From fb7c887bad68ab680c44f8b191340265fa99a931 Mon Sep 17 00:00:00 2001 From: Camille Moinier Date: Fri, 7 Jun 2024 10:30:08 +0200 Subject: [PATCH] try with custom function --- apps/datahub-e2e/src/e2e/search.cy.ts | 2 +- apps/datahub-e2e/src/support/commands.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/datahub-e2e/src/e2e/search.cy.ts b/apps/datahub-e2e/src/e2e/search.cy.ts index 681e32f2..5a534945 100644 --- a/apps/datahub-e2e/src/e2e/search.cy.ts +++ b/apps/datahub-e2e/src/e2e/search.cy.ts @@ -94,7 +94,7 @@ describe('search', () => { cy.intercept('PUT', '**/geonetwork/srv/api/userselections/**').as( 'addFavoriteRequest' ) - if (!cy.get('mel-datahub-results-card-favorite')) { + if (!cy.doesElementExist('mel-datahub-results-card-favorite')) { cy.clearFavorites() cy.get('mel-datahub-results-card-search') .eq(1) diff --git a/apps/datahub-e2e/src/support/commands.ts b/apps/datahub-e2e/src/support/commands.ts index 8ddac829..39628765 100644 --- a/apps/datahub-e2e/src/support/commands.ts +++ b/apps/datahub-e2e/src/support/commands.ts @@ -17,9 +17,19 @@ declare namespace Cypress { login(username?: string, password?: string, redirect?: boolean) signOut(): void clearFavorites() + doesElementExist(element: string): boolean } } +Cypress.Commands.add('doesElementExist', (element) => { + + cy.window().then((win) => { + const identifiedElement = win.document.querySelector(element) + return identifiedElement + }); +}) + + Cypress.Commands.add( 'login', (username = 'admin', password = 'admin', redirect = false) => {