import type { Scenario } from './e2e';
export type Pace = 'normal' | 'slow';
const PACES = {
normal: { stepDelayMs: 0, typeDelayMs: 10, timeScale: 1, endPauseMs: 0 },
slow: { stepDelayMs: 800, typeDelayMs: 150, timeScale: 4, endPauseMs: 5000 },
} satisfies Record<Pace, { stepDelayMs: number; typeDelayMs: number; timeScale: number; endPauseMs: number }>;
let current: Pace = 'normal';
export const isSlow = () => current === 'slow';
export const stepDelayMs = () => PACES[current].stepDelayMs;
export const typeDelayMs = () => PACES[current].typeDelayMs;
export const scaled = (ms: number) => ms * PACES[current].timeScale;
* Register a scenario as a test at the given pace. The pace is set when the test runs,
* not when it's registered, because "Run all specs" loads every spec into one page.
*/
export function runScenario(scenario: Scenario, pace: Pace = 'normal') {
it(pace === 'slow' ? `${scenario.title} (slow)` : scenario.title, () => {
current = pace;
scenario.run();
const { endPauseMs } = PACES[pace];
if (endPauseMs > 0) cy.wait(endPauseMs, { log: false });
});
}