Skip to content

Commit

Permalink
try with custom function
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoinier committed Jun 7, 2024
1 parent a09b42e commit fb7c887
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/datahub-e2e/src/e2e/search.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions apps/datahub-e2e/src/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit fb7c887

Please sign in to comment.