@techsio/storybook-better-a11y 0.0.4 → 0.0.5
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.js +5 -6
- package/dist/manager.js +11 -1540
- package/dist/postinstall.js +1 -1
- package/dist/preview.js +68 -1
- package/package.json +1 -1
- package/dist/100.js +0 -122
- package/dist/212.js +0 -1965
- package/dist/212.js.LICENSE.txt +0 -19
- package/dist/699.js +0 -542
- package/dist/rslib-runtime.js +0 -37
package/dist/postinstall.js
CHANGED
package/dist/preview.js
CHANGED
|
@@ -1 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
import { expect } from "storybook/test";
|
|
2
|
+
import { run } from "./a11yRunner.js";
|
|
3
|
+
import { getIsVitestStandaloneRun } from "./utils.js";
|
|
4
|
+
import { withVisionSimulator } from "./withVisionSimulator.js";
|
|
5
|
+
let vitestMatchersExtended = false;
|
|
6
|
+
const decorators = [
|
|
7
|
+
withVisionSimulator
|
|
8
|
+
];
|
|
9
|
+
const afterEach = async ({ id: storyId, reporting, parameters, globals, viewMode })=>{
|
|
10
|
+
const a11yParameter = parameters.a11y;
|
|
11
|
+
const a11yGlobals = globals.a11y;
|
|
12
|
+
const shouldRunEnvironmentIndependent = a11yParameter?.disable !== true && a11yParameter?.test !== 'off' && a11yGlobals?.manual !== true;
|
|
13
|
+
const getMode = ()=>{
|
|
14
|
+
switch(a11yParameter?.test){
|
|
15
|
+
case 'todo':
|
|
16
|
+
return 'warning';
|
|
17
|
+
case 'error':
|
|
18
|
+
default:
|
|
19
|
+
return 'failed';
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
if (shouldRunEnvironmentIndependent && 'story' === viewMode) try {
|
|
23
|
+
const result = await run(a11yParameter, storyId);
|
|
24
|
+
if (result) {
|
|
25
|
+
const hasViolations = (result?.violations.length ?? 0) > 0;
|
|
26
|
+
reporting.addReport({
|
|
27
|
+
type: 'a11y',
|
|
28
|
+
version: 1,
|
|
29
|
+
result,
|
|
30
|
+
status: hasViolations ? getMode() : 'passed'
|
|
31
|
+
});
|
|
32
|
+
if (getIsVitestStandaloneRun()) {
|
|
33
|
+
if (hasViolations && 'failed' === getMode()) {
|
|
34
|
+
if (!vitestMatchersExtended) {
|
|
35
|
+
const { toHaveNoViolations } = await import("vitest-axe/matchers");
|
|
36
|
+
expect.extend({
|
|
37
|
+
toHaveNoViolations
|
|
38
|
+
});
|
|
39
|
+
vitestMatchersExtended = true;
|
|
40
|
+
}
|
|
41
|
+
expect(result).toHaveNoViolations();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} catch (e) {
|
|
46
|
+
reporting.addReport({
|
|
47
|
+
type: 'a11y',
|
|
48
|
+
version: 1,
|
|
49
|
+
result: {
|
|
50
|
+
error: e
|
|
51
|
+
},
|
|
52
|
+
status: 'failed'
|
|
53
|
+
});
|
|
54
|
+
if (getIsVitestStandaloneRun()) throw e;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const initialGlobals = {
|
|
58
|
+
a11y: {
|
|
59
|
+
manual: false
|
|
60
|
+
},
|
|
61
|
+
vision: void 0
|
|
62
|
+
};
|
|
63
|
+
const preview_parameters = {
|
|
64
|
+
a11y: {
|
|
65
|
+
test: 'todo'
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export { afterEach, decorators, initialGlobals, preview_parameters as parameters };
|
package/package.json
CHANGED
package/dist/100.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
const ADDON_ID = 'storybook/a11y';
|
|
2
|
-
const PANEL_ID = `${ADDON_ID}/panel`;
|
|
3
|
-
"a11y";
|
|
4
|
-
"vision";
|
|
5
|
-
const RESULT = `${ADDON_ID}/result`;
|
|
6
|
-
const REQUEST = `${ADDON_ID}/request`;
|
|
7
|
-
const RUNNING = `${ADDON_ID}/running`;
|
|
8
|
-
const ERROR = `${ADDON_ID}/error`;
|
|
9
|
-
const MANUAL = `${ADDON_ID}/manual`;
|
|
10
|
-
const SELECT = `${ADDON_ID}/select`;
|
|
11
|
-
const DOCUMENTATION_LINK = 'writing-tests/accessibility-testing';
|
|
12
|
-
const DOCUMENTATION_DISCREPANCY_LINK = `${DOCUMENTATION_LINK}#why-are-my-tests-failing-in-different-environments`;
|
|
13
|
-
const EVENTS = {
|
|
14
|
-
RESULT: RESULT,
|
|
15
|
-
REQUEST: REQUEST,
|
|
16
|
-
RUNNING: RUNNING,
|
|
17
|
-
ERROR: ERROR,
|
|
18
|
-
MANUAL: MANUAL,
|
|
19
|
-
SELECT: SELECT
|
|
20
|
-
};
|
|
21
|
-
const STATUS_TYPE_ID_COMPONENT_TEST = 'storybook/component-test';
|
|
22
|
-
const STATUS_TYPE_ID_A11Y = 'storybook/a11y';
|
|
23
|
-
const filters = {
|
|
24
|
-
blurred: {
|
|
25
|
-
label: 'Blurred vision',
|
|
26
|
-
filter: 'blur(2px)',
|
|
27
|
-
percentage: 22.9
|
|
28
|
-
},
|
|
29
|
-
deuteranomaly: {
|
|
30
|
-
label: 'Deuteranomaly',
|
|
31
|
-
filter: 'url("#storybook-a11y-vision-deuteranomaly")',
|
|
32
|
-
percentage: 2.7
|
|
33
|
-
},
|
|
34
|
-
deuteranopia: {
|
|
35
|
-
label: 'Deuteranopia',
|
|
36
|
-
filter: 'url("#storybook-a11y-vision-deuteranopia")',
|
|
37
|
-
percentage: 0.56
|
|
38
|
-
},
|
|
39
|
-
protanomaly: {
|
|
40
|
-
label: 'Protanomaly',
|
|
41
|
-
filter: 'url("#storybook-a11y-vision-protanomaly")',
|
|
42
|
-
percentage: 0.66
|
|
43
|
-
},
|
|
44
|
-
protanopia: {
|
|
45
|
-
label: 'Protanopia',
|
|
46
|
-
filter: 'url("#storybook-a11y-vision-protanopia")',
|
|
47
|
-
percentage: 0.59
|
|
48
|
-
},
|
|
49
|
-
tritanomaly: {
|
|
50
|
-
label: 'Tritanomaly',
|
|
51
|
-
filter: 'url("#storybook-a11y-vision-tritanomaly")',
|
|
52
|
-
percentage: 0.01
|
|
53
|
-
},
|
|
54
|
-
tritanopia: {
|
|
55
|
-
label: 'Tritanopia',
|
|
56
|
-
filter: 'url("#storybook-a11y-vision-tritanopia")',
|
|
57
|
-
percentage: 0.016
|
|
58
|
-
},
|
|
59
|
-
achromatopsia: {
|
|
60
|
-
label: 'Achromatopsia',
|
|
61
|
-
filter: 'url("#storybook-a11y-vision-achromatopsia")',
|
|
62
|
-
percentage: 0.0001
|
|
63
|
-
},
|
|
64
|
-
grayscale: {
|
|
65
|
-
label: 'Grayscale',
|
|
66
|
-
filter: 'grayscale(100%)'
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const filterDefs = `<svg id="storybook-a11y-vision-filters" style="display: none !important;">
|
|
70
|
-
<defs>
|
|
71
|
-
<filter id="storybook-a11y-vision-protanopia">
|
|
72
|
-
<feColorMatrix
|
|
73
|
-
in="SourceGraphic"
|
|
74
|
-
type="matrix"
|
|
75
|
-
values="0.567, 0.433, 0, 0, 0 0.558, 0.442, 0, 0, 0 0, 0.242, 0.758, 0, 0 0, 0, 0, 1, 0"
|
|
76
|
-
/>
|
|
77
|
-
</filter>
|
|
78
|
-
<filter id="storybook-a11y-vision-protanomaly">
|
|
79
|
-
<feColorMatrix
|
|
80
|
-
in="SourceGraphic"
|
|
81
|
-
type="matrix"
|
|
82
|
-
values="0.817, 0.183, 0, 0, 0 0.333, 0.667, 0, 0, 0 0, 0.125, 0.875, 0, 0 0, 0, 0, 1, 0"
|
|
83
|
-
/>
|
|
84
|
-
</filter>
|
|
85
|
-
<filter id="storybook-a11y-vision-deuteranopia">
|
|
86
|
-
<feColorMatrix
|
|
87
|
-
in="SourceGraphic"
|
|
88
|
-
type="matrix"
|
|
89
|
-
values="0.625, 0.375, 0, 0, 0 0.7, 0.3, 0, 0, 0 0, 0.3, 0.7, 0, 0 0, 0, 0, 1, 0"
|
|
90
|
-
/>
|
|
91
|
-
</filter>
|
|
92
|
-
<filter id="storybook-a11y-vision-deuteranomaly">
|
|
93
|
-
<feColorMatrix
|
|
94
|
-
in="SourceGraphic"
|
|
95
|
-
type="matrix"
|
|
96
|
-
values="0.8, 0.2, 0, 0, 0 0.258, 0.742, 0, 0, 0 0, 0.142, 0.858, 0, 0 0, 0, 0, 1, 0"
|
|
97
|
-
/>
|
|
98
|
-
</filter>
|
|
99
|
-
<filter id="storybook-a11y-vision-tritanopia">
|
|
100
|
-
<feColorMatrix
|
|
101
|
-
in="SourceGraphic"
|
|
102
|
-
type="matrix"
|
|
103
|
-
values="0.95, 0.05, 0, 0, 0 0, 0.433, 0.567, 0, 0 0, 0.475, 0.525, 0, 0 0, 0, 0, 1, 0"
|
|
104
|
-
/>
|
|
105
|
-
</filter>
|
|
106
|
-
<filter id="storybook-a11y-vision-tritanomaly">
|
|
107
|
-
<feColorMatrix
|
|
108
|
-
in="SourceGraphic"
|
|
109
|
-
type="matrix"
|
|
110
|
-
values="0.967, 0.033, 0, 0, 0 0, 0.733, 0.267, 0, 0 0, 0.183, 0.817, 0, 0 0, 0, 0, 1, 0"
|
|
111
|
-
/>
|
|
112
|
-
</filter>
|
|
113
|
-
<filter id="storybook-a11y-vision-achromatopsia">
|
|
114
|
-
<feColorMatrix
|
|
115
|
-
in="SourceGraphic"
|
|
116
|
-
type="matrix"
|
|
117
|
-
values="0.299, 0.587, 0.114, 0, 0 0.299, 0.587, 0.114, 0, 0 0.299, 0.587, 0.114, 0, 0 0, 0, 0, 1, 0"
|
|
118
|
-
/>
|
|
119
|
-
</filter>
|
|
120
|
-
</defs>
|
|
121
|
-
</svg>`;
|
|
122
|
-
export { ADDON_ID, DOCUMENTATION_DISCREPANCY_LINK, EVENTS, PANEL_ID, STATUS_TYPE_ID_A11Y, STATUS_TYPE_ID_COMPONENT_TEST, filterDefs, filters };
|