-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget-rule-content.ts
440 lines (364 loc) · 14.1 KB
/
get-rule-content.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
import moment from "moment";
import outdent from "outdent";
import { RulePage } from "../../types";
import { indent } from "../../utils/index";
import { parsePage } from "../../utils/parse-page";
import { createGlossary } from "../__test-utils";
import { getRuleContent } from "../get-rule-content";
import { getFooter } from "../rule-content/frontmatter/get-footer";
describe("getRuleContent", () => {
const q = "```";
const glossaryBase = {
hello: outdent`
Hello [world][]
[world]: #world
[w3c]: https://w3.org
`,
world: outdent`
World of the [ACT-rules community][]
[act-rules community]: https://act-rules.github.io
`,
outcome: `All good.`,
};
const glossary = createGlossary(glossaryBase);
it("creates a complete rule page", () => {
const rulePage = parsePage(outdent`
---
id: abc123
name: Hello world
rule_type: atomic
description: hello world
accessibility_requirements:
wcag20:4.1.2: # Name, Role, Value (A)
forConformance: true
failed: not satisfied
passed: further testing needed
inapplicable: further testing needed
wcag20:1.1.1: # Non-text Content (A)
secondary: |
This rule is **less strict** than this criterion.
using-aria:fourth:
title: Fourth rule of ARIA use
secondary: This rule is **more strict** than this requirement.
input_aspects:
- DOM Tree
acknowledgments:
authors:
- Wilco Fiers
---
[hello][], [w3c][]
## Passed Example 1
${q}html
<img alt="" />
${q}
[hello]: #hello
[w3c]: https://w3.org 'W3C website'
`) as RulePage;
const taskforceMarkdown = getRuleContent(
{
...rulePage,
filename: "abc123.md",
assets: {
"/test-assets/hello.css": "div { color: blue }",
"/test-assets/world.js": "console.log('world');",
},
},
glossary,
{ matrix: true },
[]
);
expect(taskforceMarkdown).toBe(
outdent`
---
title: "Hello world"
permalink: /standards-guidelines/act/rules/abc123/
ref: /standards-guidelines/act/rules/abc123/
lang: en
github:
repository: w3c/wcag-act-rules
path: content/rules/abc123/index.md
feedbackmail: public-wcag-act@w3.org
footer: |
${indent(getFooter(rulePage.frontmatter, false))}
proposed: false
rule_meta:
id: abc123
name: "Hello world"
rule_type: atomic
original_file: abc123.md
description: |
hello world
last_modified: ${moment().format("D MMMM YYYY")}
scs_tested:
- handle: Name, Role, Value
num: 4.1.2
level: A
---
[hello][], [w3c][]
## Accessibility Requirements Mapping
<ul class="act-requirements-list">
<li><details>
<summary><span>4.1.2 Name, Role, Value (Level A)</span></summary>
<ul>
<li><a href="https://www.w3.org/TR/WCAG22/#name-role-value">Learn more about 4.1.2 Name, Role, Value</a></li>
<li><strong>Required for conformance</strong> to WCAG 2.0 and later on level A and higher.</li>
<li>Outcome mapping: <ul>
<li>Any <code>failed</code> outcomes: success criterion is not satisfied</li>
<li>All <code>passed</code> outcomes: success criterion needs further testing</li>
<li>An <code>inapplicable</code> outcome: success criterion needs further testing</li>
</ul></li>
</ul>
</details></li>
</ul>
### Secondary Requirements
This rule is related to the following accessibility requirements, but was
not designed to test this requirements directly. These
[secondary requirements](https://w3c.github.io/wcag-act/act-rules-format.html#secondary-requirements)
can either be stricter than the rule requires, or may be satisfied in ways
not tested by the rule:
- [1.1.1 Non-text Content (Level A)](https://www.w3.org/TR/WCAG22/#non-text-content): This rule is **less strict** than this criterion.
- [Fourth rule of ARIA use](https://www.w3.org/TR/using-aria/#fourth): This rule is **more strict** than this requirement.
## Input Aspects
The following aspects are required in using this rule.
- [DOM Tree](https://www.w3.org/TR/act-rules-aspects/#input-aspects-dom)
## Test Cases
<details class="act-inline-assets" markdown="block">
<summary><span>These Javascript and CSS files are used in several examples:</span></summary>
File [\`/test-assets/world.js\`](https://w3.org/WAI/content-assets/wcag-act-rules/test-assets/world.js):
${q}javascript
console.log('world');
${q}
File [\`/test-assets/hello.css\`](https://w3.org/WAI/content-assets/wcag-act-rules/test-assets/hello.css):
${q}css
div { color: blue }
${q}
</details>
### Passed
#### Passed Example 1
<a class="example-link" title="Passed Example 1" target="_blank" href="https://w3.org/WAI/content-assets/wcag-act-rules/testcases/abc123/98a6b1fc6e5d43490f9c9a7cce9676487c94d2a3.html">Open in a new tab</a>
${q}html
<img alt="" />
${q}
### Failed
_There are no failed examples._
### Inapplicable
_There are no inapplicable examples._
## Glossary
### Hello {#hello}
Hello [world][]
### Outcome {#outcome}
All good.
### World {#world}
World of the [ACT-rules community][]
[act-rules community]: https://act-rules.github.io
[hello]: #hello
[w3c]: https://w3.org 'W3C website'
[world]: #world
`
);
});
// Mapping to WCAG SCs adds a scs_tested key to the TF Markdown, which is
// somewhat annoying to handle in bulk. So they are not part of this test
// but are effectively tested as part of the previous one.
it("accept all possible non-WCAG mappings", () => {
const requirements = [
{
source: `wcag-technique:ARIA5: # Using WAI-ARIA state and property attributes to expose the state of a user interface component
forConformance: false
failed: not satisfied
passed: further testing needed
inapplicable: further testing needed`,
expected: outdent`
<ul class="act-requirements-list">
<li><details>
<summary><span>ARIA5: Using WAI-ARIA state and property attributes to expose the state of a user interface component</span></summary>
<ul>
<li><a href="https://www.w3.org/WAI/WCAG22/Techniques/aria/ARIA5">Learn more about technique ARIA5</a></li>
<li>Not required for conformance to any W3C accessibility recommendation.</li>
<li>Outcome mapping: <ul>
<li>Any <code>failed</code> outcomes: technique is not satisfied</li>
<li>All <code>passed</code> outcomes: technique needs further testing</li>
<li>An <code>inapplicable</code> outcome: technique needs further testing</li>
</ul></li>
</ul>
</details></li>
</ul>`,
},
{
source: `aria12:state_property_processing:
title: ARIA 1.2, 8.6 State and Property Attribute Processing
forConformance: true
failed: not satisfied
passed: satisfied
inapplicable: satisfied`,
expected: outdent`
<ul class="act-requirements-list">
<li><details>
<summary><span>ARIA 1.2, 8.6 State and Property Attribute Processing</span></summary>
<ul>
<li><a href="https://www.w3.org/TR/wai-aria-1.2/#state_property_processing">Learn more about ARIA 1.2, 8.6 State and Property Attribute Processing</a></li>
<li><strong>Required for conformance</strong> to WAI-ARIA 1.2 author requirements.</li>
<li>Outcome mapping: <ul>
<li>Any <code>failed</code> outcomes: WAI-ARIA requirement is not satisfied</li>
<li>All <code>passed</code> outcomes: WAI-ARIA requirement is satisfied</li>
<li>An <code>inapplicable</code> outcome: WAI-ARIA requirement is satisfied</li>
</ul></li>
</ul>
</details></li>
</ul>`,
},
{
source: `html-aria:docconformance:
title: ARIA in HTML, 4. Document conformance requirements for use of ARIA attributes in HTML
forConformance: true
failed: not satisfied
passed: satisfied
inapplicable: satisfied`,
expected: outdent`
<ul class="act-requirements-list">
<li><details>
<summary><span>ARIA in HTML, 4. Document conformance requirements for use of ARIA attributes in HTML</span></summary>
<ul>
<li><a href="https://www.w3.org/TR/html-aria/#docconformance">Learn more about ARIA in HTML, 4. Document conformance requirements for use of ARIA attributes in HTML</a></li>
<li><strong>Required for conformance</strong> to ARIA in HTML.</li>
<li>Outcome mapping: <ul>
<li>Any <code>failed</code> outcomes: ARIA in HTML requirement is not satisfied</li>
<li>All <code>passed</code> outcomes: ARIA in HTML requirement is satisfied</li>
<li>An <code>inapplicable</code> outcome: ARIA in HTML requirement is satisfied</li>
</ul></li>
</ul>
</details></li>
</ul>`,
},
{
source: `using-aria:fourth:
title: Fourth rule of ARIA use
forConformance: false
failed: not satisfied
passed: further testing needed
inapplicable: further testing needed`,
expected: outdent`
<ul class="act-requirements-list">
<li><details>
<summary><span>Fourth rule of ARIA use</span></summary>
<ul>
<li><a href="https://www.w3.org/TR/using-aria/#fourth">Learn more about Fourth rule of ARIA use</a></li>
<li>Not required for conformance to any W3C accessibility recommendation.</li>
<li>Outcome mapping: <ul>
<li>Any <code>failed</code> outcomes: WAI-ARIA rule is not satisfied</li>
<li>All <code>passed</code> outcomes: WAI-ARIA rule needs further testing</li>
<li>An <code>inapplicable</code> outcome: WAI-ARIA rule needs further testing</li>
</ul></li>
</ul>
</details></li>
</ul>`,
},
{
source: `wcag-text:cc5: # Non-interference due to mapping to 2.2.2
title: WCAG Non-Interference
forConformance: true
failed: not satisfied
passed: further testing needed
inapplicable: further testing needed`,
expected: outdent`
<ul class="act-requirements-list">
<li><details>
<summary><span>WCAG Non-Interference</span></summary>
<ul>
<li><a href="https://www.w3.org/TR/WCAG22/#cc5">Learn more about WCAG Non-Interference</a></li>
<li><strong>Required for conformance</strong> to WCAG 2.2.</li>
<li>Outcome mapping: <ul>
<li>Any <code>failed</code> outcomes: WCAG 2 conformance requirement is not satisfied</li>
<li>All <code>passed</code> outcomes: WCAG 2 conformance requirement needs further testing</li>
<li>An <code>inapplicable</code> outcome: WCAG 2 conformance requirement needs further testing</li>
</ul></li>
</ul>
</details></li>
</ul>`,
},
];
for (const requirement of requirements) {
const rulePage = parsePage(outdent`
---
id: abc123
name: Hello world
rule_type: atomic
description: hello world
accessibility_requirements:
${requirement.source}
input_aspects:
- DOM Tree
acknowledgments:
authors:
- Wilco Fiers
---
[hello][], [w3c][]
## Passed Example 1
${q}html
<img alt="" />
${q}
[hello]: #hello
[w3c]: https://w3.org 'W3C website'
`) as RulePage;
const taskforceMarkdown = getRuleContent(
{ ...rulePage, filename: "abc123.md" },
glossary,
{ matrix: true },
[]
);
expect(taskforceMarkdown).toBe(
outdent`
---
title: "Hello world"
permalink: /standards-guidelines/act/rules/abc123/
ref: /standards-guidelines/act/rules/abc123/
lang: en
github:
repository: w3c/wcag-act-rules
path: content/rules/abc123/index.md
feedbackmail: public-wcag-act@w3.org
footer: |
${indent(getFooter(rulePage.frontmatter, false))}
proposed: false
rule_meta:
id: abc123
name: "Hello world"
rule_type: atomic
original_file: abc123.md
description: |
hello world
last_modified: ${moment().format("D MMMM YYYY")}
---
[hello][], [w3c][]
## Accessibility Requirements Mapping
${requirement.expected}
## Input Aspects
The following aspects are required in using this rule.
- [DOM Tree](https://www.w3.org/TR/act-rules-aspects/#input-aspects-dom)
## Test Cases
### Passed
#### Passed Example 1
<a class="example-link" title="Passed Example 1" target="_blank" href="https://w3.org/WAI/content-assets/wcag-act-rules/testcases/abc123/98a6b1fc6e5d43490f9c9a7cce9676487c94d2a3.html">Open in a new tab</a>
${q}html
<img alt="" />
${q}
### Failed
_There are no failed examples._
### Inapplicable
_There are no inapplicable examples._
## Glossary
### Hello {#hello}
Hello [world][]
### Outcome {#outcome}
All good.
### World {#world}
World of the [ACT-rules community][]
[act-rules community]: https://act-rules.github.io
[hello]: #hello
[w3c]: https://w3.org 'W3C website'
[world]: #world
`
);
}
});
});