fix issues in core

This commit is contained in:
2025-12-23 11:25:08 +01:00
parent 1efd971032
commit 2854ae3c5c
113 changed files with 1142 additions and 458 deletions

View File

@@ -2,6 +2,7 @@ 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';
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
describe('GetCurrentUserSessionUseCase', () => {
let sessionPort: {
@@ -9,7 +10,8 @@ describe('GetCurrentUserSessionUseCase', () => {
createSession: Mock;
clearSession: Mock;
};
let logger: Logger;
let output: UseCaseOutputPort<any> & { present: Mock };
let useCase: GetCurrentUserSessionUseCase;
beforeEach(() => {
@@ -19,7 +21,22 @@ describe('GetCurrentUserSessionUseCase', () => {
clearSession: vi.fn(),
};
useCase = new GetCurrentUserSessionUseCase(sessionPort as unknown as IdentitySessionPort);
logger = {
debug: vi.fn(),
info: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
} as unknown as Logger;
output = {
present: vi.fn(),
};
useCase = new GetCurrentUserSessionUseCase(
sessionPort as unknown as IdentitySessionPort,
logger,
output,
);
});
it('returns the current auth session when one exists', async () => {
@@ -40,7 +57,8 @@ describe('GetCurrentUserSessionUseCase', () => {
const result = await useCase.execute();
expect(sessionPort.getCurrentSession).toHaveBeenCalledTimes(1);
expect(result).toEqual(session);
expect(result.isOk()).toBe(true);
expect(output.present).toHaveBeenCalledWith(session);
});
it('returns null when there is no active session', async () => {
@@ -49,6 +67,7 @@ describe('GetCurrentUserSessionUseCase', () => {
const result = await useCase.execute();
expect(sessionPort.getCurrentSession).toHaveBeenCalledTimes(1);
expect(result).toBeNull();
expect(result.isOk()).toBe(true);
expect(output.present).toHaveBeenCalledWith(null);
});
});
});