@fragments-sdk/cli 0.5.2 → 0.7.0
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/bin.js +996 -79
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-ICAIQ57V.js → chunk-6JBGU74P.js} +5 -3
- package/dist/chunk-6JBGU74P.js.map +1 -0
- package/dist/chunk-7OPWMLOE.js +1625 -0
- package/dist/chunk-7OPWMLOE.js.map +1 -0
- package/dist/{chunk-2H2JAA3U.js → chunk-CVXKXVOY.js} +3 -3
- package/dist/{chunk-2H2JAA3U.js.map → chunk-CVXKXVOY.js.map} +1 -1
- package/dist/{chunk-IOJE35DZ.js → chunk-NWQ4CJOQ.js} +3 -3
- package/dist/{chunk-2DJH4F4P.js → chunk-RVRTRESS.js} +3 -3
- package/dist/{chunk-V7YLRR4C.js → chunk-TJ34N7C7.js} +41 -4
- package/dist/{chunk-V7YLRR4C.js.map → chunk-TJ34N7C7.js.map} +1 -1
- package/dist/{chunk-XNWDI6UT.js → chunk-XHUDJNN3.js} +5 -5
- package/dist/{core-DKHB7FYV.js → core-W2HYIQW6.js} +4 -4
- package/dist/{generate-KL24VZVD.js → generate-LMTISDIJ.js} +5 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -7
- package/dist/index.js.map +1 -1
- package/dist/{init-NION5S3M.js → init-7CHRKQ7P.js} +5 -5
- package/dist/mcp-bin.js +8 -220
- package/dist/mcp-bin.js.map +1 -1
- package/dist/scan-WY23TJCP.js +12 -0
- package/dist/{service-RWUMZ3EW.js → service-T2L7VLTE.js} +5 -5
- package/dist/static-viewer-GBR7YNF3.js +12 -0
- package/dist/{test-ECPEXFDN.js → test-OJRXNDO2.js} +4 -4
- package/dist/{tokens-ITADYVPF.js → tokens-3BWDESVM.js} +6 -6
- package/dist/viewer-SUFOISZM.js +1822 -0
- package/dist/viewer-SUFOISZM.js.map +1 -0
- package/package.json +6 -5
- package/src/bin.ts +31 -0
- package/src/build.ts +147 -13
- package/src/cli-commands.ts +18 -0
- package/src/commands/__tests__/a11y-scoring.test.ts +278 -0
- package/src/commands/a11y-report.ts +625 -0
- package/src/commands/a11y.ts +168 -14
- package/src/commands/build.ts +16 -0
- package/src/commands/graph.ts +274 -0
- package/src/core/auto-props.ts +464 -0
- package/src/core/composition.ts +64 -1
- package/src/core/graph-extractor.test.ts +542 -0
- package/src/core/graph-extractor.ts +601 -0
- package/src/core/importAnalyzer.ts +5 -0
- package/src/core/schema.ts +2 -0
- package/src/core/types.ts +3 -1
- package/src/index.ts +4 -0
- package/src/mcp/server.ts +13 -220
- package/src/theme/__tests__/component-contrast.test.ts +338 -0
- package/src/theme/__tests__/contrast-validation.test.ts +326 -0
- package/src/theme/contrast.test.ts +331 -0
- package/src/theme/contrast.ts +246 -0
- package/src/theme/generator.ts +213 -1
- package/src/theme/index.ts +16 -0
- package/src/theme/types.ts +51 -0
- package/src/viewer/__tests__/a11y-fixes.test.ts +358 -0
- package/src/viewer/__tests__/viewer-integration.test.ts +2 -7
- package/src/viewer/components/AccessibilityPanel.tsx +493 -433
- package/src/viewer/components/ActionCapture.tsx +1 -1
- package/src/viewer/components/ActionsPanel.tsx +142 -183
- package/src/viewer/components/App.tsx +276 -183
- package/src/viewer/components/BottomPanel.tsx +40 -80
- package/src/viewer/components/CodePanel.tsx +9 -87
- package/src/viewer/components/CommandPalette.tsx +117 -74
- package/src/viewer/components/ComponentGraph.tsx +143 -126
- package/src/viewer/components/ComponentHeader.tsx +46 -43
- package/src/viewer/components/ContractPanel.tsx +124 -117
- package/src/viewer/components/ErrorBoundary.tsx +47 -35
- package/src/viewer/components/FigmaEmbed.tsx +18 -13
- package/src/viewer/components/FragmentEditor.tsx +126 -63
- package/src/viewer/components/HealthDashboard.tsx +146 -171
- package/src/viewer/components/HmrStatusIndicator.tsx +31 -41
- package/src/viewer/components/Icons.tsx +151 -98
- package/src/viewer/components/InteractionsPanel.tsx +317 -264
- package/src/viewer/components/IsolatedPreviewFrame.tsx +52 -27
- package/src/viewer/components/IsolatedRender.tsx +12 -6
- package/src/viewer/components/KeyboardShortcutsHelp.tsx +34 -70
- package/src/viewer/components/LandingPage.tsx +285 -305
- package/src/viewer/components/Layout.tsx +12 -10
- package/src/viewer/components/LeftSidebar.tsx +103 -155
- package/src/viewer/components/MultiViewportPreview.tsx +254 -63
- package/src/viewer/components/PreviewArea.tsx +113 -44
- package/src/viewer/components/PreviewFrameHost.tsx +36 -6
- package/src/viewer/components/PreviewPane.tsx +2 -3
- package/src/viewer/components/PreviewToolbar.tsx +109 -105
- package/src/viewer/components/PropsEditor.tsx +154 -74
- package/src/viewer/components/PropsTable.tsx +95 -82
- package/src/viewer/components/RelationsSection.tsx +71 -40
- package/src/viewer/components/ResizablePanel.tsx +158 -55
- package/src/viewer/components/RightSidebar.tsx +46 -56
- package/src/viewer/components/ScreenshotButton.tsx +12 -12
- package/src/viewer/components/SkeletonLoader.tsx +99 -83
- package/src/viewer/components/StoryRenderer.tsx +4 -11
- package/src/viewer/components/Toast.tsx +3 -67
- package/src/viewer/components/TokenStylePanel.tsx +136 -118
- package/src/viewer/components/UsageSection.tsx +26 -26
- package/src/viewer/components/VariantMatrix.tsx +140 -47
- package/src/viewer/components/VariantTabs.tsx +24 -68
- package/src/viewer/components/ViewportSelector.tsx +121 -114
- package/src/viewer/constants/ui.ts +23 -22
- package/src/viewer/entry.tsx +8 -3
- package/src/viewer/index.ts +3 -6
- package/src/viewer/preview-frame.html +43 -18
- package/src/viewer/server.ts +7 -16
- package/src/viewer/styles/globals.css +46 -85
- package/src/viewer/utils/a11y-fixes.ts +53 -30
- package/dist/chunk-ICAIQ57V.js.map +0 -1
- package/dist/chunk-U4GQ2JTD.js +0 -832
- package/dist/chunk-U4GQ2JTD.js.map +0 -1
- package/dist/scan-ESEXV7LF.js +0 -12
- package/dist/static-viewer-O37MJ5B6.js +0 -12
- package/dist/viewer-YDGFDTK5.js +0 -11104
- package/dist/viewer-YDGFDTK5.js.map +0 -1
- package/src/viewer/postcss.config.js +0 -6
- package/src/viewer/tailwind.config.js +0 -37
- /package/dist/{chunk-IOJE35DZ.js.map → chunk-NWQ4CJOQ.js.map} +0 -0
- /package/dist/{chunk-2DJH4F4P.js.map → chunk-RVRTRESS.js.map} +0 -0
- /package/dist/{chunk-XNWDI6UT.js.map → chunk-XHUDJNN3.js.map} +0 -0
- /package/dist/{core-DKHB7FYV.js.map → core-W2HYIQW6.js.map} +0 -0
- /package/dist/{generate-KL24VZVD.js.map → generate-LMTISDIJ.js.map} +0 -0
- /package/dist/{init-NION5S3M.js.map → init-7CHRKQ7P.js.map} +0 -0
- /package/dist/{scan-ESEXV7LF.js.map → scan-WY23TJCP.js.map} +0 -0
- /package/dist/{service-RWUMZ3EW.js.map → service-T2L7VLTE.js.map} +0 -0
- /package/dist/{static-viewer-O37MJ5B6.js.map → static-viewer-GBR7YNF3.js.map} +0 -0
- /package/dist/{test-ECPEXFDN.js.map → test-OJRXNDO2.js.map} +0 -0
- /package/dist/{tokens-ITADYVPF.js.map → tokens-3BWDESVM.js.map} +0 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
getStaticFix,
|
|
4
|
+
generateElementFix,
|
|
5
|
+
getImpactDescription,
|
|
6
|
+
getImpactColorClass,
|
|
7
|
+
extractWcagTags,
|
|
8
|
+
parseWcagTag,
|
|
9
|
+
} from '../utils/a11y-fixes.js';
|
|
10
|
+
import type { SerializedNode } from '../types/a11y.js';
|
|
11
|
+
|
|
12
|
+
function makeNode(overrides?: Partial<SerializedNode>): SerializedNode {
|
|
13
|
+
return {
|
|
14
|
+
html: '<div>test</div>',
|
|
15
|
+
target: ['div'],
|
|
16
|
+
...overrides,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function makeContrastNode(
|
|
21
|
+
fg: string,
|
|
22
|
+
bg: string,
|
|
23
|
+
ratio: number,
|
|
24
|
+
required: number
|
|
25
|
+
): SerializedNode {
|
|
26
|
+
return {
|
|
27
|
+
html: '<span style="color: ' + fg + '; background: ' + bg + '">text</span>',
|
|
28
|
+
target: ['span'],
|
|
29
|
+
any: [
|
|
30
|
+
{
|
|
31
|
+
id: 'color-contrast',
|
|
32
|
+
data: {
|
|
33
|
+
fgColor: fg,
|
|
34
|
+
bgColor: bg,
|
|
35
|
+
contrastRatio: ratio,
|
|
36
|
+
expectedContrastRatio: required,
|
|
37
|
+
fontSize: '16px',
|
|
38
|
+
fontWeight: 'normal',
|
|
39
|
+
},
|
|
40
|
+
impact: 'serious',
|
|
41
|
+
message: 'Element has insufficient color contrast',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
describe('getStaticFix', () => {
|
|
48
|
+
const knownRules = [
|
|
49
|
+
'color-contrast',
|
|
50
|
+
'image-alt',
|
|
51
|
+
'button-name',
|
|
52
|
+
'link-name',
|
|
53
|
+
'label',
|
|
54
|
+
'aria-valid-attr',
|
|
55
|
+
'aria-valid-attr-value',
|
|
56
|
+
'aria-required-attr',
|
|
57
|
+
'heading-order',
|
|
58
|
+
'tabindex',
|
|
59
|
+
'duplicate-id',
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
for (const ruleId of knownRules) {
|
|
63
|
+
it(`returns fix for "${ruleId}"`, () => {
|
|
64
|
+
const fix = getStaticFix(ruleId);
|
|
65
|
+
expect(fix).not.toBeNull();
|
|
66
|
+
expect(fix!.whyItMatters).toBeTruthy();
|
|
67
|
+
expect(fix!.howToFix).toBeTruthy();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
it('returns null for unknown rule', () => {
|
|
72
|
+
expect(getStaticFix('unknown-rule')).toBeNull();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('color-contrast has wcagCriterion 1.4.3 AA', () => {
|
|
76
|
+
const fix = getStaticFix('color-contrast');
|
|
77
|
+
expect(fix!.wcagCriterion).toBeDefined();
|
|
78
|
+
expect(fix!.wcagCriterion!.id).toBe('1.4.3');
|
|
79
|
+
expect(fix!.wcagCriterion!.level).toBe('AA');
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('generateElementFix — color-contrast', () => {
|
|
84
|
+
it('valid colors → autoFixable: true with suggested hex', () => {
|
|
85
|
+
const node = makeContrastNode('#888888', '#ffffff', 3.54, 4.5);
|
|
86
|
+
const fix = generateElementFix('color-contrast', node);
|
|
87
|
+
expect(fix).not.toBeNull();
|
|
88
|
+
expect(fix!.autoFixable).toBe(true);
|
|
89
|
+
expect(fix!.explanation).toMatch(/#[0-9a-f]{6}/);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('includes ratio in explanation', () => {
|
|
93
|
+
const node = makeContrastNode('#888888', '#ffffff', 3.54, 4.5);
|
|
94
|
+
const fix = generateElementFix('color-contrast', node);
|
|
95
|
+
expect(fix!.explanation).toContain('3.54');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('includes required ratio in explanation', () => {
|
|
99
|
+
const node = makeContrastNode('#888888', '#ffffff', 3.54, 4.5);
|
|
100
|
+
const fix = generateElementFix('color-contrast', node);
|
|
101
|
+
expect(fix!.explanation).toContain('4.5');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('missing fg color → null', () => {
|
|
105
|
+
const node = makeNode({
|
|
106
|
+
any: [{
|
|
107
|
+
id: 'color-contrast',
|
|
108
|
+
data: { bgColor: '#ffffff' },
|
|
109
|
+
impact: 'serious',
|
|
110
|
+
message: 'Insufficient contrast',
|
|
111
|
+
}],
|
|
112
|
+
});
|
|
113
|
+
const fix = generateElementFix('color-contrast', node);
|
|
114
|
+
expect(fix).toBeNull();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('missing bg color → null', () => {
|
|
118
|
+
const node = makeNode({
|
|
119
|
+
any: [{
|
|
120
|
+
id: 'color-contrast',
|
|
121
|
+
data: { fgColor: '#888888' },
|
|
122
|
+
impact: 'serious',
|
|
123
|
+
message: 'Insufficient contrast',
|
|
124
|
+
}],
|
|
125
|
+
});
|
|
126
|
+
const fix = generateElementFix('color-contrast', node);
|
|
127
|
+
expect(fix).toBeNull();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('CSS variable colors → autoFixable: false', () => {
|
|
131
|
+
const node = makeNode({
|
|
132
|
+
html: '<span>text</span>',
|
|
133
|
+
any: [{
|
|
134
|
+
id: 'color-contrast',
|
|
135
|
+
data: {
|
|
136
|
+
fgColor: 'var(--text-color)',
|
|
137
|
+
bgColor: '#ffffff',
|
|
138
|
+
contrastRatio: 3.0,
|
|
139
|
+
expectedContrastRatio: 4.5,
|
|
140
|
+
},
|
|
141
|
+
impact: 'serious',
|
|
142
|
+
message: 'Insufficient contrast',
|
|
143
|
+
}],
|
|
144
|
+
});
|
|
145
|
+
const fix = generateElementFix('color-contrast', node);
|
|
146
|
+
expect(fix).not.toBeNull();
|
|
147
|
+
expect(fix!.autoFixable).toBe(false);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('no any data → null', () => {
|
|
151
|
+
const node = makeNode({ html: '<span>text</span>' });
|
|
152
|
+
const fix = generateElementFix('color-contrast', node);
|
|
153
|
+
expect(fix).toBeNull();
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('generateElementFix — image-alt', () => {
|
|
158
|
+
it('missing alt → adds alt attribute', () => {
|
|
159
|
+
const node = makeNode({ html: '<img src="hero.jpg">' });
|
|
160
|
+
const fix = generateElementFix('image-alt', node);
|
|
161
|
+
expect(fix).not.toBeNull();
|
|
162
|
+
expect(fix!.fixedHtml).toContain('alt=');
|
|
163
|
+
expect(fix!.autoFixable).toBe(true);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('empty alt → replaces with descriptive text', () => {
|
|
167
|
+
const node = makeNode({ html: '<img src="photo.jpg" alt="">' });
|
|
168
|
+
const fix = generateElementFix('image-alt', node);
|
|
169
|
+
expect(fix).not.toBeNull();
|
|
170
|
+
expect(fix!.fixedHtml).toContain('alt="photo"');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('derives alt text from filename', () => {
|
|
174
|
+
const node = makeNode({ html: '<img src="/images/user-profile.png">' });
|
|
175
|
+
const fix = generateElementFix('image-alt', node);
|
|
176
|
+
expect(fix!.fixedHtml).toContain('user profile');
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('handles camelCase filenames', () => {
|
|
180
|
+
const node = makeNode({ html: '<img src="teamPhoto.jpg">' });
|
|
181
|
+
const fix = generateElementFix('image-alt', node);
|
|
182
|
+
expect(fix!.fixedHtml).toContain('team photo');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('autoFixable is true', () => {
|
|
186
|
+
const node = makeNode({ html: '<img src="test.jpg">' });
|
|
187
|
+
const fix = generateElementFix('image-alt', node);
|
|
188
|
+
expect(fix!.autoFixable).toBe(true);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
describe('generateElementFix — button-name', () => {
|
|
193
|
+
it('SVG-only button → aria-label suggestion', () => {
|
|
194
|
+
const node = makeNode({
|
|
195
|
+
html: '<button><svg xmlns="http://www.w3.org/2000/svg"><path d="M10 10"/></svg></button>',
|
|
196
|
+
});
|
|
197
|
+
const fix = generateElementFix('button-name', node);
|
|
198
|
+
expect(fix).not.toBeNull();
|
|
199
|
+
expect(fix!.fixedHtml).toContain('aria-label');
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('empty button → text suggestion', () => {
|
|
203
|
+
const node = makeNode({ html: '<button></button>' });
|
|
204
|
+
const fix = generateElementFix('button-name', node);
|
|
205
|
+
expect(fix).not.toBeNull();
|
|
206
|
+
expect(fix!.fixedHtml).toContain('[Button text]');
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('autoFixable is false (requires human decision)', () => {
|
|
210
|
+
const node = makeNode({ html: '<button></button>' });
|
|
211
|
+
const fix = generateElementFix('button-name', node);
|
|
212
|
+
expect(fix!.autoFixable).toBe(false);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
describe('generateElementFix — link-name', () => {
|
|
217
|
+
it('SVG-only link → aria-label suggestion', () => {
|
|
218
|
+
const node = makeNode({
|
|
219
|
+
html: '<a href="/"><svg xmlns="http://www.w3.org/2000/svg"><path d="M10 10"/></svg></a>',
|
|
220
|
+
});
|
|
221
|
+
const fix = generateElementFix('link-name', node);
|
|
222
|
+
expect(fix).not.toBeNull();
|
|
223
|
+
expect(fix!.fixedHtml).toContain('aria-label');
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('empty link → text suggestion', () => {
|
|
227
|
+
const node = makeNode({ html: '<a href="/about"></a>' });
|
|
228
|
+
const fix = generateElementFix('link-name', node);
|
|
229
|
+
expect(fix).not.toBeNull();
|
|
230
|
+
expect(fix!.fixedHtml).toContain('[Link text]');
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it('text link → explanation only (no fixedHtml change needed)', () => {
|
|
234
|
+
const node = makeNode({ html: '<a href="/about">Click here</a>' });
|
|
235
|
+
const fix = generateElementFix('link-name', node);
|
|
236
|
+
expect(fix).not.toBeNull();
|
|
237
|
+
expect(fix!.explanation).toContain('descriptive');
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('autoFixable is false', () => {
|
|
241
|
+
const node = makeNode({ html: '<a href="/"></a>' });
|
|
242
|
+
const fix = generateElementFix('link-name', node);
|
|
243
|
+
expect(fix!.autoFixable).toBe(false);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
describe('generateElementFix — label', () => {
|
|
248
|
+
it('input with id → label suggestion', () => {
|
|
249
|
+
const node = makeNode({ html: '<input type="email" id="email-input">' });
|
|
250
|
+
const fix = generateElementFix('label', node);
|
|
251
|
+
expect(fix).not.toBeNull();
|
|
252
|
+
expect(fix!.explanation).toContain('email-input');
|
|
253
|
+
expect(fix!.explanation).toContain('<label');
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('input without id → adds id', () => {
|
|
257
|
+
const node = makeNode({ html: '<input type="text">' });
|
|
258
|
+
const fix = generateElementFix('label', node);
|
|
259
|
+
expect(fix).not.toBeNull();
|
|
260
|
+
expect(fix!.fixedHtml).toContain('id=');
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it('autoFixable is false', () => {
|
|
264
|
+
const node = makeNode({ html: '<input type="text">' });
|
|
265
|
+
const fix = generateElementFix('label', node);
|
|
266
|
+
expect(fix!.autoFixable).toBe(false);
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
describe('generateElementFix — unknown rule', () => {
|
|
271
|
+
it('heading-order → null (no generator registered)', () => {
|
|
272
|
+
const node = makeNode({ html: '<h4>Section</h4>' });
|
|
273
|
+
const fix = generateElementFix('heading-order', node);
|
|
274
|
+
expect(fix).toBeNull();
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
describe('getImpactDescription', () => {
|
|
279
|
+
it('critical → correct description', () => {
|
|
280
|
+
expect(getImpactDescription('critical')).toContain('completely block');
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('serious → correct description', () => {
|
|
284
|
+
expect(getImpactDescription('serious')).toContain('very difficult');
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it('moderate → correct description', () => {
|
|
288
|
+
expect(getImpactDescription('moderate')).toContain('some difficulty');
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it('minor → correct description', () => {
|
|
292
|
+
expect(getImpactDescription('minor')).toContain('slight inconvenience');
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it('null → fallback description', () => {
|
|
296
|
+
expect(getImpactDescription(null)).toContain('not determined');
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
describe('getImpactColorClass', () => {
|
|
301
|
+
it('critical → error variant with danger color', () => {
|
|
302
|
+
const result = getImpactColorClass('critical');
|
|
303
|
+
expect(result.variant).toBe('error');
|
|
304
|
+
expect(result.color).toContain('danger');
|
|
305
|
+
expect(result.bg).toContain('danger');
|
|
306
|
+
expect(result.borderLeft).toContain('danger');
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
it('serious → error variant with danger color', () => {
|
|
310
|
+
const result = getImpactColorClass('serious');
|
|
311
|
+
expect(result.variant).toBe('error');
|
|
312
|
+
expect(result.color).toContain('danger');
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('moderate → warning variant', () => {
|
|
316
|
+
const result = getImpactColorClass('moderate');
|
|
317
|
+
expect(result.variant).toBe('warning');
|
|
318
|
+
expect(result.color).toContain('warning');
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it('minor/null → info variant', () => {
|
|
322
|
+
const minorResult = getImpactColorClass('minor');
|
|
323
|
+
expect(minorResult.variant).toBe('info');
|
|
324
|
+
expect(minorResult.color).toContain('info');
|
|
325
|
+
const nullResult = getImpactColorClass(null);
|
|
326
|
+
expect(nullResult.variant).toBe('info');
|
|
327
|
+
expect(nullResult.color).toContain('info');
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
describe('extractWcagTags', () => {
|
|
332
|
+
it('filters wcag-prefixed tags only', () => {
|
|
333
|
+
const tags = ['wcag2a', 'wcag143', 'cat.color', 'best-practice'];
|
|
334
|
+
const result = extractWcagTags(tags);
|
|
335
|
+
expect(result).toEqual(['wcag2a', 'wcag143']);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
it('returns empty when no wcag tags', () => {
|
|
339
|
+
const tags = ['best-practice', 'cat.aria'];
|
|
340
|
+
const result = extractWcagTags(tags);
|
|
341
|
+
expect(result).toEqual([]);
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
describe('parseWcagTag', () => {
|
|
346
|
+
it('wcag143 → 1.4.3', () => {
|
|
347
|
+
expect(parseWcagTag('wcag143')).toBe('1.4.3');
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('wcag111 → 1.1.1', () => {
|
|
351
|
+
expect(parseWcagTag('wcag111')).toBe('1.1.1');
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it('non-matching → null', () => {
|
|
355
|
+
expect(parseWcagTag('wcag2a')).toBeNull();
|
|
356
|
+
expect(parseWcagTag('best-practice')).toBeNull();
|
|
357
|
+
});
|
|
358
|
+
});
|
|
@@ -50,14 +50,9 @@ describe("viewer path resolution", () => {
|
|
|
50
50
|
expect(existsSync(resolve(viewerRoot, "render-template.html"))).toBe(true);
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
it("viewerRoot
|
|
53
|
+
it("viewerRoot does not contain tailwind.config.js (removed in Tailwind→Fragments migration)", () => {
|
|
54
54
|
const viewerRoot = resolve(cliPackageRoot, "src/viewer");
|
|
55
|
-
expect(existsSync(resolve(viewerRoot, "tailwind.config.js"))).toBe(
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("viewerRoot contains postcss.config.js", () => {
|
|
59
|
-
const viewerRoot = resolve(cliPackageRoot, "src/viewer");
|
|
60
|
-
expect(existsSync(resolve(viewerRoot, "postcss.config.js"))).toBe(true);
|
|
55
|
+
expect(existsSync(resolve(viewerRoot, "tailwind.config.js"))).toBe(false);
|
|
61
56
|
});
|
|
62
57
|
|
|
63
58
|
it("viewerRoot contains styles/globals.css", () => {
|