28 lines
1,006 B
TypeScript
28 lines
1,006 B
TypeScript
// Which fixture world the mock network serves. One scenario = one route, so every branch of the
|
|
// data layer opens in isolation and gets its own screenshot and its own accessibility pass
|
|
// (FRONTEND_PLAN.md rule 10).
|
|
//
|
|
// The list lives here rather than in `mock/` because the router needs it too, and the router may
|
|
// not see fixtures. It disappears together with the mock, and nothing outside the mock reads the
|
|
// VALUE of a scenario — only its name, as a route.
|
|
|
|
export const scenarios = [
|
|
'showcase',
|
|
'scale',
|
|
'empty',
|
|
'intake',
|
|
'loading',
|
|
'error',
|
|
'offline',
|
|
'partial',
|
|
] as const;
|
|
|
|
export type Scenario = (typeof scenarios)[number];
|
|
|
|
export const defaultScenario: Scenario = 'showcase';
|
|
|
|
/** The scenario is read from the path at start-up, before the router exists. */
|
|
export function scenarioOf(pathname: string): Scenario {
|
|
const name = pathname.replace(/^\/+|\/+$/g, '');
|
|
return (scenarios as readonly string[]).includes(name) ? (name as Scenario) : defaultScenario;
|
|
}
|