Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(e2e): more resilient version of visit('/') #10128

Merged
merged 1 commit into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions cypress/e2e/basic.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ describe('Before setup instance', () => {
});

it('successfully loads', () => {
cy.visit('/');
cy.visitHome();
});

it('setup instance', () => {
cy.visit('/');
cy.visitHome();

cy.intercept('POST', '/api/admin/accounts/create').as('signup');

cy.get('[data-cy-admin-username] input').type('admin');
cy.get('[data-cy-admin-password] input').type('admin1234');
cy.get('[data-cy-admin-ok]').click();
Expand All @@ -43,11 +43,11 @@ describe('After setup instance', () => {
});

it('successfully loads', () => {
cy.visit('/');
cy.visitHome();
});

it('signup', () => {
cy.visit('/');
cy.visitHome();

cy.intercept('POST', '/api/signup').as('signup');

Expand Down Expand Up @@ -79,11 +79,11 @@ describe('After user signup', () => {
});

it('successfully loads', () => {
cy.visit('/');
cy.visitHome();
});

it('signin', () => {
cy.visit('/');
cy.visitHome();

cy.intercept('POST', '/api/signin').as('signin');

Expand All @@ -101,7 +101,7 @@ describe('After user signup', () => {
userId: this.alice.id,
});

cy.visit('/');
cy.visitHome();

cy.get('[data-cy-signin]').click();
cy.get('[data-cy-signin-username] input').type('alice');
Expand Down
7 changes: 6 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

Cypress.Commands.add('visitHome', () => {
cy.visit('/');
cy.get('button', { timeout: 30000 }).should('be.visible');
})

Cypress.Commands.add('resetState', () => {
cy.window(win => {
win.indexedDB.deleteDatabase('keyval-store');
Expand All @@ -43,7 +48,7 @@ Cypress.Commands.add('registerUser', (username, password, isAdmin = false) => {
});

Cypress.Commands.add('login', (username, password) => {
cy.visit('/');
cy.visitHome();

cy.intercept('POST', '/api/signin').as('signin');

Expand Down