54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||
import type { StepHarness } from '../support/StepHarness';
|
||
import { createStepHarness } from '../support/StepHarness';
|
||
import { IRACING_SELECTORS } from 'core/automation/infrastructure//automation/dom/IRacingSelectors';
|
||
|
||
describe('Step 14 – time of day', () => {
|
||
let harness: StepHarness;
|
||
|
||
beforeEach(async () => {
|
||
harness = await createStepHarness();
|
||
});
|
||
|
||
afterEach(async () => {
|
||
await harness.dispose();
|
||
});
|
||
|
||
it('executes on Time of Day page and applies time-of-day slider from config', async () => {
|
||
await harness.navigateToFixtureStep(14);
|
||
|
||
const page = harness.adapter.getPage();
|
||
expect(page).not.toBeNull();
|
||
|
||
const container = page!
|
||
.locator(IRACING_SELECTORS.wizard.stepContainers.timeOfDay)
|
||
.first();
|
||
expect(await container.count()).toBeGreaterThan(0);
|
||
|
||
const sidebarTimeOfDay = await page!.textContent(
|
||
'#wizard-sidebar-link-set-time-of-day',
|
||
);
|
||
expect(sidebarTimeOfDay).toContain('Time of Day');
|
||
|
||
const config = { timeOfDay: 800 };
|
||
|
||
const result = await harness.executeStep(14, config);
|
||
|
||
expect(result.success).toBe(true);
|
||
expect(result.error).toBeUndefined();
|
||
|
||
const timeSlider = page!
|
||
.locator(IRACING_SELECTORS.steps.timeOfDay)
|
||
.first();
|
||
const sliderExists = await timeSlider.count();
|
||
expect(sliderExists).toBeGreaterThan(0);
|
||
|
||
const valueAttr =
|
||
(await timeSlider.getAttribute('data-value')) ??
|
||
(await timeSlider.inputValue().catch(() => null));
|
||
expect(valueAttr).toBe(String(config.timeOfDay));
|
||
|
||
const footerText = await page!.textContent('.wizard-footer');
|
||
expect(footerText).toMatch(/Weather/i);
|
||
});
|
||
}); |