From 98d3856b13c41bd9581d6ac948de21e1bbdef401 Mon Sep 17 00:00:00 2001 From: Olivia Guyot Date: Wed, 13 Dec 2023 16:28:19 +0100 Subject: [PATCH] fix(e2e): improve login command & remove useless clearCookies 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. --- apps/datahub-e2e/src/e2e/datasets.cy.ts | 1 - tools/e2e/commands.ts | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/datahub-e2e/src/e2e/datasets.cy.ts b/apps/datahub-e2e/src/e2e/datasets.cy.ts index f8e97ae8ab..d90c807231 100644 --- a/apps/datahub-e2e/src/e2e/datasets.cy.ts +++ b/apps/datahub-e2e/src/e2e/datasets.cy.ts @@ -2,7 +2,6 @@ import 'cypress-real-events' describe('datasets', () => { beforeEach(() => { - cy.clearCookies() cy.visit('/search') // aliases diff --git a/tools/e2e/commands.ts b/tools/e2e/commands.ts index 2e29d3b5d6..87860241d9 100644 --- a/tools/e2e/commands.ts +++ b/tools/e2e/commands.ts @@ -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() } ) @@ -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 || []