Skip to content

Commit

Permalink
chore(tests): added checks for page breaks without aria-label or titl…
Browse files Browse the repository at this point in the history
…e but with textual content inside element (see #355 ) [skip ci]
  • Loading branch information
danielweck committed Jul 7, 2022
1 parent 5bd93d3 commit b5d1b66
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/__tests__/axe-rules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ test('DPUB ARIA landmark unique', async () => {

test('Ensure page breaks have labels', async () => {
const report = await ace('../data/axerule-pagebreak-label');
// console.log(JSON.stringify(report, null, 4));
expect(report['earl:result']['earl:outcome']).toEqual('fail');
const assertions = findAssertionsForDoc(report, 'content_001.xhtml');
expect(assertions).toBeDefined();
Expand All @@ -174,6 +175,20 @@ test('Ensure page breaks have labels', async () => {
'earl:pointer': expect.objectContaining({ css: ['#p4'] }),
}),
}),
expect.objectContaining({
'earl:test': expect.objectContaining({ 'dct:title': 'pagebreak-label' }),
'earl:result': expect.objectContaining({
'earl:outcome': 'fail',
'earl:pointer': expect.objectContaining({ css: ['#p7'] }),
}),
}),
expect.objectContaining({
'earl:test': expect.objectContaining({ 'dct:title': 'pagebreak-label' }),
'earl:result': expect.objectContaining({
'earl:outcome': 'fail',
'earl:pointer': expect.objectContaining({ css: ['#p8'] }),
}),
}),
]));
expect(assertions).not.toEqual(expect.arrayContaining([
expect.objectContaining({
Expand All @@ -193,6 +208,43 @@ test('Ensure page breaks have labels', async () => {
}),
})
]));
expect(assertions).not.toEqual(expect.arrayContaining([
expect.objectContaining({
'earl:test': expect.objectContaining({ 'dct:title': 'pagebreak-label' }),
'earl:result': expect.objectContaining({
'earl:outcome': 'fail',
'earl:pointer': expect.objectContaining({ css: ['#p5'] }),
}),
})
]));
expect(assertions).not.toEqual(expect.arrayContaining([
expect.objectContaining({
'earl:test': expect.objectContaining({ 'dct:title': 'pagebreak-label' }),
'earl:result': expect.objectContaining({
'earl:outcome': 'fail',
'earl:pointer': expect.objectContaining({ css: ['#p6'] }),
}),
})
]));
// SEE: https://github.com/daisy/ace/issues/355
// expect(assertions).not.toEqual(expect.arrayContaining([
// expect.objectContaining({
// 'earl:test': expect.objectContaining({ 'dct:title': 'pagebreak-label' }),
// 'earl:result': expect.objectContaining({
// 'earl:outcome': 'fail',
// 'earl:pointer': expect.objectContaining({ css: ['#p7'] }),
// }),
// })
// ]));
// expect(assertions).not.toEqual(expect.arrayContaining([
// expect.objectContaining({
// 'earl:test': expect.objectContaining({ 'dct:title': 'pagebreak-label' }),
// 'earl:result': expect.objectContaining({
// 'earl:outcome': 'fail',
// 'earl:pointer': expect.objectContaining({ css: ['#p8'] }),
// }),
// })
// ]));
});

test('Checks that `epub:type` have matching ARIA roles', async() => {
Expand Down
4 changes: 4 additions & 0 deletions tests/data/axerule-pagebreak-label/EPUB/content_001.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@
<span id="p2" epub:type="pagebreak" title="p2"/>
<span id="p3" role="doc-pagebreak"/>
<span id="p4" epub:type="pagebreak"/>
<span id="p5" role="doc-pagebreak" aria-label="p5"/>
<span id="p6" epub:type="pagebreak" aria-label="p6"/>
<span id="p7" role="doc-pagebreak">p7</span>
<span id="p8" epub:type="pagebreak">p8</span>
</body>
</html>

0 comments on commit b5d1b66

Please sign in to comment.