@visual-check/storybook 0.1.2 → 0.2.1
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/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/open-requests/open-requests.d.ts +71 -0
- package/dist/open-requests/open-requests.d.ts.map +1 -0
- package/dist/open-requests/open-requests.js +131 -0
- package/dist/open-requests/open-requests.js.map +1 -0
- package/dist/per-story-options/define-visual-check.d.ts +72 -6
- package/dist/per-story-options/define-visual-check.d.ts.map +1 -1
- package/dist/per-story-options/define-visual-check.js +8 -1
- package/dist/per-story-options/define-visual-check.js.map +1 -1
- package/package.json +15 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { type CombinationsInput, combinations } from './dom-port/combinations.js
|
|
|
2
2
|
import { forceStates } from './forced-state/force-states.js';
|
|
3
3
|
import type { ForcedState } from './forced-state/forced-states.js';
|
|
4
4
|
import { type GridCaption, type GridCell, type GridHeader, type GridInput, type GridLayout, type GridRow, type GridStyle, gridAttribute, gridLayoutOf, type PropValues } from './grid-story/grid-layout.js';
|
|
5
|
+
import { type WaitForRequestsOptions, waitForRequests, watchRequests } from './open-requests/open-requests.js';
|
|
5
6
|
import { defineVisualCheck, type GlobalValue, type Mask, type ModeDefinition, type Tolerance, type Viewport, type VisualCheck, type VisualCheckDeclaration, type VisualCheckOptions, type VisualCheckParameter, type WaitHook, type WrittenMask } from './per-story-options/define-visual-check.js';
|
|
6
|
-
export type { CombinationsInput, ForcedState, GlobalValue, GridCaption, GridCell, GridHeader, GridInput, GridLayout, GridRow, GridStyle, Mask, ModeDefinition, PropValues, Tolerance, Viewport, VisualCheck, VisualCheckDeclaration, VisualCheckOptions, VisualCheckParameter, WaitHook, WrittenMask, };
|
|
7
|
-
export { combinations, defineVisualCheck, forceStates, gridAttribute, gridLayoutOf };
|
|
7
|
+
export type { CombinationsInput, ForcedState, GlobalValue, GridCaption, GridCell, GridHeader, GridInput, GridLayout, GridRow, GridStyle, Mask, ModeDefinition, PropValues, Tolerance, Viewport, VisualCheck, VisualCheckDeclaration, VisualCheckOptions, VisualCheckParameter, WaitForRequestsOptions, WaitHook, WrittenMask, };
|
|
8
|
+
export { combinations, defineVisualCheck, forceStates, gridAttribute, gridLayoutOf, waitForRequests, watchRequests };
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,aAAa,EACb,YAAY,EACZ,KAAK,UAAU,EAChB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACb,KAAK,WAAW,EACjB,MAAM,4CAA4C,CAAA;AAEnD,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,WAAW,EACX,QAAQ,EACR,UAAU,EACV,SAAS,EACT,UAAU,EACV,OAAO,EACP,SAAS,EACT,IAAI,EACJ,cAAc,EACd,UAAU,EACV,SAAS,EACT,QAAQ,EACR,WAAW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,GACZ,CAAA;AACD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { combinations } from './dom-port/combinations.js';
|
|
2
2
|
import { forceStates } from './forced-state/force-states.js';
|
|
3
3
|
import { gridAttribute, gridLayoutOf, } from './grid-story/grid-layout.js';
|
|
4
|
+
import { waitForRequests, watchRequests } from './open-requests/open-requests.js';
|
|
4
5
|
import { defineVisualCheck, } from './per-story-options/define-visual-check.js';
|
|
5
|
-
export { combinations, defineVisualCheck, forceStates, gridAttribute, gridLayoutOf };
|
|
6
|
+
export { combinations, defineVisualCheck, forceStates, gridAttribute, gridLayoutOf, waitForRequests, watchRequests };
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAE5D,OAAO,EAQL,aAAa,EACb,YAAY,GAEb,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,iBAAiB,GAYlB,MAAM,4CAA4C,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAE5D,OAAO,EAQL,aAAa,EACb,YAAY,GAEb,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAA+B,eAAe,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAC9G,OAAO,EACL,iBAAiB,GAYlB,MAAM,4CAA4C,CAAA;AA0BnD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What counting open requests reaches in a page: the `fetch` it wraps and the `XMLHttpRequest` whose `send` it hooks.
|
|
3
|
+
* Either may be missing, and is then skipped.
|
|
4
|
+
*/
|
|
5
|
+
export interface RequestGlobals {
|
|
6
|
+
/**
|
|
7
|
+
* The page's `fetch`, replaced by one that counts each call until its promise settles.
|
|
8
|
+
*/
|
|
9
|
+
fetch?: typeof fetch | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Whose `send` is hooked to count each request until its `loadend`.
|
|
12
|
+
*/
|
|
13
|
+
XMLHttpRequest?: typeof XMLHttpRequest | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A page's open `fetch` and XHR calls, counted from when the counter was made.
|
|
17
|
+
*/
|
|
18
|
+
export interface RequestCounter {
|
|
19
|
+
/**
|
|
20
|
+
* How many are open now.
|
|
21
|
+
*/
|
|
22
|
+
readonly open: number;
|
|
23
|
+
/**
|
|
24
|
+
* Calls the listener on every change of the count, until the returned function is called.
|
|
25
|
+
*/
|
|
26
|
+
subscribe(listener: () => void): () => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* How `waitForRequests` waits.
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export interface WaitForRequestsOptions {
|
|
34
|
+
/**
|
|
35
|
+
* How long no request must be open, in milliseconds, before it resolves. 500 by default.
|
|
36
|
+
*/
|
|
37
|
+
quietMs?: number | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* The longest it waits, in milliseconds, since a mock that never answers never goes quiet. 5000 by default. Reaching
|
|
40
|
+
* it isn't an error.
|
|
41
|
+
*/
|
|
42
|
+
maxMs?: number | undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Starts counting the page's open `fetch` and XHR calls, for `waitForRequests`. Call it once in `preview`, as it loads,
|
|
46
|
+
* so requests a story starts on its first render count too: a `wait` hook alone can't see requests already open when
|
|
47
|
+
* it starts. Calling it again does nothing. The page's calls behave as before, with the same arguments, results and
|
|
48
|
+
* errors.
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export declare function watchRequests(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Resolves once no `fetch` or XHR call has been open for `quietMs`, or at `maxMs`, whichever comes first. Await it in a
|
|
55
|
+
* `wait` hook, such as `wait: () => waitForRequests()`, so a story that loads its data through mocked requests after it
|
|
56
|
+
* renders is captured with that data. Reaching `maxMs` isn't an error, since a mock that never answers never goes
|
|
57
|
+
* quiet. Only requests started after `watchRequests` count.
|
|
58
|
+
*
|
|
59
|
+
* @throws When `watchRequests` wasn't called first.
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
export declare function waitForRequests(options?: WaitForRequestsOptions): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* A counter of the page's open requests. Making it hooks the page's `fetch` and `XMLHttpRequest`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function requestCounterOf(page: RequestGlobals): RequestCounter;
|
|
67
|
+
/**
|
|
68
|
+
* Resolves once the counter has had no open request for `quietMs`, or at `maxMs`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function quietRequests(counter: RequestCounter, { quietMs, maxMs }: WaitForRequestsOptions): Promise<void>;
|
|
71
|
+
//# sourceMappingURL=open-requests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-requests.d.ts","sourceRoot":"","sources":["../../src/open-requests/open-requests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,GAAG,SAAS,CAAA;IAChC;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,cAAc,GAAG,SAAS,CAAA;CACnD;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAA;CAC5C;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC3B;AAYD;;;;;;;GAOG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAMzF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,cAAc,CAsCrE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,cAAc,EACvB,EAAE,OAAa,EAAE,KAAa,EAAE,EAAE,sBAAsB,GACvD,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The counter of this realm's page, made by the first `watchRequests`.
|
|
3
|
+
*/
|
|
4
|
+
let realmCounter;
|
|
5
|
+
/**
|
|
6
|
+
* Starts counting the page's open `fetch` and XHR calls, for `waitForRequests`. Call it once in `preview`, as it loads,
|
|
7
|
+
* so requests a story starts on its first render count too: a `wait` hook alone can't see requests already open when
|
|
8
|
+
* it starts. Calling it again does nothing. The page's calls behave as before, with the same arguments, results and
|
|
9
|
+
* errors.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export function watchRequests() {
|
|
14
|
+
realmCounter ??= requestCounterOf(globalThis);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolves once no `fetch` or XHR call has been open for `quietMs`, or at `maxMs`, whichever comes first. Await it in a
|
|
18
|
+
* `wait` hook, such as `wait: () => waitForRequests()`, so a story that loads its data through mocked requests after it
|
|
19
|
+
* renders is captured with that data. Reaching `maxMs` isn't an error, since a mock that never answers never goes
|
|
20
|
+
* quiet. Only requests started after `watchRequests` count.
|
|
21
|
+
*
|
|
22
|
+
* @throws When `watchRequests` wasn't called first.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export async function waitForRequests(options = {}) {
|
|
26
|
+
if (realmCounter === undefined) {
|
|
27
|
+
throw new Error('visual-check: waitForRequests needs watchRequests() called in the preview, as it loads.');
|
|
28
|
+
}
|
|
29
|
+
await quietRequests(realmCounter, options);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A counter of the page's open requests. Making it hooks the page's `fetch` and `XMLHttpRequest`.
|
|
33
|
+
*/
|
|
34
|
+
export function requestCounterOf(page) {
|
|
35
|
+
const listeners = new Set();
|
|
36
|
+
let open = 0;
|
|
37
|
+
const change = (by) => {
|
|
38
|
+
open += by;
|
|
39
|
+
for (const listener of listeners) {
|
|
40
|
+
listener();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const start = () => {
|
|
44
|
+
let ended = false;
|
|
45
|
+
change(1);
|
|
46
|
+
return () => {
|
|
47
|
+
if (!ended) {
|
|
48
|
+
ended = true;
|
|
49
|
+
change(-1);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
hookFetch(page, start);
|
|
54
|
+
hookXhr(page, start);
|
|
55
|
+
return {
|
|
56
|
+
get open() {
|
|
57
|
+
return open;
|
|
58
|
+
},
|
|
59
|
+
subscribe(listener) {
|
|
60
|
+
listeners.add(listener);
|
|
61
|
+
return () => listeners.delete(listener);
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Resolves once the counter has had no open request for `quietMs`, or at `maxMs`.
|
|
67
|
+
*/
|
|
68
|
+
export function quietRequests(counter, { quietMs = 500, maxMs = 5_000 }) {
|
|
69
|
+
return new Promise((resolve) => {
|
|
70
|
+
let quietTimer;
|
|
71
|
+
const finish = () => {
|
|
72
|
+
clearTimeout(quietTimer);
|
|
73
|
+
clearTimeout(maxTimer);
|
|
74
|
+
unsubscribe();
|
|
75
|
+
resolve();
|
|
76
|
+
};
|
|
77
|
+
const restart = () => {
|
|
78
|
+
clearTimeout(quietTimer);
|
|
79
|
+
quietTimer = counter.open === 0 ? setTimeout(finish, quietMs) : undefined;
|
|
80
|
+
};
|
|
81
|
+
const maxTimer = setTimeout(finish, maxMs);
|
|
82
|
+
const unsubscribe = counter.subscribe(restart);
|
|
83
|
+
restart();
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Replaces the page's `fetch` with one that counts each call until its promise settles, and passes `this`, the
|
|
88
|
+
* arguments, the response and any error through.
|
|
89
|
+
*/
|
|
90
|
+
function hookFetch(page, start) {
|
|
91
|
+
const previous = page.fetch;
|
|
92
|
+
if (typeof previous !== 'function') {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
page.fetch = function counted(...args) {
|
|
96
|
+
const end = start();
|
|
97
|
+
let response;
|
|
98
|
+
try {
|
|
99
|
+
response = previous.apply(this, args);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
end();
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
return Promise.resolve(response).finally(end);
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Wraps `XMLHttpRequest.prototype.send` so each request counts until its `loadend`, and passes `this`, the arguments
|
|
110
|
+
* and any error through.
|
|
111
|
+
*/
|
|
112
|
+
function hookXhr(page, start) {
|
|
113
|
+
const prototype = page.XMLHttpRequest?.prototype;
|
|
114
|
+
const previous = prototype?.send;
|
|
115
|
+
if (prototype === undefined || typeof previous !== 'function') {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
prototype.send = function counted(...args) {
|
|
119
|
+
const end = start();
|
|
120
|
+
this.addEventListener('loadend', end, { once: true });
|
|
121
|
+
try {
|
|
122
|
+
previous.apply(this, args);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
this.removeEventListener('loadend', end);
|
|
126
|
+
end();
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=open-requests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-requests.js","sourceRoot":"","sources":["../../src/open-requests/open-requests.ts"],"names":[],"mappings":"AAmDA;;GAEG;AACH,IAAI,YAAwC,CAAA;AAE5C;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa;IAC3B,YAAY,KAAK,gBAAgB,CAAC,UAAU,CAAC,CAAA;AAC/C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAO,GAA2B,EAAE;IACxE,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,yFAAyF,CAAC,CAAA;IAC5G,CAAC;IAED,MAAM,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAoB;IACnD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;IACvC,IAAI,IAAI,GAAG,CAAC,CAAA;IAEZ,MAAM,MAAM,GAAG,CAAC,EAAU,EAAQ,EAAE;QAClC,IAAI,IAAI,EAAE,CAAA;QAEV,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,QAAQ,EAAE,CAAA;QACZ,CAAC;IACH,CAAC,CAAA;IAED,MAAM,KAAK,GAAiB,GAAG,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QAErD,IAAI,CAAC;YACH,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;YACxC,GAAG,EAAE,CAAA;YACL,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -134,7 +134,13 @@ export interface VisualCheckOptions<ModeName extends string> {
|
|
|
134
134
|
*/
|
|
135
135
|
modes?: readonly ModeName[] | undefined;
|
|
136
136
|
/**
|
|
137
|
-
*
|
|
137
|
+
* Whether to take the default capture, the story with no mode. `false` captures the listed modes only, for a story
|
|
138
|
+
* that exists to show them. Their viewport still merges over `viewport`, and their baselines keep their names.
|
|
139
|
+
* Defaults to `true`. With `false`, list at least one mode, or set `disable: true`.
|
|
140
|
+
*/
|
|
141
|
+
defaultCapture?: boolean | undefined;
|
|
142
|
+
/**
|
|
143
|
+
* The default capture's viewport, which each mode's viewport merges over. Deep-merges over the inherited one.
|
|
138
144
|
*/
|
|
139
145
|
viewport?: Viewport | undefined;
|
|
140
146
|
/**
|
|
@@ -147,6 +153,12 @@ export interface VisualCheckOptions<ModeName extends string> {
|
|
|
147
153
|
* `true`. An element's capture never grows it.
|
|
148
154
|
*/
|
|
149
155
|
growViewport?: boolean | undefined;
|
|
156
|
+
/**
|
|
157
|
+
* Whether the capture may cut content the page shows: wider than the viewport for the full page, or spilling past
|
|
158
|
+
* the `element` box. Defaults to `false`, which makes such a story broken, `overflows`. Set it only when the cut is
|
|
159
|
+
* intended.
|
|
160
|
+
*/
|
|
161
|
+
allowOverflow?: boolean | undefined;
|
|
150
162
|
/**
|
|
151
163
|
* The regions to paint over, by name. A name set to `null` drops the inherited mask. `null` drops them all.
|
|
152
164
|
*/
|
|
@@ -159,6 +171,31 @@ export interface VisualCheckOptions<ModeName extends string> {
|
|
|
159
171
|
* Whether to leave the stories out. `false` on a story brings it back from a disabled file.
|
|
160
172
|
*/
|
|
161
173
|
disable?: boolean | undefined;
|
|
174
|
+
/**
|
|
175
|
+
* What a page error that isn't expected does to these stories' snapshots, in place of the config's: `'fail'` lists
|
|
176
|
+
* it and fails `test`, `'warn'` lists it without failing, and `'off'` doesn't check page errors.
|
|
177
|
+
*/
|
|
178
|
+
pageErrors?: 'fail' | 'warn' | 'off' | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* The page errors these stories raise on purpose, such as a mocked error response. A string matches a page error
|
|
181
|
+
* whose text contains it, and a regular expression one whose text it matches. The text is the message, or the URL
|
|
182
|
+
* for a load. An error's message is its stack, whose first line is `Name: message`, so a regular expression anchored
|
|
183
|
+
* at the message's end with `$` doesn't match it. The list replaces the inherited one, and the config's list is always added to it. An entry that
|
|
184
|
+
* matches none of a snapshot's page errors is a warning.
|
|
185
|
+
*/
|
|
186
|
+
expectedPageErrors?: readonly (string | RegExp)[] | undefined;
|
|
187
|
+
/**
|
|
188
|
+
* What a real network request to a host the config's `silenceHosts` doesn't match does to these stories' snapshots in
|
|
189
|
+
* `test`, in place of the config's: `'fail'` lists it and fails `test`, `'warn'` lists it without failing, and
|
|
190
|
+
* `'off'` doesn't watch their requests. A story that reaches a host on purpose sets `'warn'` or `'off'`.
|
|
191
|
+
*/
|
|
192
|
+
realRequests?: 'fail' | 'warn' | 'off' | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* The limit, in ms, for everything up to these stories' capture: loading, `play`, the `wait` hook and the waits for
|
|
195
|
+
* images, fonts and the end state. It replaces the config's `readyTimeout` for these stories, such as a story whose
|
|
196
|
+
* hook waits on slow data. A whole number from 1 to 2147483647.
|
|
197
|
+
*/
|
|
198
|
+
readyTimeout?: number | undefined;
|
|
162
199
|
/**
|
|
163
200
|
* A hook to wait for before the capture. `null` turns an inherited hook off.
|
|
164
201
|
*/
|
|
@@ -166,16 +203,22 @@ export interface VisualCheckOptions<ModeName extends string> {
|
|
|
166
203
|
}
|
|
167
204
|
/**
|
|
168
205
|
* What the helper writes into `parameters.visualCheck`. The same keys as the options, except two. `modes` lists every
|
|
169
|
-
* declared mode: its definition when the level names it, `null` when it doesn't.
|
|
170
|
-
*
|
|
206
|
+
* declared mode: its definition when the level names it, `null` when it doesn't. A name the level lists that the
|
|
207
|
+
* declaration lacks is written as `'undeclared'`, so visual-check rejects it. Each mask is written with both keys, the
|
|
208
|
+
* unused one `null` (see `WrittenMask`).
|
|
171
209
|
*
|
|
172
210
|
* @public
|
|
173
211
|
*/
|
|
174
212
|
export interface VisualCheckParameter {
|
|
175
213
|
/**
|
|
176
|
-
* One entry per declared mode, in the declaration's key order
|
|
214
|
+
* One entry per declared mode, in the declaration's key order, then `'undeclared'` for each listed name the
|
|
215
|
+
* declaration lacks.
|
|
177
216
|
*/
|
|
178
|
-
modes?: Record<string, ModeDefinition | null>;
|
|
217
|
+
modes?: Record<string, ModeDefinition | null | 'undeclared'>;
|
|
218
|
+
/**
|
|
219
|
+
* Whether to take the default capture.
|
|
220
|
+
*/
|
|
221
|
+
defaultCapture?: boolean;
|
|
179
222
|
/**
|
|
180
223
|
* The default capture's viewport.
|
|
181
224
|
*/
|
|
@@ -188,6 +231,10 @@ export interface VisualCheckParameter {
|
|
|
188
231
|
* Whether a full-page capture first grows the viewport's height to the page's.
|
|
189
232
|
*/
|
|
190
233
|
growViewport?: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Whether the capture may cut content the page shows.
|
|
236
|
+
*/
|
|
237
|
+
allowOverflow?: boolean;
|
|
191
238
|
/**
|
|
192
239
|
* The regions to paint over, by name, or `null` for none.
|
|
193
240
|
*/
|
|
@@ -200,6 +247,22 @@ export interface VisualCheckParameter {
|
|
|
200
247
|
* Whether to leave the stories out.
|
|
201
248
|
*/
|
|
202
249
|
disable?: boolean;
|
|
250
|
+
/**
|
|
251
|
+
* What a page error that isn't expected does to the snapshots.
|
|
252
|
+
*/
|
|
253
|
+
pageErrors?: 'fail' | 'warn' | 'off';
|
|
254
|
+
/**
|
|
255
|
+
* The page errors the stories raise on purpose, besides the config's.
|
|
256
|
+
*/
|
|
257
|
+
expectedPageErrors?: readonly (string | RegExp)[];
|
|
258
|
+
/**
|
|
259
|
+
* What a real network request does to the snapshots in `test`.
|
|
260
|
+
*/
|
|
261
|
+
realRequests?: 'fail' | 'warn' | 'off';
|
|
262
|
+
/**
|
|
263
|
+
* The limit, in ms, for everything up to the capture, in place of the config's `readyTimeout`.
|
|
264
|
+
*/
|
|
265
|
+
readyTimeout?: number;
|
|
203
266
|
/**
|
|
204
267
|
* A hook to wait for before the capture, or `null` for none.
|
|
205
268
|
*/
|
|
@@ -227,7 +290,10 @@ export type VisualCheck<ModeName extends string> = (options: VisualCheckOptions<
|
|
|
227
290
|
* - `modes`: the most specific list.
|
|
228
291
|
* - `viewport` and `tolerance`: merged key by key.
|
|
229
292
|
* - `masks`: merged by name. A name set to `null` drops one mask, and `masks: null` drops all of them.
|
|
230
|
-
* - `wait`, `element`, `growViewport`
|
|
293
|
+
* - `defaultCapture`, `wait`, `element`, `growViewport`, `allowOverflow`, `disable`, `pageErrors`, `realRequests` and
|
|
294
|
+
* `readyTimeout`: the most specific value.
|
|
295
|
+
* - `expectedPageErrors`: the most specific list, since Storybook replaces arrays: a story's list replaces its meta's or
|
|
296
|
+
* `preview`'s. The config's list is then added to it, so put the entries every story needs in the config.
|
|
231
297
|
*
|
|
232
298
|
* A key set to `undefined` is left out, so it never hides an inherited value. `null` is kept, and turns one off. The
|
|
233
299
|
* helper checks nothing at run time. visual-check validates the merged options before it captures.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-visual-check.d.ts","sourceRoot":"","sources":["../../src/per-story-options/define-visual-check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE5D;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAEnD;;;;G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AAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAA;IACtC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAA;CACvB;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,QAAQ,SAAS,MAAM,IAAI,CAAC,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK;IACrG,WAAW,EAAE,oBAAoB,CAAA;CAClC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,QAAQ,SAAS,MAAM,EAC7D,WAAW,EAAE,sBAAsB,CAAC,QAAQ,CAAC,GAC5C,WAAW,CAAC,QAAQ,CAAC,CAAA;AACxB;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,iBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,SAAS,MAAM,EAC7G,WAAW,EAAE,sBAAsB,CAAC,QAAQ,EAAE,OAAO,CAAC,KACnD,WAAW,CAAC,QAAQ,CAAC,CAAA"}
|
|
@@ -35,7 +35,9 @@ function declareModes(declaration) {
|
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Writes one entry per declared mode, in the key order of the declaration: the definition when the list names the mode,
|
|
38
|
-
* `null` when it doesn't.
|
|
38
|
+
* `null` when it doesn't. Then writes `'undeclared'` for each listed name the declaration lacks, in list order, so that
|
|
39
|
+
* a typo or a name only a `preview.js` or generated code holds reaches visual-check's validation instead of being
|
|
40
|
+
* dropped.
|
|
39
41
|
*/
|
|
40
42
|
function writeModes(declared, listed) {
|
|
41
43
|
const names = new Set(listed);
|
|
@@ -43,6 +45,11 @@ function writeModes(declared, listed) {
|
|
|
43
45
|
for (const [name, definition] of Object.entries(declared)) {
|
|
44
46
|
written[name] = names.has(name) ? definition : null;
|
|
45
47
|
}
|
|
48
|
+
for (const name of names) {
|
|
49
|
+
if (!Object.hasOwn(declared, name)) {
|
|
50
|
+
written[name] = 'undeclared';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
46
53
|
return written;
|
|
47
54
|
}
|
|
48
55
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-visual-check.js","sourceRoot":"","sources":["../../src/per-story-options/define-visual-check.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"define-visual-check.js","sourceRoot":"","sources":["../../src/per-story-options/define-visual-check.ts"],"names":[],"mappings":"AA+TA;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAA4C;IAC5E,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,OAAO,YAAY,CAAC,WAAW,CAAC,CAAA;AAClC,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,WAA2C;IAC/D;;OAEG;IACH,OAAO,SAAS,WAAW,CAAC,OAAO;QACjC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;QACzC,MAAM,SAAS,GAA4B,EAAE,CAAA;QAE7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAChD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;YACxB,CAAC;QACH,CAAC;QAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,SAAS,CAAC,KAAK,GAAG,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QACxD,CAAC;QAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,SAAS,CAAC,KAAK,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAA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}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visual-check/storybook",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -12,6 +12,20 @@
|
|
|
12
12
|
"dist",
|
|
13
13
|
"THIRD-PARTY-NOTICES.md"
|
|
14
14
|
],
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"typesVersions": {
|
|
17
|
+
"*": {
|
|
18
|
+
"react": [
|
|
19
|
+
"./dist/react.d.ts"
|
|
20
|
+
],
|
|
21
|
+
"vue": [
|
|
22
|
+
"./dist/vue.d.ts"
|
|
23
|
+
],
|
|
24
|
+
"angular": [
|
|
25
|
+
"./dist/angular.d.ts"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
15
29
|
"exports": {
|
|
16
30
|
".": {
|
|
17
31
|
"types": "./dist/index.d.ts",
|