From 20d9575a9468a16a200935d68175d902d91f65bc Mon Sep 17 00:00:00 2001 From: Richard Kettelerij Date: Tue, 12 Nov 2024 13:48:05 +0100 Subject: [PATCH] chore(tiles): fix failing tests on CI --- tests/cypress/e2e/styles.cy.ts | 22 ++++++++++------------ tests/cypress/e2e/tiles.cy.ts | 10 ++++++++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/tests/cypress/e2e/styles.cy.ts b/tests/cypress/e2e/styles.cy.ts index b3b446af..ea396a72 100644 --- a/tests/cypress/e2e/styles.cy.ts +++ b/tests/cypress/e2e/styles.cy.ts @@ -1,5 +1,15 @@ describe('OGC API Styles tests', () => { + Cypress.on("window:before:load", () => { + /** + * Thankfully, Cypress searches for "jQuery" property on the state + * variable (cy), if that's present, it takes the precedence + * over window.$ + * https://github.com/cypress-io/cypress/blob/7.0-release/packages/driver/src/cy/jquery.js#L12 + */ + cy.state("jQuery", Cypress.$); + }); + it('styles page should have no a11y violations', () => { cy.visit('/styles') cy.injectAxe() @@ -13,12 +23,6 @@ describe('OGC API Styles tests', () => { it('styles page should have no broken links', () => { cy.visit('/styles') - - cy.on('window:before:load', (win) => { - if (win.jQuery === undefined && (win.$ === undefined || win.$ === {})) { - win.$ = Cypress.cy.$$; - } - }); cy.checkForBrokenLinks() }) @@ -35,12 +39,6 @@ describe('OGC API Styles tests', () => { it('style page should have no broken links', () => { cy.visit('/styles/dummy-style') - - cy.on('window:before:load', (win) => { - if (win.jQuery === undefined && (win.$ === undefined || win.$ === {})) { - win.$ = Cypress.cy.$$; - } - }); cy.checkForBrokenLinks() }) diff --git a/tests/cypress/e2e/tiles.cy.ts b/tests/cypress/e2e/tiles.cy.ts index ec7fa45a..1685459c 100644 --- a/tests/cypress/e2e/tiles.cy.ts +++ b/tests/cypress/e2e/tiles.cy.ts @@ -1,5 +1,15 @@ describe('OGC API Tiles tests', () => { + Cypress.on("window:before:load", () => { + /** + * Thankfully, Cypress searches for "jQuery" property on the state + * variable (cy), if that's present, it takes the precedence + * over window.$ + * https://github.com/cypress-io/cypress/blob/7.0-release/packages/driver/src/cy/jquery.js#L12 + */ + cy.state("jQuery", Cypress.$); + }); + it('dataset tiles page should have no a11y violations', () => { cy.visit('/tiles') cy.injectAxe()