website refactor
This commit is contained in:
37
tests/shared/website/RouteScenarioMatrix.ts
Normal file
37
tests/shared/website/RouteScenarioMatrix.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { getWebsiteRouteContracts, ScenarioRole } from './RouteContractSpec';
|
||||
import { WebsiteRouteManager, RouteAccess } from './WebsiteRouteManager';
|
||||
import { routeMatchers } from '../../../apps/website/lib/routing/RouteConfig';
|
||||
|
||||
/**
|
||||
* Represents a single entry in the route coverage matrix.
|
||||
* This is a machine-readable artifact used to verify testing gaps.
|
||||
*/
|
||||
export interface RouteScenarioMatrixEntry {
|
||||
/** The resolved path of the route */
|
||||
path: string;
|
||||
/** The access level required for this route */
|
||||
accessLevel: RouteAccess;
|
||||
/** The scenarios that must be tested for this route */
|
||||
requiredScenarios: ScenarioRole[];
|
||||
/** Whether this route has parameter-based edge cases (e.g. 404s for bad IDs) */
|
||||
hasParamEdgeCases: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The RouteScenarioMatrix provides a structured view of all routes and their
|
||||
* required test scenarios. It is derived from the route contracts and inventory.
|
||||
*/
|
||||
export const RouteScenarioMatrix: RouteScenarioMatrixEntry[] = (() => {
|
||||
const contracts = getWebsiteRouteContracts();
|
||||
const manager = new WebsiteRouteManager();
|
||||
const edgeCases = manager.getParamEdgeCases();
|
||||
|
||||
return contracts.map(contract => {
|
||||
return {
|
||||
path: contract.path,
|
||||
accessLevel: contract.accessLevel,
|
||||
requiredScenarios: Object.keys(contract.scenarios) as ScenarioRole[],
|
||||
hasParamEdgeCases: edgeCases.some(ec => routeMatchers.matches(contract.path, ec.pathTemplate)),
|
||||
};
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user