From ed01b64b1bb4579ae1c6b87ac6dd327b745c2fab Mon Sep 17 00:00:00 2001 From: Miguel Angel Medinilla Luque Date: Thu, 28 Sep 2023 10:39:18 +0200 Subject: [PATCH] cypress: Replace obsolete Cypress.Cookies.preserveOnce --- .github/workflows/integration-tests.yml | 6 +++--- cypress/e2e/finding_aid.cy.js | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 75e2207281..ee1be4d23d 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -91,10 +91,10 @@ jobs: sudo rm -f /etc/nginx/sites-enabled/default sudo nginx -t sudo systemctl restart nginx - - name: Create and set permissions /home/runner/work/atom/atom/cypress/screenshots + - name: Create writable Cypress videos and screenshots dirs run: | - sudo mkdir /home/runner/work/atom/atom/cypress/screenshots - sudo chmod a=rwx /home/runner/work/atom/atom/cypress/screenshots + sudo mkdir -p ${{ github.workspace }}/cypress/screenshots ${{ github.workspace }}/cypress/videos + sudo chmod a=rwx ${{ github.workspace }}/cypress/screenshots ${{ github.workspace }}/cypress/videos - name: Run tests env: BROWSER: ${{ matrix.browser }} diff --git a/cypress/e2e/finding_aid.cy.js b/cypress/e2e/finding_aid.cy.js index 89d01d5be2..bed2ac0edc 100644 --- a/cypress/e2e/finding_aid.cy.js +++ b/cypress/e2e/finding_aid.cy.js @@ -24,21 +24,30 @@ describe( }) }) + beforeEach(() => { // Preserve authentication cookies between tests cy.getCookies().then((cookies) => { const cookiesToPreserve = ['atom_authenticated', 'symfony']; + const preservePromises = []; + cookiesToPreserve.forEach((cookieName) => { const cookie = cookies.find((c) => c.name === cookieName); if (cookie) { - cy.setCookie(cookie.name, cookie.value, { - // Add any additional options if needed - // For example, { domain: 'example.com' } - }); + preservePromises.push( + cy.setCookie(cookie.name, cookie.value, { + // Add any additional options if needed + // For example, { domain: 'example.com' } + }) + ); } }); + + // Wait for all setCookie promises to complete before proceeding + return Promise.all(preservePromises); }); - }) + }); + it('Disables finding aids', () => { cy.visit('settings/findingAid')