Skip to content

Commit 9e82d97

Browse files
committed
test: cover a11y cases
1 parent 3ce0687 commit 9e82d97

2 files changed

Lines changed: 73 additions & 2 deletions

File tree

‎elements/pf-v6-tooltip/demo/slotted-content.html‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<section>
55
<p>A tooltip may contain
66
<pf-v6-tooltip>
7-
<samp tabindex="0">HTML content</samp>
7+
<button class="inline-trigger">HTML content</button>
88
<span slot="content">
99
Slotted content can be <mark>formatted</mark>, using HTML
1010
tags like <em>em</em>, <strong>strong</strong>, or <code>code</code>.
@@ -22,7 +22,15 @@
2222
padding: 6em;
2323
}
2424

25-
samp {
25+
.inline-trigger {
2626
font-weight: bold;
27+
font-family: monospace;
28+
border: none;
29+
background: none;
30+
padding: 0;
31+
cursor: pointer;
32+
text-decoration: underline;
33+
font-size: inherit;
34+
color: inherit;
2735
}
2836
</style>

‎elements/pf-v6-tooltip/test/pf-v6-tooltip.spec.ts‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,69 @@ describe('<pf-v6-tooltip>', function() {
494494
});
495495
});
496496

497+
describe('announcer live region', function() {
498+
beforeEach(async function() {
499+
element = await fixture<PfV6Tooltip>(html`
500+
<pf-v6-tooltip content="Announced text">
501+
<button>Trigger</button>
502+
</pf-v6-tooltip>
503+
`);
504+
});
505+
506+
describe('after calling show()', function() {
507+
beforeEach(async function() {
508+
await element.show();
509+
await element.updateComplete;
510+
});
511+
512+
it('should populate the live region with tooltip content', async function() {
513+
const snapshot = await a11ySnapshot();
514+
const text = JSON.stringify(snapshot);
515+
expect(text).to.include('Announced text');
516+
});
517+
518+
describe('then calling hide()', function() {
519+
beforeEach(async function() {
520+
await element.hide();
521+
await element.updateComplete;
522+
});
523+
524+
it('should clear the live region', async function() {
525+
const snapshot = await a11ySnapshot();
526+
const text = JSON.stringify(snapshot);
527+
expect(text).to.not.include('Announced text');
528+
});
529+
});
530+
});
531+
});
532+
533+
describe('tooltip content inert state', function() {
534+
beforeEach(async function() {
535+
element = await fixture<PfV6Tooltip>(html`
536+
<pf-v6-tooltip content="Inert test">
537+
<button>Trigger</button>
538+
</pf-v6-tooltip>
539+
`);
540+
});
541+
542+
it('should exclude tooltip content from ax tree when hidden', async function() {
543+
const snapshot = await a11ySnapshot();
544+
expect(snapshot).to.not.axContainName('Inert test');
545+
});
546+
547+
describe('after calling show()', function() {
548+
beforeEach(async function() {
549+
await element.show();
550+
await element.updateComplete;
551+
});
552+
553+
it('should include tooltip content in ax tree when visible', async function() {
554+
const snapshot = await a11ySnapshot();
555+
expect(snapshot).to.axContainName('Inert test');
556+
});
557+
});
558+
});
559+
497560
describe('with silent attribute', function() {
498561
beforeEach(async function() {
499562
element = await fixture<PfV6Tooltip>(html`

0 commit comments

Comments
 (0)