resolve todos in website

This commit is contained in:
2025-12-20 12:55:07 +01:00
parent 20588e1c0b
commit 92be9d2e1b
56 changed files with 2476 additions and 78 deletions

View File

@@ -0,0 +1,54 @@
import { describe, it, expect, vi, type Mock } from 'vitest';
import { GetCurrentUserSessionUseCase } from './GetCurrentUserSessionUseCase';
import type { IdentitySessionPort } from '../ports/IdentitySessionPort';
import type { AuthSessionDTO } from '../dto/AuthSessionDTO';
describe('GetCurrentUserSessionUseCase', () => {
let sessionPort: {
getCurrentSession: Mock;
createSession: Mock;
clearSession: Mock;
};
let useCase: GetCurrentUserSessionUseCase;
beforeEach(() => {
sessionPort = {
getCurrentSession: vi.fn(),
createSession: vi.fn(),
clearSession: vi.fn(),
};
useCase = new GetCurrentUserSessionUseCase(sessionPort as unknown as IdentitySessionPort);
});
it('returns the current auth session when one exists', async () => {
const session: AuthSessionDTO = {
user: {
id: 'user-1',
email: 'test@example.com',
displayName: 'Test User',
primaryDriverId: 'driver-1',
},
issuedAt: Date.now(),
expiresAt: Date.now() + 1000,
token: 'token-123',
};
sessionPort.getCurrentSession.mockResolvedValue(session);
const result = await useCase.execute();
expect(sessionPort.getCurrentSession).toHaveBeenCalledTimes(1);
expect(result).toEqual(session);
});
it('returns null when there is no active session', async () => {
sessionPort.getCurrentSession.mockResolvedValue(null);
const result = await useCase.execute();
expect(sessionPort.getCurrentSession).toHaveBeenCalledTimes(1);
expect(result).toBeNull();
});
});