Răsfoiți Sursa

fix: resolve TypeScript errors in test files

- Remove unused 'screen' import from NowPlayingBar.test.tsx
- Add missing IntersectionObserver properties to MockIntersectionObserver
- Use type-only imports for PatternMetadata, PreviewData in handlers.ts
- Use type-only imports for RenderOptions, ReactElement, ReactNode in utils.tsx
- Export IntegrationWrapper to resolve unused variable warning

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
tuanchris 1 săptămână în urmă
părinte
comite
00c84c690c

+ 1 - 1
frontend/src/__tests__/components/NowPlayingBar.test.tsx

@@ -1,5 +1,5 @@
 import { describe, it, expect, vi, beforeEach } from 'vitest'
-import { renderWithProviders, screen } from '../../test/utils'
+import { renderWithProviders } from '../../test/utils'
 import { NowPlayingBar } from '../../components/NowPlayingBar'
 
 describe('NowPlayingBar', () => {

+ 10 - 1
frontend/src/test/mocks/browser.ts

@@ -1,10 +1,15 @@
 import { vi } from 'vitest'
 
 // Mock IntersectionObserver
-export class MockIntersectionObserver {
+export class MockIntersectionObserver implements IntersectionObserver {
   callback: IntersectionObserverCallback
   elements: Set<Element> = new Set()
 
+  // Required IntersectionObserver properties
+  readonly root: Element | Document | null = null
+  readonly rootMargin: string = '0px'
+  readonly thresholds: ReadonlyArray<number> = [0]
+
   constructor(callback: IntersectionObserverCallback) {
     this.callback = callback
   }
@@ -25,6 +30,10 @@ export class MockIntersectionObserver {
   disconnect() {
     this.elements.clear()
   }
+
+  takeRecords(): IntersectionObserverEntry[] {
+    return []
+  }
 }
 
 // Mock matchMedia

+ 1 - 1
frontend/src/test/mocks/handlers.ts

@@ -1,5 +1,5 @@
 import { http, HttpResponse } from 'msw'
-import { PatternMetadata, PreviewData } from '@/lib/types'
+import type { PatternMetadata, PreviewData } from '@/lib/types'
 
 // ============================================
 // API Call Tracking for Integration Tests

+ 5 - 4
frontend/src/test/utils.tsx

@@ -1,7 +1,8 @@
-import { render, RenderOptions } from '@testing-library/react'
+import { render } from '@testing-library/react'
+import type { RenderOptions } from '@testing-library/react'
 import { BrowserRouter, MemoryRouter, Routes, Route } from 'react-router'
-import { ReactElement, ReactNode } from 'react'
-import { PatternMetadata, PreviewData } from '@/lib/types'
+import type { ReactElement, ReactNode } from 'react'
+import type { PatternMetadata, PreviewData } from '@/lib/types'
 import { TableProvider } from '@/contexts/TableContext'
 import { Layout } from '@/components/layout/Layout'
 import { BrowsePage } from '@/pages/BrowsePage'
@@ -14,7 +15,7 @@ function AllProviders({ children }: { children: ReactNode }) {
 }
 
 // Integration test wrapper - full app with routing
-function IntegrationWrapper({
+export function IntegrationWrapper({
   children,
   initialEntries = ['/']
 }: {