Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Storybook test-runner configuration (Phase 08 #62).
|
||||
*
|
||||
* The test-runner spins up Playwright + Chromium, walks every story
|
||||
* registered in `main.ts`, and applies the `postVisit` hook below to
|
||||
* each one. The hook re-runs the same axe-rules ruleset the in-canvas
|
||||
* `@storybook/addon-a11y` panel uses (see `.storybook/preview.tsx`)
|
||||
* but in a real headless Chromium where `color-contrast` actually
|
||||
* resolves CSS — failures here are real WCAG-2.2-AA regressions and
|
||||
* MUST be fixed (or explicitly opted-out via `parameters.a11y.disable
|
||||
* = true` with a justification comment in the story).
|
||||
*
|
||||
* The `getStoryContext` / `injectAxe` / `checkA11y` triple is the
|
||||
* documented integration recipe; we override the axe-context to the
|
||||
* Storybook root so out-of-frame chrome (toolbar etc.) is ignored.
|
||||
*/
|
||||
import type { TestRunnerConfig } from "@storybook/test-runner";
|
||||
import { getStoryContext } from "@storybook/test-runner";
|
||||
import { checkA11y, configureAxe, injectAxe } from "axe-playwright";
|
||||
|
||||
const config: TestRunnerConfig = {
|
||||
async preVisit(page) {
|
||||
await injectAxe(page);
|
||||
},
|
||||
async postVisit(page, context) {
|
||||
const storyContext = await getStoryContext(page, context);
|
||||
const a11yParameter = (storyContext.parameters as {
|
||||
a11y?: { disable?: boolean; config?: unknown; options?: unknown };
|
||||
}).a11y;
|
||||
|
||||
if (a11yParameter?.disable) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (a11yParameter?.config || a11yParameter?.options) {
|
||||
await configureAxe(page, {
|
||||
rules: ((a11yParameter.config as { rules?: unknown[] } | undefined)?.rules ?? []) as never[],
|
||||
});
|
||||
}
|
||||
|
||||
await checkA11y(page, "#storybook-root", {
|
||||
detailedReport: true,
|
||||
detailedReportOptions: { html: true },
|
||||
axeOptions: a11yParameter?.options as Parameters<typeof checkA11y>[2] extends infer T
|
||||
? T extends { axeOptions?: infer A }
|
||||
? A
|
||||
: undefined
|
||||
: undefined,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
Reference in new issue
Block a user