-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix(lib): onClick is not updating currentStep if step is disabled #30 * test(project): Cover unit and E2E test for disabled step #30
- Loading branch information
1 parent
2750ad4
commit 9abd2ce
Showing
4 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
38 changes: 34 additions & 4 deletions
38
packages/headless-stepper-e2e/src/integration/HeadlessStepper/HeadlessStepper.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,37 @@ | ||
describe('headless-stepper: HeadlessStepper component', () => { | ||
beforeEach(() => cy.visit('/iframe.html?id=headlessstepper--primary')); | ||
|
||
it('should render the component', () => { | ||
cy.get('h1').should('contain', 'Welcome to HeadlessStepper!'); | ||
beforeEach(() => | ||
cy.visit('/iframe.html?id=headlessstepper-usestepper--use-stepper') | ||
); | ||
|
||
it('should render the component', () => { | ||
cy.get('h1').should('contain', 'Welcome to HeadlessStepper!'); | ||
}); | ||
|
||
it('should navigate by clicking on the menu unless it is disabled', () => { | ||
cy.get('p').should('contain.text', 'Current step: 0'); | ||
|
||
cy.get('ol > a').each((element) => { | ||
const { attributes, textContent } = element[0]; | ||
const [, step] = textContent.split(' '); | ||
|
||
const ariaDisabled = attributes.getNamedItem('aria-disabled'); | ||
const stepNumber = Number(step) - 1; // If step is called "Step 1" the index is 0 | ||
|
||
cy.wrap(element).click(); | ||
|
||
if (ariaDisabled) { | ||
/** | ||
* -1 means the step was not changed since it is disabled. | ||
*/ | ||
cy.get('p').should('contain.text', `Current step: ${stepNumber - 1}`); | ||
} else { | ||
cy.get('p').should('contain.text', `Current step: ${stepNumber}`); | ||
} | ||
|
||
// eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.wait(200); | ||
}); | ||
|
||
cy.get('p').should('contain.text', 'Current step: 5'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters