From b664b0272aaaf02f0b268b66094aea559ff2e782 Mon Sep 17 00:00:00 2001 From: Simen Fivelstad Smaaberg <66635118+simensma-fresh@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:40:08 +0000 Subject: [PATCH] Fixed cypress tests --- .../core-web/cypress/e2e/majorprojects.cy.ts | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/services/core-web/cypress/e2e/majorprojects.cy.ts b/services/core-web/cypress/e2e/majorprojects.cy.ts index 55beab3c03..acc780a53c 100644 --- a/services/core-web/cypress/e2e/majorprojects.cy.ts +++ b/services/core-web/cypress/e2e/majorprojects.cy.ts @@ -90,28 +90,37 @@ describe("Major Projects", () => { }); }); - // Intercept the GET request and stub the response - cy.intercept("GET", "**/documents**", (req) => { - // Set the desired response properties - req.reply({ - statusCode: 301, - body: "Mocked response data", - }); - }).as("downloadRequest"); + cy.wait(2500); cy.get("[data-cy=menu-actions-button]") .last() .click({ force: true }); - // Click the Download file button in the dropdown - cy.contains("button", "Download file", { timeout: 3000 }) - .find("div") - .click({ force: true }); - // Wait for the network request to complete - cy.wait("@downloadRequest").then((interception) => { - // Check that the download request was made successfully - expect(interception.response.statusCode).to.equal(301); + cy.intercept( + "GET", + /.*\/download-token\/332d6f13-cd09-4b55-93d7-52bd7e557fa4$/, + { + statusCode: 200, + body: { + token_guid: "ec851412-9c91-48cd-8917-dd58f0934b16" + }, + } + ); + + + cy.window().then((win) => { + cy.stub(win, 'open').as('windowOpen'); + // Click the Download file button in the dropdown + cy.contains("button", "Download file", { timeout: 3000 }) + .find("div") + .click({ force: true }); + + cy.get('@windowOpen').should('be.called'); // Make sure PDF is opened in new window. }); + + + + }); });