test: comprehensive test suites and quality gates pass across backend, storefront and admin
- Backend (NestJS): 82 suites, 641 tests passing; 0 ESLint errors; 0 tsc errors. Hardened SSL cert/key matching, SSRF IP pinning, and eBank validation. - Admin Panel (Vite/React): 48 suites, 300 tests passing; 0 ESLint errors; 0 tsc errors. Full coverage across all pages and settings. - Storefront (Next.js): 62 suites, 368 tests passing; 0 ESLint errors; 0 tsc errors. - Fixed unmount lifecycle guards, promise error handling, and component edge cases.
This commit is contained in:
1 parent
1e73715169
commit
ddbf1ca026
439 files changed
+32911
-6107
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import { render, screen, act } from '@testing-library/react';
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { NetworkBanner } from '../NetworkBanner';
|
||||
|
||||
let mockIsOnline = true;
|
||||
vi.mock('../../lib/hooks/useNetworkStatus', () => ({
|
||||
useNetworkStatus: () => mockIsOnline,
|
||||
}));
|
||||
|
||||
vi.mock('motion/react', () => ({
|
||||
motion: {
|
||||
div: ({ children, className }: any) => <div className={className}>{children}</div>,
|
||||
},
|
||||
AnimatePresence: ({ children }: any) => <>{children}</>,
|
||||
}));
|
||||
|
||||
describe('NetworkBanner Component', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.useFakeTimers();
|
||||
});
|
||||
|
||||
it('does not render banner when initially online', () => {
|
||||
mockIsOnline = true;
|
||||
render(<NetworkBanner />);
|
||||
expect(screen.queryByText(/اتصال اینترنت شما قطع شده است/)).toBeNull();
|
||||
});
|
||||
|
||||
it('renders offline warning when network goes offline', async () => {
|
||||
mockIsOnline = false;
|
||||
render(<NetworkBanner />);
|
||||
|
||||
await act(async () => {
|
||||
await Promise.resolve();
|
||||
});
|
||||
|
||||
expect(screen.getByText(/اتصال اینترنت شما قطع شده است/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user