Add comprehensive performance monitoring and testing infrastructure
- Implement performance dashboard with real-time metrics tracking - Add React hooks for smart polling, debouncing, and active source lookup - Create Jest testing framework with comprehensive test suites for components, API endpoints, and utilities - Enhance UI components with optimized rendering and memoization - Improve polling efficiency with visibility detection and adaptive intervals 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
a66979fb34
commit
c259f0d943
15 changed files with 6320 additions and 94 deletions
69
jest.setup.js
Normal file
69
jest.setup.js
Normal file
|
@ -0,0 +1,69 @@
|
|||
import '@testing-library/jest-dom';
|
||||
import { TextEncoder, TextDecoder } from 'util';
|
||||
|
||||
// Polyfills for Node.js environment
|
||||
global.TextEncoder = TextEncoder;
|
||||
global.TextDecoder = TextDecoder;
|
||||
|
||||
// Mock NextResponse for API route testing
|
||||
jest.mock('next/server', () => ({
|
||||
NextResponse: {
|
||||
json: jest.fn((data, options) => ({
|
||||
data,
|
||||
status: options?.status || 200,
|
||||
json: async () => data,
|
||||
})),
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock Next.js router
|
||||
jest.mock('next/navigation', () => ({
|
||||
useRouter() {
|
||||
return {
|
||||
push: jest.fn(),
|
||||
replace: jest.fn(),
|
||||
prefetch: jest.fn(),
|
||||
back: jest.fn(),
|
||||
forward: jest.fn(),
|
||||
refresh: jest.fn(),
|
||||
};
|
||||
},
|
||||
useParams() {
|
||||
return {};
|
||||
},
|
||||
usePathname() {
|
||||
return '';
|
||||
},
|
||||
useSearchParams() {
|
||||
return new URLSearchParams();
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock window.confirm for delete operations
|
||||
global.confirm = jest.fn(() => true);
|
||||
|
||||
// Mock console.error to avoid noise in tests
|
||||
const originalError = console.error;
|
||||
beforeAll(() => {
|
||||
console.error = (...args) => {
|
||||
if (
|
||||
typeof args[0] === 'string' &&
|
||||
args[0].includes('Warning: ReactDOM.render is no longer supported')
|
||||
) {
|
||||
return;
|
||||
}
|
||||
originalError.call(console, ...args);
|
||||
};
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
console.error = originalError;
|
||||
});
|
||||
|
||||
// Mock fetch globally
|
||||
global.fetch = jest.fn();
|
||||
|
||||
// Reset all mocks between tests
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue