This commit is contained in:
2025-12-11 21:06:25 +01:00
parent c49ea2598d
commit ec3ddc3a5c
227 changed files with 3496 additions and 2083 deletions

View File

@@ -10,10 +10,12 @@ import { describe, it, expect } from 'vitest';
describe('RootLayout auth caching behavior', () => {
it('is configured as dynamic to avoid static auth caching', async () => {
const layoutModule = await import('../../../../apps/website/app/layout');
const layoutModule = (await import(
'../../../../apps/website/app/layout',
)) as { dynamic?: string };
// Next.js dynamic routing flag
const dynamic = (layoutModule as any).dynamic;
const dynamic = layoutModule.dynamic;
expect(dynamic).toBe('force-dynamic');
});
@@ -21,9 +23,11 @@ describe('RootLayout auth caching behavior', () => {
describe('Dashboard auth caching behavior', () => {
it('is configured as dynamic to evaluate auth per request', async () => {
const dashboardModule = await import('../../../../apps/website/app/dashboard/page');
const dynamic = (dashboardModule as any).dynamic;
const dashboardModule = (await import(
'../../../../apps/website/app/dashboard/page',
)) as { dynamic?: string };
const dynamic = dashboardModule.dynamic;
expect(dynamic).toBe('force-dynamic');
});

View File

@@ -26,7 +26,7 @@ describe('iRacing auth route handlers', () => {
it('start route redirects to auth URL and sets state cookie', async () => {
const req = new Request('http://localhost/auth/iracing/start?returnTo=/dashboard');
const res = await startGet(req as any);
const res = await startGet(req);
expect(res.status).toBe(307);
const location = res.headers.get('location') ?? '';
@@ -51,7 +51,7 @@ describe('iRacing auth route handlers', () => {
'http://localhost/auth/iracing/callback?code=demo-code&state=valid-state&returnTo=/dashboard',
);
const res = await callbackGet(req as any);
const res = await callbackGet(req);
expect(res.status).toBe(307);
const location = res.headers.get('location');
@@ -70,7 +70,7 @@ describe('iRacing auth route handlers', () => {
method: 'POST',
});
const res = await logoutPost(req as any);
const res = await logoutPost(req);
expect(res.status).toBe(307);
const location = res.headers.get('location');

View File

@@ -43,7 +43,7 @@ function createSearchParams(stepValue: string | null) {
}
return null;
},
} as any;
} as URLSearchParams;
}
describe('CreateLeaguePage - URL-bound wizard steps', () => {

View File

@@ -10,13 +10,15 @@ const mockCheckRateLimit = vi.fn<[], Promise<RateLimitResult>>();
const mockGetClientIp = vi.fn<[], string>();
vi.mock('../../../apps/website/lib/rate-limit', () => ({
checkRateLimit: (...args: any[]) => mockCheckRateLimit(...(args as [])),
getClientIp: (..._args: any[]) => mockGetClientIp(),
checkRateLimit: (...args: unknown[]) => mockCheckRateLimit(...(args as [])),
getClientIp: (..._args: unknown[]) => mockGetClientIp(),
}));
async function getPostHandler() {
const routeModule: any = await import('../../../apps/website/app/api/signup/route');
return routeModule.POST as (request: Request) => Promise<Response>;
const routeModule = (await import(
'../../../apps/website/app/api/signup/route'
)) as { POST: (request: Request) => Promise<Response> };
return routeModule.POST;
}
function createJsonRequest(body: unknown): Request {
@@ -55,7 +57,7 @@ describe('/api/signup POST', () => {
expect(response.status).toBeGreaterThanOrEqual(200);
expect(response.status).toBeLessThan(300);
const data = (await response.json()) as any;
const data = (await response.json()) as { message: unknown; ok: unknown };
expect(data).toHaveProperty('message');
expect(typeof data.message).toBe('string');
@@ -73,7 +75,7 @@ describe('/api/signup POST', () => {
expect(response.status).toBe(400);
const data = (await response.json()) as any;
const data = (await response.json()) as { error: unknown };
expect(typeof data.error).toBe('string');
expect(data.error.toLowerCase()).toContain('email');
});
@@ -89,7 +91,7 @@ describe('/api/signup POST', () => {
expect(response.status).toBe(400);
const data = (await response.json()) as any;
const data = (await response.json()) as { error: unknown };
expect(typeof data.error).toBe('string');
});
@@ -106,7 +108,7 @@ describe('/api/signup POST', () => {
expect(second.status).toBe(409);
const data = (await second.json()) as any;
const data = (await second.json()) as { error: unknown };
expect(typeof data.error).toBe('string');
expect(data.error.toLowerCase()).toContain('already');
});
@@ -128,7 +130,7 @@ describe('/api/signup POST', () => {
expect(response.status).toBe(429);
const data = (await response.json()) as any;
const data = (await response.json()) as { error: unknown; retryAfter?: unknown };
expect(typeof data.error).toBe('string');
expect(data).toHaveProperty('retryAfter');
});