61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||
import type { StepHarness } from '../support/StepHarness';
|
||
import { createStepHarness } from '../support/StepHarness';
|
||
|
||
describe('Step 8 – cars', () => {
|
||
let harness: StepHarness;
|
||
|
||
beforeEach(async () => {
|
||
harness = await createStepHarness();
|
||
});
|
||
|
||
afterEach(async () => {
|
||
await harness.dispose();
|
||
});
|
||
|
||
describe('alignment', () => {
|
||
it('executes on Cars page in mock wizard', async () => {
|
||
await harness.navigateToFixtureStep(8);
|
||
|
||
const page = harness.adapter.getPage();
|
||
expect(page).not.toBeNull();
|
||
|
||
const stepIndicatorBefore = await page!.textContent('[data-indicator]');
|
||
expect(stepIndicatorBefore).toContain('Set Cars');
|
||
|
||
const result = await harness.executeStep(8, {});
|
||
|
||
expect(result.success).toBe(true);
|
||
expect(result.error).toBeUndefined();
|
||
});
|
||
});
|
||
|
||
describe('state validation', () => {
|
||
it('fails validation when executed on Track page instead of Cars page', async () => {
|
||
await harness.navigateToFixtureStep(11);
|
||
await harness.adapter.getPage()?.waitForLoadState('domcontentloaded');
|
||
|
||
await expect(async () => {
|
||
await harness.executeStep(8, {});
|
||
}).rejects.toThrow(/Step 8 FAILED validation/i);
|
||
});
|
||
|
||
it('fails fast on Step 8 if already past Cars page', async () => {
|
||
await harness.navigateToFixtureStep(11);
|
||
await harness.adapter.getPage()?.waitForLoadState('domcontentloaded');
|
||
|
||
await expect(async () => {
|
||
await harness.executeStep(8, {});
|
||
}).rejects.toThrow(/Step 8 FAILED validation/i);
|
||
});
|
||
|
||
it('passes validation when on Cars page', async () => {
|
||
await harness.navigateToFixtureStep(8);
|
||
await harness.adapter.getPage()?.waitForLoadState('domcontentloaded');
|
||
|
||
const result = await harness.executeStep(8, {});
|
||
|
||
expect(result.success).toBe(true);
|
||
});
|
||
});
|
||
}); |