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

@@ -24,7 +24,11 @@ describe('OverlaySyncService (unit)', () => {
test('startAction resolves as confirmed only after action-started event is emitted', async () => {
const emitter = new MockLifecycleEmitter()
// create service wiring: pass emitter as dependency (constructor shape expected)
const svc = new OverlaySyncService({ lifecycleEmitter: emitter as any, logger: console as any, publisher: { publish: async () => {} } as any })
const svc = new OverlaySyncService({
lifecycleEmitter: emitter,
logger: console,
publisher: { publish: async () => {} },
})
const action: OverlayAction = { id: 'add-car', label: 'Adding...' }

View File

@@ -11,7 +11,7 @@ class MockLifecycleEmitter implements IAutomationLifecycleEmitter {
offLifecycle(cb: LifecycleCallback): void {
this.callbacks.delete(cb)
}
async emit(event: any) {
async emit(event: { type: string; actionId: string; timestamp: number }) {
for (const cb of Array.from(this.callbacks)) {
cb(event)
}
@@ -21,7 +21,11 @@ class MockLifecycleEmitter implements IAutomationLifecycleEmitter {
describe('OverlaySyncService timeout (unit)', () => {
test('startAction with short timeout resolves as tentative when no events', async () => {
const emitter = new MockLifecycleEmitter()
const svc = new OverlaySyncService({ lifecycleEmitter: emitter as any, logger: console as any, publisher: { publish: async () => {} } as any })
const svc = new OverlaySyncService({
lifecycleEmitter: emitter,
logger: console,
publisher: { publish: async () => {} },
})
const action: OverlayAction = { id: 'add-car', label: 'Adding...', timeoutMs: 50 }

View File

@@ -233,13 +233,13 @@ describe('CheckAuthenticationUseCase', () => {
mockAuthService.getSessionExpiry.mockResolvedValue(
Result.ok(new Date(Date.now() + 3600000))
);
(mockAuthService as any).verifyPageAuthentication = vi.fn().mockResolvedValue(
mockAuthService.verifyPageAuthentication = vi.fn().mockResolvedValue(
Result.ok(new BrowserAuthenticationState(true, true))
);
await useCase.execute({ verifyPageContent: true });
expect((mockAuthService as any).verifyPageAuthentication).toHaveBeenCalledTimes(1);
expect(mockAuthService.verifyPageAuthentication).toHaveBeenCalledTimes(1);
});
it('should return EXPIRED when cookies valid but page shows login UI', async () => {
@@ -253,7 +253,7 @@ describe('CheckAuthenticationUseCase', () => {
mockAuthService.getSessionExpiry.mockResolvedValue(
Result.ok(new Date(Date.now() + 3600000))
);
(mockAuthService as any).verifyPageAuthentication = vi.fn().mockResolvedValue(
mockAuthService.verifyPageAuthentication = vi.fn().mockResolvedValue(
Result.ok(new BrowserAuthenticationState(true, false))
);
@@ -274,7 +274,7 @@ describe('CheckAuthenticationUseCase', () => {
mockAuthService.getSessionExpiry.mockResolvedValue(
Result.ok(new Date(Date.now() + 3600000))
);
(mockAuthService as any).verifyPageAuthentication = vi.fn().mockResolvedValue(
mockAuthService.verifyPageAuthentication = vi.fn().mockResolvedValue(
Result.ok(new BrowserAuthenticationState(true, true))
);
@@ -295,11 +295,11 @@ describe('CheckAuthenticationUseCase', () => {
mockAuthService.getSessionExpiry.mockResolvedValue(
Result.ok(new Date(Date.now() + 3600000))
);
(mockAuthService as any).verifyPageAuthentication = vi.fn();
mockAuthService.verifyPageAuthentication = vi.fn();
await useCase.execute();
expect((mockAuthService as any).verifyPageAuthentication).not.toHaveBeenCalled();
expect(mockAuthService.verifyPageAuthentication).not.toHaveBeenCalled();
});
it('should handle verifyPageAuthentication errors gracefully', async () => {
@@ -313,7 +313,7 @@ describe('CheckAuthenticationUseCase', () => {
mockAuthService.getSessionExpiry.mockResolvedValue(
Result.ok(new Date(Date.now() + 3600000))
);
(mockAuthService as any).verifyPageAuthentication = vi.fn().mockResolvedValue(
mockAuthService.verifyPageAuthentication = vi.fn().mockResolvedValue(
Result.err('Page navigation failed')
);
@@ -388,7 +388,7 @@ describe('CheckAuthenticationUseCase', () => {
mockAuthService.getSessionExpiry.mockResolvedValue(
Result.ok(new Date(Date.now() + 3600000))
);
(mockAuthService as any).verifyPageAuthentication = vi.fn().mockResolvedValue(
mockAuthService.verifyPageAuthentication = vi.fn().mockResolvedValue(
Result.ok(new BrowserAuthenticationState(true, false))
);

View File

@@ -56,7 +56,7 @@ describe('CompleteRaceCreationUseCase', () => {
const state = CheckoutState.ready();
vi.mocked(mockCheckoutService.extractCheckoutInfo).mockResolvedValue(
Result.ok({ price: undefined as any, state, buttonHtml: '<a>n/a</a>' })
Result.ok({ price: undefined, state, buttonHtml: '<a>n/a</a>' })
);
const result = await useCase.execute('test-session-123');