Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create E2E suite to test on real browser (#449)
- Loading branch information
Showing
9 changed files
with
666 additions
and
17 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
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 @@ | ||
{} |
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,68 @@ | ||
/// <reference types="cypress" /> | ||
|
||
describe('simple modal', () => { | ||
beforeEach(() => { | ||
cy.visit('http://localhost:3000/examples'); | ||
// Page is heavy to load so we wait for it to be loaded | ||
cy.wait(500); | ||
}); | ||
|
||
it('should open modal when clicking open button', () => { | ||
cy.get('button').eq(2).click(); | ||
cy.get('[data-testid=modal]').should('exist'); | ||
}); | ||
|
||
// TODO overlay not working, see how to fix | ||
// it('should close modal when clicking overlay', () => { | ||
// cy.get('button').eq(2).click(); | ||
// cy.get('[data-testid=overlay]').click(); | ||
// cy.get('[data-testid=modal]').should('not.exist'); | ||
// }); | ||
|
||
it('should close modal when clicking the close icon', () => { | ||
cy.get('button').eq(2).click(); | ||
cy.get('[data-testid=close-button]').click(); | ||
cy.get('[data-testid=modal]').should('not.exist'); | ||
}); | ||
|
||
it('should close modal when pressing esc key', () => { | ||
cy.get('button').eq(2).click(); | ||
cy.get('body').type('{esc}'); | ||
cy.get('[data-testid=modal]').should('not.exist'); | ||
}); | ||
|
||
it('should close only last modal when pressing esc key when multiple modals are opened', () => { | ||
cy.get('button').eq(8).click(); | ||
cy.get('[data-testid=modal] button').eq(0).click(); | ||
cy.get('[data-testid=modal]').should('have.length', 2); | ||
cy.get('body').type('{esc}'); | ||
cy.get('[data-testid=modal]').should('have.length', 1); | ||
cy.get('body').type('{esc}'); | ||
cy.get('[data-testid=modal]').should('not.exist'); | ||
}); | ||
|
||
it('should block the scroll when modal is opened', () => { | ||
cy.get('button').eq(2).click(); | ||
cy.get('html').should('have.css', 'position', 'fixed'); | ||
}); | ||
|
||
it('should unblock the scroll when modal is closed', () => { | ||
cy.get('button').eq(2).click(); | ||
cy.get('html').should('have.css', 'position', 'fixed'); | ||
cy.get('body').type('{esc}'); | ||
cy.get('html').should('not.have.css', 'position', 'fixed'); | ||
}); | ||
|
||
it('should unblock scroll only after last modal is closed when multiple modals are opened', () => { | ||
cy.get('button').eq(8).click(); | ||
cy.get('[data-testid=modal] button').eq(0).click(); | ||
cy.get('[data-testid=modal]').should('have.length', 2); | ||
cy.get('html').should('have.css', 'position', 'fixed'); | ||
cy.get('body').type('{esc}'); | ||
cy.get('[data-testid=modal]').should('have.length', 1); | ||
cy.get('html').should('have.css', 'position', 'fixed'); | ||
cy.get('body').type('{esc}'); | ||
cy.get('[data-testid=modal]').should('not.exist'); | ||
cy.get('html').should('not.have.css', 'position', 'fixed'); | ||
}); | ||
}); |
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,21 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
/** | ||
* @type {Cypress.PluginConfig} | ||
*/ | ||
module.exports = (on, config) => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
} |
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,25 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add("login", (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) |
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,20 @@ | ||
// *********************************************************** | ||
// This example support/index.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
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,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["es5", "dom"], | ||
"types": ["cypress"] | ||
}, | ||
"include": ["**/*.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
Oops, something went wrong.