@forgebook/testing 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/src/browserTests.d.ts +2 -0
- package/dist/src/browserTests.d.ts.map +1 -1
- package/dist/src/browserTests.js +52 -32
- package/dist/src/browserTests.js.map +1 -1
- package/dist/src/checkStories.d.ts.map +1 -1
- package/dist/src/checkStories.js +10 -7
- package/dist/src/checkStories.js.map +1 -1
- package/dist/src/storyPages.d.ts.map +1 -1
- package/dist/src/storyPages.js +7 -1
- package/dist/src/storyPages.js.map +1 -1
- package/dist/src/storyTestPlan.d.ts +45 -0
- package/dist/src/storyTestPlan.d.ts.map +1 -0
- package/dist/src/storyTestPlan.js +21 -0
- package/dist/src/storyTestPlan.js.map +1 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -113,6 +113,14 @@ structure view), starting Vite through the package manager that runs them (`vite
|
|
|
113
113
|
another command). A story that breaks a rule fails all its variants; `storyBrowserTests` also takes `check`, a rule of
|
|
114
114
|
the package's own run on every frame.
|
|
115
115
|
|
|
116
|
+
A story about logic (`parameters: { logic: true }`, a hook's or a function's scene) is tested once, in the catalogue's
|
|
117
|
+
default view, named `logic`: the variants only change how it looks. Its test still waits for the frame to be ready, so
|
|
118
|
+
its play has to pass, and fails on an error in the page; axe runs too, since the scene is a page a person uses and a
|
|
119
|
+
demo that fails WCAG is a bad example to copy. The checks about looks are left out: the spills and the overlays (layout
|
|
120
|
+
at the variants' widths) and the package's own `check`, and a screenshot run takes no reference image of it.
|
|
121
|
+
`forgebook check` runs the same checks on it, and with `--all-variants` both it and `forgebook shot` open it once, in
|
|
122
|
+
the default view.
|
|
123
|
+
|
|
116
124
|
### On the server
|
|
117
125
|
|
|
118
126
|
One test file and a Vitest configuration with the catalogue's plugin, which reads the source's
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* `check`. The variants include a
|
|
12
12
|
* narrow frame, as wide as the catalogue's stage beside the props panel. With `screenshot` it compares the frame with its reference image instead,
|
|
13
13
|
* for the visual tests, which run in the Playwright container so fonts and rendering are the same everywhere.
|
|
14
|
+
* A story about logic (`parameters.logic`) is tested once, in the default view, without the layout checks, and never
|
|
15
|
+
* pictured (`storyTestPlan.ts`).
|
|
14
16
|
*
|
|
15
17
|
* @module
|
|
16
18
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserTests.d.ts","sourceRoot":"","sources":["../../src/browserTests.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"browserTests.d.ts","sourceRoot":"","sources":["../../src/browserTests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAU,KAAK,IAAI,EAAQ,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAqB,KAAK,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AAKhG,OAAO,EAAoC,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjF,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGxE,sCAAsC;AACtC,MAAM,MAAM,YAAY,GAAG;IACzB,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IACpD,yEAAyE;IACzE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,oHAAoH;AACpH,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,aAAc,SAAS,UAAU,EAAE,KAAG,YAAY,EAuB3E,CAAC;AAEF,oHAAoH;AACpH,eAAO,MAAM,cAAc,EAAE,SAAS,YAAY,EAAoC,CAAC;AAEvF,oCAAoC;AACpC,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,GAAG;IACzD,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,qHAAqH;IACrH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IAC1C,gHAAgH;IAChH,QAAQ,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IAChC,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAC5C,qGAAqG;IACrG,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD,CAAC;AA8BF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,YAAa,wBAAwB,KAAG,IA2CrE,CAAC"}
|
package/dist/src/browserTests.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* `check`. The variants include a
|
|
12
12
|
* narrow frame, as wide as the catalogue's stage beside the props panel. With `screenshot` it compares the frame with its reference image instead,
|
|
13
13
|
* for the visual tests, which run in the Playwright container so fonts and rendering are the same everywhere.
|
|
14
|
+
* A story about logic (`parameters.logic`) is tested once, in the default view, without the layout checks, and never
|
|
15
|
+
* pictured (`storyTestPlan.ts`).
|
|
14
16
|
*
|
|
15
17
|
* @module
|
|
16
18
|
*/
|
|
@@ -24,6 +26,7 @@ import { defaultView, frameAddress } from "forgebook/view-state";
|
|
|
24
26
|
import { isOverlayChecked } from "./overlays.js";
|
|
25
27
|
import { axeProblems, overlayProblems, spillProblems, watchedErrors } from "./storyCheck.js";
|
|
26
28
|
import { indexedSource } from "./storyFiles.js";
|
|
29
|
+
import { plannedStoryTests } from "./storyTestPlan.js";
|
|
27
30
|
/** The narrow variant's width: about the catalogue's stage beside the props panel in a laptop window, in CSS px. */
|
|
28
31
|
export const NARROW_WIDTH = 560;
|
|
29
32
|
/**
|
|
@@ -58,6 +61,26 @@ export const storyVariants = (switches) => {
|
|
|
58
61
|
};
|
|
59
62
|
/** The variants of a catalogue with the default switches: light, dark, both at more contrast, structure, narrow. */
|
|
60
63
|
export const STORY_VARIANTS = storyVariants(DEFAULT_SWITCHES);
|
|
64
|
+
/** A problem list's messages, so a failing test names each problem. */
|
|
65
|
+
const messages = (problems) => problems.map((problem) => problem.message);
|
|
66
|
+
/**
|
|
67
|
+
* Runs the checks of one planned test on a shown story: axe, then for a story about its looks the spills, the
|
|
68
|
+
* source's own check, and the overlays last (it resizes the window, which may close what the story left open). A story
|
|
69
|
+
* about logic gets axe only.
|
|
70
|
+
*
|
|
71
|
+
* @param page - the story's frame, ready.
|
|
72
|
+
* @param planned - the story, its variant and whether its layout is checked.
|
|
73
|
+
* @param a11y - the catalogue's accessibility rules.
|
|
74
|
+
* @param check - the source's own check, if any.
|
|
75
|
+
*/
|
|
76
|
+
const expectChecksPass = async (page, planned, a11y, check) => {
|
|
77
|
+
expect(messages(await axeProblems(page, a11y))).toEqual([]);
|
|
78
|
+
if (!planned.hasLookChecks)
|
|
79
|
+
return;
|
|
80
|
+
expect(messages(await spillProblems(page))).toEqual([]);
|
|
81
|
+
await check?.(page);
|
|
82
|
+
expect(messages(await overlayProblems(page, isOverlayChecked(planned.variant.view), planned.story.height))).toEqual([]);
|
|
83
|
+
};
|
|
61
84
|
/**
|
|
62
85
|
* Declares the tests, one `describe` per component and one test per story and variant.
|
|
63
86
|
*
|
|
@@ -72,39 +95,36 @@ export const storyBrowserTests = (options) => {
|
|
|
72
95
|
const tree = storyTree([indexedSource(options)]);
|
|
73
96
|
const groups = Map.groupBy(testedStoryLocations(tree), (location) => location.component.title);
|
|
74
97
|
for (const [title, locations] of groups) {
|
|
98
|
+
const planned = plannedStoryTests(locations.map((location) => location.story), variants, screenshot);
|
|
99
|
+
// a component whose stories are all about logic has nothing to picture
|
|
100
|
+
if (planned.length === 0)
|
|
101
|
+
continue;
|
|
75
102
|
test.describe(title, () => {
|
|
76
|
-
for (const { story } of
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
expect(messages(await spillProblems(page))).toEqual([]);
|
|
102
|
-
await check?.(page);
|
|
103
|
-
// last: it resizes the window, which may close what the story left open
|
|
104
|
-
expect(messages(await overlayProblems(page, isOverlayChecked(variant.view), story.height))).toEqual([]);
|
|
105
|
-
expect(errors).toEqual([]);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
103
|
+
for (const { story, variant, hasLookChecks } of planned) {
|
|
104
|
+
test(`${story.name} · ${variant.name}`, async ({ page }) => {
|
|
105
|
+
const errors = watchedErrors(page);
|
|
106
|
+
if (variant.width !== undefined)
|
|
107
|
+
await page.setViewportSize({ width: variant.width, height: 800 });
|
|
108
|
+
// a Live story is checked and pictured at its start: its clock held, so its image never changes;
|
|
109
|
+
// always on its page's own colour, whatever a variant names: a backdrop is for looking
|
|
110
|
+
const view = {
|
|
111
|
+
...defaults,
|
|
112
|
+
...variant.view,
|
|
113
|
+
switches: { ...defaults.switches, ...variant.view.switches },
|
|
114
|
+
backdrop: "plain"
|
|
115
|
+
};
|
|
116
|
+
await page.goto(heldClockAddress(frameAddress(frameUrl, story.id, view, switches)));
|
|
117
|
+
await expect(page.locator("html")).toHaveAttribute(STATUS_ATTRIBUTE, "ready");
|
|
118
|
+
if (screenshot) {
|
|
119
|
+
await expect(page).toHaveScreenshot(`${story.id.replace(":", "--")}--${variant.name}.png`, {
|
|
120
|
+
fullPage: true,
|
|
121
|
+
animations: "disabled"
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
await expectChecksPass(page, { story, variant, hasLookChecks }, catalogue.a11y, check);
|
|
126
|
+
expect(errors).toEqual([]);
|
|
127
|
+
});
|
|
108
128
|
}
|
|
109
129
|
});
|
|
110
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserTests.js","sourceRoot":"","sources":["../../src/browserTests.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"browserTests.js","sourceRoot":"","sources":["../../src/browserTests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,MAAM,EAAa,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAA0C,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAmB,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,sBAAsB,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAA0B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAyB,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAe9E,oHAAoH;AACpH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAA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,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;oBACvF,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gBAC7B,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkStories.d.ts","sourceRoot":"","sources":["../../src/checkStories.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAGlB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"checkStories.d.ts","sourceRoot":"","sources":["../../src/checkStories.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAGlB,MAAM,uBAAuB,CAAC;AA6C/B;;;;;GAKG;AACH,eAAO,MAAM,YAAY,YAAmB,iBAAiB,KAAG,OAAO,CAAC,gBAAgB,CAIvF,CAAC"}
|
package/dist/src/checkStories.js
CHANGED
|
@@ -2,6 +2,7 @@ import { catalogueSettings } from "forgebook/catalogue";
|
|
|
2
2
|
import { isOverlayChecked } from "./overlays.js";
|
|
3
3
|
import { axeProblems, errorProblems, overlayProblems, spillProblems, watchedErrors } from "./storyCheck.js";
|
|
4
4
|
import { eachStoryPage, openedStory, READY_MS } from "./storyPages.js";
|
|
5
|
+
import { hasLookChecks } from "./storyTestPlan.js";
|
|
5
6
|
/**
|
|
6
7
|
* One story in one view, checked.
|
|
7
8
|
*
|
|
@@ -25,13 +26,15 @@ const checkedPage = async (page, storyPage, a11y) => {
|
|
|
25
26
|
]);
|
|
26
27
|
if (status === "error")
|
|
27
28
|
return result([{ kind: "frame", message: "The story could not be shown" }, ...errorProblems(errors)]);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
// a story about logic gets the suite's checks of a scene, not those about looks (`storyTestPlan.ts`)
|
|
30
|
+
const lookProblems = hasLookChecks(storyPage.story)
|
|
31
|
+
? [
|
|
32
|
+
...(await spillProblems(page)),
|
|
33
|
+
// last of the page's checks: it resizes the window, which may close what the story left open
|
|
34
|
+
...(await overlayProblems(page, isOverlayChecked(storyPage.view), storyPage.story.height))
|
|
35
|
+
]
|
|
36
|
+
: [];
|
|
37
|
+
return result([...(await axeProblems(page, a11y)), ...lookProblems, ...errorProblems(errors)]);
|
|
35
38
|
};
|
|
36
39
|
/**
|
|
37
40
|
* Checks the stories a request names, in its views, on one browser.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkStories.js","sourceRoot":"","sources":["../../src/checkStories.ts"],"names":[],"mappings":"AAYA,OAAO,EAAqB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQ3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAkB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"checkStories.js","sourceRoot":"","sources":["../../src/checkStories.ts"],"names":[],"mappings":"AAYA,OAAO,EAAqB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQ3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAkB,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEn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,YAAY,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACjG,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,OAA0B,EAA6B,EAAE;IAC1F,MAAM,EAAE,IAAI,EAAE,GAAG,iBAAiB,CAAC,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACxE,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IACtG,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;AAChC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storyPages.d.ts","sourceRoot":"","sources":["../../src/storyPages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAY,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EAAwC,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"storyPages.d.ts","sourceRoot":"","sources":["../../src/storyPages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAY,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EAAwC,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAQ5F,2DAA2D;AAC3D,eAAO,MAAM,QAAQ,QAAS,CAAC;AAE/B,mDAAmD;AACnD,MAAM,MAAM,SAAS,GAAG;IACtB,iBAAiB;IACjB,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,wDAAwD;IACxD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,wEAAwE;AACxE,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAyBvD;;;;GAIG;AACH,eAAO,MAAM,YAAY,YAAa,iBAAiB,KAAG,SAAS,EAmBlE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,SAAgB,IAAI,aAAa,SAAS,KAAG,OAAO,CAAC,WAAW,CAavF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAU,OAAO,WAChC,iBAAiB,SACnB,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,KAC5D,OAAO,CAAC,OAAO,EAAE,CAgBnB,CAAC"}
|
package/dist/src/storyPages.js
CHANGED
|
@@ -16,6 +16,7 @@ import { STATUS_ATTRIBUTE } from "forgebook/frame-status";
|
|
|
16
16
|
import { heldClockAddress } from "forgebook/story-clock";
|
|
17
17
|
import { defaultView, frameAddress, parseView } from "forgebook/view-state";
|
|
18
18
|
import { storyVariants } from "./browserTests.js";
|
|
19
|
+
import { LOGIC_VARIANT } from "./storyTestPlan.js";
|
|
19
20
|
/** The window's size when a view sets no width, in CSS px: the browser tests' own. */
|
|
20
21
|
const WINDOW = { width: 1280, height: 800 };
|
|
21
22
|
/** How long a frame may take to say it is ready, in ms. */
|
|
@@ -47,7 +48,12 @@ const viewsOf = (request) => {
|
|
|
47
48
|
*/
|
|
48
49
|
export const storyPagesOf = (request) => {
|
|
49
50
|
const views = viewsOf(request);
|
|
50
|
-
|
|
51
|
+
const catalogue = catalogueSettings("", request.switches, request.lists);
|
|
52
|
+
// a story about logic has one look worth checking: every variant is its default view (`storyTestPlan.ts`)
|
|
53
|
+
const logicViews = request.isAllVariants
|
|
54
|
+
? [{ name: LOGIC_VARIANT.name, view: defaultView(catalogue), width: undefined }]
|
|
55
|
+
: views;
|
|
56
|
+
return request.stories.flatMap((story) => (story.isLogic === true ? logicViews : views).map(({ name, view, width }) => {
|
|
51
57
|
const shown = { ...view, backdrop: "plain" };
|
|
52
58
|
return {
|
|
53
59
|
story,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storyPages.js","sourceRoot":"","sources":["../../src/storyPages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,QAAQ,EAAa,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAkB,MAAM,sBAAsB,CAAC;AAE5F,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"storyPages.js","sourceRoot":"","sources":["../../src/storyPages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,QAAQ,EAAa,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAkB,MAAM,sBAAsB,C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AO,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;YAChE,CAAC;oBAAS,CAAC;gBACT,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;YACxB,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;YAAS,CAAC;QACT,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tests the browser suite declares for each story: a story about its looks in every variant, with the layout
|
|
3
|
+
* checks; a story about logic (`parameters.logic`) once, in the catalogue's default view, without them, and never
|
|
4
|
+
* pictured.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* A logic story is a hook's or a function's scene: the variants (themes, contrast, the structure only, a narrow frame)
|
|
8
|
+
* change how it looks, which is not what it is there for. Its one test still waits for the frame to be ready, so its
|
|
9
|
+
* play has to pass, checks the console and the page for errors, and runs axe, since its scene is a page a person uses.
|
|
10
|
+
* The checks about looks are left out: the spills and the overlays (layout at the variants' widths) and the source's
|
|
11
|
+
* own check (a rule of its components, which a hook's scene borrows only to be usable). `forgebook check` follows the
|
|
12
|
+
* same rule (`hasLookChecks`). Pure, so the suite's shape is tested without a browser.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import type { TreeStory } from "forgebook/story-tree";
|
|
17
|
+
import type { StoryVariant } from "./browserTests.ts";
|
|
18
|
+
/** The one variant a logic story is tested in: the catalogue's default view. */
|
|
19
|
+
export declare const LOGIC_VARIANT: StoryVariant;
|
|
20
|
+
/** One test the suite declares. */
|
|
21
|
+
export type PlannedStoryTest = {
|
|
22
|
+
/** The story. */
|
|
23
|
+
readonly story: TreeStory;
|
|
24
|
+
/** The variant it is drawn in. */
|
|
25
|
+
readonly variant: StoryVariant;
|
|
26
|
+
/** Whether the checks about looks run (spills, overlays, the source's own check): only for a story about its looks. */
|
|
27
|
+
readonly hasLookChecks: boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Whether a story gets the checks about looks: every story but one about logic.
|
|
31
|
+
*
|
|
32
|
+
* @param story - the story, as the tree or a check request gives it.
|
|
33
|
+
*/
|
|
34
|
+
export declare const hasLookChecks: (story: {
|
|
35
|
+
readonly isLogic?: boolean;
|
|
36
|
+
}) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The tests of some stories, in their order, each story's variants in theirs.
|
|
39
|
+
*
|
|
40
|
+
* @param stories - the stories.
|
|
41
|
+
* @param variants - the variants a story about its looks is tested in.
|
|
42
|
+
* @param isScreenshot - whether the run compares reference images instead of running the checks.
|
|
43
|
+
*/
|
|
44
|
+
export declare const plannedStoryTests: (stories: readonly TreeStory[], variants: readonly StoryVariant[], isScreenshot: boolean) => PlannedStoryTest[];
|
|
45
|
+
//# sourceMappingURL=storyTestPlan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storyTestPlan.d.ts","sourceRoot":"","sources":["../../src/storyTestPlan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,gFAAgF;AAChF,eAAO,MAAM,aAAa,EAAE,YAA0C,CAAC;AAEvE,mCAAmC;AACnC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iBAAiB;IACjB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,kCAAkC;IAClC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,uHAAuH;IACvH,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,UAAW;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,KAAG,OAAiC,CAAC;AAExG;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,YACnB,SAAS,SAAS,EAAE,YACnB,SAAS,YAAY,EAAE,gBACnB,OAAO,KACpB,gBAAgB,EAIf,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** The one variant a logic story is tested in: the catalogue's default view. */
|
|
2
|
+
export const LOGIC_VARIANT = { name: "logic", view: {} };
|
|
3
|
+
/**
|
|
4
|
+
* Whether a story gets the checks about looks: every story but one about logic.
|
|
5
|
+
*
|
|
6
|
+
* @param story - the story, as the tree or a check request gives it.
|
|
7
|
+
*/
|
|
8
|
+
export const hasLookChecks = (story) => story.isLogic !== true;
|
|
9
|
+
/**
|
|
10
|
+
* The tests of some stories, in their order, each story's variants in theirs.
|
|
11
|
+
*
|
|
12
|
+
* @param stories - the stories.
|
|
13
|
+
* @param variants - the variants a story about its looks is tested in.
|
|
14
|
+
* @param isScreenshot - whether the run compares reference images instead of running the checks.
|
|
15
|
+
*/
|
|
16
|
+
export const plannedStoryTests = (stories, variants, isScreenshot) => stories.flatMap((story) => {
|
|
17
|
+
if (hasLookChecks(story))
|
|
18
|
+
return variants.map((variant) => ({ story, variant, hasLookChecks: true }));
|
|
19
|
+
return isScreenshot ? [] : [{ story, variant: LOGIC_VARIANT, hasLookChecks: false }];
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=storyTestPlan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storyTestPlan.js","sourceRoot":"","sources":["../../src/storyTestPlan.ts"],"names":[],"mappings":"AAmBA,gFAAgF;AAChF,MAAM,CAAC,MAAM,aAAa,GAAiB,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AAYvE;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAqC,EAAW,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC;AAExG;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,OAA6B,EAC7B,QAAiC,EACjC,YAAqB,EACD,EAAE,CACtB,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAsB,EAAE;IAC5C,IAAI,aAAa,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACtG,OAAO,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;AACvF,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgebook/testing",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Tests from a package's stories: each story and variant in the browser with axe, spills and overlays, screenshots, and each story rendered on the server.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -68,13 +68,13 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@axe-core/playwright": "4.14.0",
|
|
70
70
|
"@ensiria/cli-kit": "^0.1.1",
|
|
71
|
-
"@forgebook/story-format": "0.1.
|
|
71
|
+
"@forgebook/story-format": "0.1.5"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@playwright/test": "^1.64.0",
|
|
75
75
|
"vite": "^8.0.0",
|
|
76
76
|
"vitest": "^5.0.0",
|
|
77
|
-
"forgebook": "^0.1.
|
|
77
|
+
"forgebook": "^0.1.8"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@playwright/test": "1.64.1",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"react": "19.3.0",
|
|
84
84
|
"vite": "8.3.5",
|
|
85
85
|
"vitest": "5.0.5",
|
|
86
|
-
"@forgebook/typescript-config": "0.0.0",
|
|
87
86
|
"@forgebook/tools": "0.0.0",
|
|
88
|
-
"forgebook": "0.
|
|
87
|
+
"@forgebook/typescript-config": "0.0.0",
|
|
88
|
+
"forgebook": "0.1.8"
|
|
89
89
|
},
|
|
90
90
|
"publishConfig": {
|
|
91
91
|
"access": "public"
|