Refactor infra tests, clean E2E step suites, and fix TS in tests

This commit is contained in:
2025-11-30 10:58:49 +01:00
parent af14526ae2
commit f8a1fbeb50
43 changed files with 883 additions and 2159 deletions

View File

@@ -0,0 +1,54 @@
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { PlaywrightAutomationAdapter, FixtureServer } from 'packages/infrastructure/adapters/automation';
import { StepId } from 'packages/domain/value-objects/StepId';
import { PinoLogAdapter } from 'packages/infrastructure/adapters/logging/PinoLogAdapter';
describe('Step 11 track', () => {
describe('state validation', () => {
let server: FixtureServer;
let adapter: PlaywrightAutomationAdapter;
let logger: PinoLogAdapter;
beforeEach(async () => {
server = new FixtureServer();
const serverInfo = await server.start();
logger = new PinoLogAdapter();
adapter = new PlaywrightAutomationAdapter(
{
headless: true,
timeout: 5000,
mode: 'mock',
baseUrl: serverInfo.url,
},
logger,
);
await adapter.connect();
});
afterEach(async () => {
await adapter.disconnect();
await server.stop();
});
it('fails validation when executed on Cars page instead of Track page', async () => {
await adapter.navigateToPage(server.getFixtureUrl(8));
await adapter.getPage()?.waitForLoadState('domcontentloaded');
await expect(async () => {
await adapter.executeStep(StepId.create(11), {});
}).rejects.toThrow(/Step 11 FAILED validation/i);
});
it('passes validation when on Track page', async () => {
await adapter.navigateToPage(server.getFixtureUrl(11));
await adapter.getPage()?.waitForLoadState('domcontentloaded');
const result = await adapter.executeStep(StepId.create(11), {});
expect(result.success).toBe(true);
});
});
});