Skip to content

Commit

Permalink
fix(e2e): improve login command & remove useless clearCookies
Browse files Browse the repository at this point in the history
The login command now returns a Cypress chain; this means that everything after
it will be executed after it's done; this will prevent race conditions

Cookies are cleaned between every run.
  • Loading branch information
jahow committed Dec 13, 2023
1 parent 1c892f0 commit 2ec4def
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion apps/datahub-e2e/src/e2e/datasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'cypress-real-events'

describe('datasets', () => {
beforeEach(() => {
cy.clearCookies()
cy.visit('/search')

// aliases
Expand Down
7 changes: 5 additions & 2 deletions tools/e2e/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ Cypress.Commands.add(
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
followRedirect: false,
})
})
if (redirect) cy.visit('/')
if (redirect) return cy.visit('/')
else return cy.window()
}
)

Expand Down Expand Up @@ -75,7 +77,8 @@ Cypress.Commands.add('clearFavorites', () => {
.as('favoritesId')
})

cy.getCookie('XSRF-TOKEN')
return cy
.getCookie('XSRF-TOKEN')
.its('value')
.then(function (token) {
const favoritesId = this.favoritesId || []
Expand Down

0 comments on commit 2ec4def

Please sign in to comment.