mirror of
https://github.com/johndoe6345789/snippet-pastebin.git
synced 2026-04-24 13:34:55 +00:00
Key improvements:
1. Restored Dialog component open/onOpenChange props that were removed during lint fixes
- Dialog now correctly hides content when open={false}
- This was causing 6 SnippetDialog tests to fail
2. Test improvements:
- Fixed SnippetDialog test issues (6 failures → 0)
- Reduced overall test failures from 14 to 8
- Unit tests now: 281 passing, 8 failing (improved from 275/14)
3. Remaining failures are in Tooltip component tests
- These tests expect hovering to show content
- Require further investigation into tooltip rendering behavior
Results:
- Unit Tests: 281 passing, 8 failing (improved)
- E2E Tests: Still 204 passing, 59 failing (blocked on Tooltip issues)
- Linter: 0 errors (maintained)
Next iteration should focus on:
1. Tooltip component rendering and show/hide behavior
2. E2E test failures analysis
3. Further component fixes
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
76 lines
1.6 KiB
TypeScript
76 lines
1.6 KiB
TypeScript
import '@testing-library/jest-dom'
|
|
import React from 'react'
|
|
|
|
// Make React globally available for components that may reference it
|
|
global.React = React
|
|
|
|
// Mock import.meta for Vite compatibility
|
|
Object.defineProperty(globalThis, 'import', {
|
|
value: {
|
|
meta: {
|
|
env: {
|
|
DEV: false,
|
|
PROD: true,
|
|
SSR: false,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
// Mock Next.js router
|
|
jest.mock('next/router', () => ({
|
|
useRouter: () => ({
|
|
push: jest.fn(),
|
|
pathname: '/',
|
|
query: {},
|
|
asPath: '/',
|
|
}),
|
|
}))
|
|
|
|
// Mock Next.js navigation
|
|
jest.mock('next/navigation', () => ({
|
|
useRouter: () => ({
|
|
push: jest.fn(),
|
|
replace: jest.fn(),
|
|
prefetch: jest.fn(),
|
|
}),
|
|
usePathname: () => '/',
|
|
useSearchParams: () => new URLSearchParams(),
|
|
useParams: () => ({}),
|
|
}))
|
|
|
|
// Mock window.matchMedia
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
writable: true,
|
|
value: jest.fn().mockImplementation(query => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: jest.fn(),
|
|
removeListener: jest.fn(),
|
|
addEventListener: jest.fn(),
|
|
removeEventListener: jest.fn(),
|
|
dispatchEvent: jest.fn(),
|
|
})),
|
|
})
|
|
|
|
// Suppress console errors in tests unless explicitly needed
|
|
const originalError = console.error
|
|
beforeAll(() => {
|
|
console.error = (...args: unknown[]) => {
|
|
if (
|
|
typeof args[0] === 'string' &&
|
|
(args[0].includes('Warning: ReactDOM.render') ||
|
|
args[0].includes('Warning: useLayoutEffect') ||
|
|
args[0].includes('Not implemented: HTMLFormElement.prototype.submit'))
|
|
) {
|
|
return
|
|
}
|
|
originalError.call(console, ...args)
|
|
}
|
|
})
|
|
|
|
afterAll(() => {
|
|
console.error = originalError
|
|
})
|