test(harness): stabilize backend+frontend QA test suite (12/12+63/63 unit+integration, 45/45 frontend)
Stabilize test harness across full stack: Backend integration tests: - Fix Auth/Club/Migration/RLS/Member/Tenant/RLS Isolation/Shift/Task test suites - Add AssemblyInfo.cs for test configuration - Enhance CustomWebApplicationFactory + TestAuthHandler for stable test environment - Expand RlsIsolationTests with comprehensive multi-tenant RLS verification Frontend test harness: - Align vitest.config.ts with backend API changes - Add bunfig.toml for bun test environment stability - Enhance api.test.ts with proper test setup integration - Expand test/setup.ts with fixture initialization All tests now passing: backend 12/12 unit + 63/63 integration, frontend 45/45
This commit is contained in:
@@ -24,7 +24,13 @@ describe('apiClient', () => {
|
||||
expires: '2099-01-01',
|
||||
});
|
||||
|
||||
(global.localStorage.getItem as any).mockReturnValue('club-1');
|
||||
// Mock document.cookie with X-Tenant-Id
|
||||
Object.defineProperty(document, 'cookie', {
|
||||
value: 'X-Tenant-Id=club-1',
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
(global.fetch as any).mockResolvedValue({
|
||||
ok: true,
|
||||
status: 200,
|
||||
@@ -143,8 +149,12 @@ describe('apiClient', () => {
|
||||
expect(callHeaders.Authorization).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should not add X-Tenant-Id header when no active club', async () => {
|
||||
(global.localStorage.getItem as any).mockReturnValueOnce(null);
|
||||
it('should not add X-Tenant-Id header when no cookie present', async () => {
|
||||
Object.defineProperty(document, 'cookie', {
|
||||
value: '',
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
await apiClient('/api/test');
|
||||
|
||||
|
||||
@@ -8,5 +8,18 @@ const localStorageMock = {
|
||||
clear: vi.fn(),
|
||||
};
|
||||
|
||||
// Ensure localStorage is available on both global and globalThis
|
||||
global.localStorage = localStorageMock as any;
|
||||
globalThis.localStorage = localStorageMock as any;
|
||||
|
||||
// Ensure document is available if jsdom hasn't set it up yet
|
||||
if (typeof document === 'undefined') {
|
||||
Object.defineProperty(globalThis, 'document', {
|
||||
value: {
|
||||
body: {},
|
||||
},
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user