-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2df5d00
commit f625b52
Showing
7 changed files
with
64 additions
and
32 deletions.
There are no files selected for viewing
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,4 +1,7 @@ | ||
{ | ||
"video": false, | ||
"baseUrl": "http://localhost:5000" | ||
"baseUrl": "http://localhost:5000", | ||
"ignoreTestFiles": [ | ||
"**/utils.js" | ||
] | ||
} |
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,18 +1,17 @@ | ||
import { shouldBeHidden, shouldBeVisible } from './utils' | ||
|
||
describe('Alert Dialog', () => { | ||
before(() => cy.visit('/tests/alert-dialog')) | ||
|
||
it('should prevent closing the dialog with escape', () => { | ||
cy.get('[data-a11y-dialog-show="my-accessible-dialog"]').first().click() | ||
cy.get('.dialog').should('not.have.attr', 'aria-hidden') | ||
cy.get('.dialog-content').should('be.visible') | ||
cy.get('.dialog').then(shouldBeVisible) | ||
cy.get('body').trigger('keydown', { keyCode: 27, which: 27 }) | ||
cy.get('.dialog').should('not.have.attr', 'aria-hidden') | ||
cy.get('.dialog-content').should('be.visible') | ||
cy.get('.dialog').then(shouldBeVisible) | ||
}) | ||
|
||
it('should prevent closing by clicking the backdrop', () => { | ||
cy.get('.dialog-overlay').click({ force: true }) | ||
cy.get('.dialog').should('not.have.attr', 'aria-hidden') | ||
cy.get('.dialog-content').should('be.visible') | ||
cy.get('.dialog').then(shouldBeVisible) | ||
}) | ||
}) |
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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export function shouldBeVisible($subject) { | ||
Cypress.log({ | ||
displayName: 'visible', | ||
name: 'shouldBeVisible', | ||
message: 'The dialog should be visible', | ||
consoleProps: () => ({ $el: $subject }), | ||
}) | ||
|
||
cy.wrap($subject, { log: false }).should('not.have.attr', 'aria-hidden') | ||
cy.wrap($subject, { log: false }) | ||
.find('.dialog-content', { log: false }) | ||
.should('be.visible') | ||
.and('have.attr', 'open') | ||
} | ||
|
||
export function shouldBeHidden($subject) { | ||
Cypress.log({ | ||
displayName: 'hidden', | ||
name: 'shouldBeHidden', | ||
message: 'The dialog should be hidden', | ||
consoleProps: () => ({ $el: $subject }), | ||
}) | ||
|
||
cy.wrap($subject, { log: false }) | ||
.should('have.attr', 'aria-hidden', 'true') | ||
.find('.dialog-overlay', { log: false }) | ||
.should('not.be.visible') | ||
cy.wrap($subject, { log: false }) | ||
.find('.dialog-content', { log: false }) | ||
.should('not.be.visible') | ||
} |
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