From b044e0684e7b7f92616286846deb887b0e799b61 Mon Sep 17 00:00:00 2001 From: AdityaP7649 Date: Tue, 10 Dec 2024 17:52:42 +0530 Subject: [PATCH 1/2] test(tabs): added axe tree test for aria selected state --- elements/pf-tabs/test/pf-tabs.spec.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/elements/pf-tabs/test/pf-tabs.spec.ts b/elements/pf-tabs/test/pf-tabs.spec.ts index a8c7c3484d..a8b1ece9d9 100644 --- a/elements/pf-tabs/test/pf-tabs.spec.ts +++ b/elements/pf-tabs/test/pf-tabs.spec.ts @@ -241,6 +241,11 @@ describe('', function() { expect(second).to.have.attribute('active'); expect(third).to.not.have.attribute('active'); }); + + it('should specify the selected tab to assistive technology', async function() { + const snapshot = await a11ySnapshot(); + expect(snapshot.children?.find(x => x.role === 'tabpanel')?.name).to.equal('tab-2'); + }); }); describe('pressing ArrowLeft', function() { @@ -254,6 +259,12 @@ describe('', function() { expect(second).to.not.have.attribute('active'); expect(third).to.have.attribute('active'); }); + + it('should specify the selected tab to assistive technology', async function() { + const snapshot = await a11ySnapshot(); + expect(snapshot.children?.find(x => x.role === 'tabpanel')?.name).to.equal('tab-3'); + }); + describe('then pressing ArrowRight', function() { beforeEach(async function() { await sendKeys({ down: 'ArrowRight' }); @@ -267,6 +278,11 @@ describe('', function() { expect(second).to.not.have.attribute('active'); expect(third).to.not.have.attribute('active'); }); + + it('should specify the selected tab to assistive technology', async function() { + const snapshot = await a11ySnapshot(); + expect(snapshot.children?.find(x => x.role === 'tabpanel')?.name).to.equal('tab-1'); + }); }); }); }); From abb3b9a0d202b3ce77d7cd49923b03471646a722 Mon Sep 17 00:00:00 2001 From: AdityaP7649 Date: Wed, 11 Dec 2024 12:04:25 +0530 Subject: [PATCH 2/2] test(tabs): updated axe tree tests to use ax helpers --- elements/pf-tabs/test/pf-tabs.spec.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/elements/pf-tabs/test/pf-tabs.spec.ts b/elements/pf-tabs/test/pf-tabs.spec.ts index a8b1ece9d9..419f3b28cd 100644 --- a/elements/pf-tabs/test/pf-tabs.spec.ts +++ b/elements/pf-tabs/test/pf-tabs.spec.ts @@ -243,8 +243,7 @@ describe('', function() { }); it('should specify the selected tab to assistive technology', async function() { - const snapshot = await a11ySnapshot(); - expect(snapshot.children?.find(x => x.role === 'tabpanel')?.name).to.equal('tab-2'); + expect(await a11ySnapshot()).to.axContainQuery({ role: 'tabpanel', name: 'tab-2' }); }); }); @@ -261,8 +260,7 @@ describe('', function() { }); it('should specify the selected tab to assistive technology', async function() { - const snapshot = await a11ySnapshot(); - expect(snapshot.children?.find(x => x.role === 'tabpanel')?.name).to.equal('tab-3'); + expect(await a11ySnapshot()).to.axContainQuery({ role: 'tabpanel', name: 'tab-3' }); }); describe('then pressing ArrowRight', function() { @@ -280,8 +278,7 @@ describe('', function() { }); it('should specify the selected tab to assistive technology', async function() { - const snapshot = await a11ySnapshot(); - expect(snapshot.children?.find(x => x.role === 'tabpanel')?.name).to.equal('tab-1'); + expect(await a11ySnapshot()).to.axContainQuery({ role: 'tabpanel', name: 'tab-1' }); }); }); });