Skip to content

Commit b1e3938

Browse files
authored
test(tabs): add axe tree test for selected state (#3098)
Closes #2771 Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2d894f1 commit b1e3938

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

elements/pf-tabs/test/pf-tabs.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ describe('<pf-tabs>', function() {
5252

5353
beforeEach(updateComplete);
5454

55+
it('should show the first tab as selected in the accessibility tree', async function() {
56+
const snapshot = await a11ySnapshot();
57+
const tabs = snapshot.children?.filter(x => x.role === 'tab') ?? [];
58+
const [first, ...rest] = tabs;
59+
expect(first).to.have.property('selected', true);
60+
for (const tab of rest) {
61+
expect(tab).to.not.have.property('selected', true);
62+
}
63+
});
64+
5565
it('should apply aria attributes on initialization', function() {
5666
const tabs = element.querySelectorAll('pf-tab');
5767
const panels = element.querySelectorAll('pf-tab-panel');
@@ -121,6 +131,15 @@ describe('<pf-tabs>', function() {
121131
it('should hide previously active panel', function() {
122132
expect(element.querySelector('pf-tab-panel')).to.have.attribute('hidden');
123133
});
134+
135+
it('should show the second tab as selected in the accessibility tree', async function() {
136+
const snapshot = await a11ySnapshot();
137+
const tabs = snapshot.children?.filter(x => x.role === 'tab') ?? [];
138+
const [first, second, third] = tabs;
139+
expect(first).to.not.have.property('selected', true);
140+
expect(second).to.have.property('selected', true);
141+
expect(third).to.not.have.property('selected', true);
142+
});
124143
});
125144

126145
describe('setting `activeIndex` to 2', function() {

0 commit comments

Comments
 (0)