Skip to content

Commit 7a2108c

Browse files
author
Eric Olkowski
committed
Updated integration tests for new default focus behavior
1 parent 8acd254 commit 7a2108c

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

packages/react-integration/cypress/integration/wizard.spec.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,20 @@ describe('Wizard Demo Test', () => {
2424
});
2525
});
2626

27-
it('Verify in-page wizard step content is focusable and has role only if content overflows', () => {
28-
cy.get('#inPageWizWithOverflow .pf-v6-c-wizard__main').should('not.have.attr', 'tabindex');
27+
it('Verify in-page wizard step content has role only if content overflows', () => {
2928
cy.get('#inPageWizWithOverflow .pf-v6-c-wizard__main').should('not.have.attr', 'role');
30-
cy.get('#inPageWizWithOverflow .pf-v6-c-wizard__main').click();
31-
cy.get('#inPageWizWithOverflow .pf-v6-c-wizard__main').should('not.have.focus');
3229
cy.get('#inPageWizWithOverflow #inPage-overflow-step-2.pf-v6-c-wizard__nav-link').click();
33-
cy.get('#inPageWizWithOverflow .pf-v6-c-wizard__main').should('have.attr', 'tabindex');
3430
cy.get('#inPageWizWithOverflow .pf-v6-c-wizard__main').should('have.attr', 'role').and('eq', 'region');
35-
cy.get('#inPageWizWithOverflow .pf-v6-c-wizard__main').click();
36-
cy.get('#inPageWizWithOverflow .pf-v6-c-wizard__main').should('have.focus');
3731
});
3832

39-
it('Verify modal wizard step content is focusable only if content overflows', () => {
40-
cy.get('#launchWizOverflow').click();
41-
cy.get('#inModalWizWithOverflow.pf-v6-c-wizard').should('exist');
42-
cy.get('#inModalWizWithOverflow .pf-v6-c-wizard__main').should('not.have.attr', 'tabindex');
43-
cy.get('#inModalWizWithOverflow .pf-v6-c-wizard__main').should('not.have.attr', 'role');
44-
cy.get('#inModalWizWithOverflow .pf-v6-c-wizard__main').click();
45-
cy.get('#inModalWizWithOverflow .pf-v6-c-wizard__main').should('not.have.focus');
46-
cy.get('#inModalWizWithOverflow #modal-overflow-step-2.pf-v6-c-wizard__nav-link').click();
47-
cy.get('#inModalWizWithOverflow main.pf-v6-c-wizard__main').should('exist');
48-
cy.get('#inModalWizWithOverflow main.pf-v6-c-wizard__main').should('have.attr', 'tabindex');
49-
cy.get('#inModalWizWithOverflow main.pf-v6-c-wizard__main').click();
50-
cy.get('#inModalWizWithOverflow main.pf-v6-c-wizard__main').should('have.focus');
51-
cy.get('#inModalWizWithOverflow .pf-v6-c-wizard__close > button').click();
33+
it('Verify in-page wizard step content receives focus only on next or back click', () => {
34+
cy.get('#inPageFocusTest .pf-v6-c-wizard__main').should('not.have.focus');
35+
cy.get('#inPageFocusTest .pf-v6-c-action-list__group button.pf-m-primary').click();
36+
cy.get('#inPageFocusTest .pf-v6-c-wizard__main').should('have.focus');
37+
cy.get('#inPageFocusTest #inPageFocusTest-wizard-step-b2').click();
38+
cy.get('#inPageFocusTest .pf-v6-c-wizard__main').should('not.have.focus');
39+
cy.get('#inPageFocusTest .pf-v6-c-action-list__group button.pf-m-secondary').click();
40+
cy.get('#inPageFocusTest .pf-v6-c-wizard__main').should('have.focus');
5241
});
5342

5443
it('Verify modal wizard roles are applied correctly', () => {

packages/react-integration/demo-app-ts/src/components/demos/WizardDemo/WizardDemo.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,28 @@ class WizardDemo extends React.Component<React.HTMLProps<HTMLDivElement>, Wizard
238238
</Wizard>
239239
<br />
240240
<br />
241+
<Wizard id="inPageFocusTest" height={500}>
242+
<WizardStep name="A" id="inPageFocusTest-wizard-step-a">
243+
<p>inPageFocusTest Step 1</p>
244+
</WizardStep>
245+
<WizardStep
246+
name="B"
247+
id="inPageFocusTest-wizard-step-b"
248+
steps={[
249+
<WizardStep name="B-1" id="inPageFocusTest-wizard-step-b1" key="inPageFocusTest-wizard-step-b1">
250+
<p>inPageFocusTest Step 2</p>
251+
</WizardStep>,
252+
<WizardStep name="B-2" id="inPageFocusTest-wizard-step-b2" key="inPageFocusTest-wizard-step-b2">
253+
<p>inPageFocusTest Step 3</p>
254+
</WizardStep>
255+
]}
256+
/>
257+
<WizardStep name="C" id="inPageFocusTest-wizard-step-c">
258+
<p>inPageFocusTest Step 4</p>
259+
</WizardStep>
260+
</Wizard>
261+
<br />
262+
<br />
241263
<Button id="launchWizOverflow" variant="primary" onClick={this.handleRoleWizardToggle}>
242264
Show Modal with Overflow
243265
</Button>

0 commit comments

Comments
 (0)