From 62a962eda6ff02efd83dd9092e87b8b3541808cc Mon Sep 17 00:00:00 2001 From: Andrew Snaith Date: Mon, 25 Oct 2021 16:55:12 -0700 Subject: [PATCH 1/2] Make intercepts in tests less version specific --- .../cypress/tests/file-preview-spec.ts | 2 +- .../cypress/tests/survey-banner-spec.ts | 23 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/files-ui/cypress/tests/file-preview-spec.ts b/packages/files-ui/cypress/tests/file-preview-spec.ts index ffe19a8ba7..6f2dc17cee 100644 --- a/packages/files-ui/cypress/tests/file-preview-spec.ts +++ b/packages/files-ui/cypress/tests/file-preview-spec.ts @@ -69,7 +69,7 @@ describe("File Preview", () => { homePage.uploadFile("../fixtures/uploadedFiles/file.zip") // setup an api intercepter for download requests - cy.intercept("POST", "https://stage.imploy.site/api/v1/bucket/*/download").as("downloadRequest").then(() => { + cy.intercept("POST", "**/bucket/*/download").as("downloadRequest").then(() => { homePage.fileItemName().dblclick() previewModal.unsupportedFileLabel().should("exist") previewModal.downloadUnsupportedFileButton().should("be.visible") diff --git a/packages/files-ui/cypress/tests/survey-banner-spec.ts b/packages/files-ui/cypress/tests/survey-banner-spec.ts index ba13369114..c11685ddb7 100644 --- a/packages/files-ui/cypress/tests/survey-banner-spec.ts +++ b/packages/files-ui/cypress/tests/survey-banner-spec.ts @@ -1,5 +1,6 @@ import { profileCreatedDate } from "../fixtures/filesTestData" import { homePage } from "../support/page-objects/homePage" +import { DISMISSED_SURVEY_KEY } from "../../../../packages/files-ui/src/Components/SurveyBanner" describe("Survey Banner", () => { @@ -7,22 +8,22 @@ describe("Survey Banner", () => { it("User can view and dismiss the survey banner", () => { // intercept and stub the account creation date to be > 7 days - cy.intercept("GET", "https://stage.imploy.site/api/v1/user/profile", (req) => { + cy.intercept("GET", "**/user/profile", (req) => { req.on("response", (res) => { - res.body.created_at = profileCreatedDate + res.body.created_at = profileCreatedDate }) }) // intercept and stub the response to ensure the banner is displayed - cy.intercept("GET", "https://stage.imploy.site/api/v1/user/store", { - body: [{ "csf.dismissedSurveyBannerV3": "false" }] + cy.intercept("GET", "**/user/store", { + body: [{ [`${DISMISSED_SURVEY_KEY}`]: "false" }] }) cy.web3Login() homePage.surveyBanner().should("be.visible") // set up a spy for the POST response - cy.intercept("POST", "https://stage.imploy.site/api/v1/user/store").as("storePost").then(() => { + cy.intercept("POST", "**/user/store").as("storePost").then(() => { // dismiss the survey banner homePage.closeBannerButton().click() @@ -30,14 +31,14 @@ describe("Survey Banner", () => { // intercept POST to ensure the key was updated after the banner is dismissed cy.wait("@storePost").its("request.body").should("contain", { - "csf.dismissedSurveyBannerV3": "true" + [`${DISMISSED_SURVEY_KEY}`]: "true" }) }) }) it("User should not see the survey banner if previously dismissed", () => { - cy.intercept("GET", "https://stage.imploy.site/api/v1/user/store", { - body: [{ "csf.dismissedSurveyBannerV3": "true" }] + cy.intercept("GET", "**/user/store", { + body: [{ [`${DISMISSED_SURVEY_KEY}`]: "true" }] }) cy.web3Login() @@ -45,7 +46,7 @@ describe("Survey Banner", () => { }) it("User should see banner if account age is greater than 7 days and api response is empty", () => { - cy.intercept("GET", "https://stage.imploy.site/api/v1/user/store", { + cy.intercept("GET", "**/user/store", { body: [{}] }) @@ -55,13 +56,13 @@ describe("Survey Banner", () => { it("User should not see banner if account age is less than 7 days and api response is empty", () => { // intercept and stub the account creation date to make it less than 7 days - cy.intercept("GET", "https://stage.imploy.site/api/v1/user/profile", (req) => { + cy.intercept("GET", "**/user/profile", (req) => { req.on("response", (res) => { res.body.created_at = res.body.updated_at }) }) - cy.intercept("GET", "https://stage.imploy.site/api/v1/user/store", { + cy.intercept("GET", "**/user/store", { body: [{}] }) From b84b332fc726869fa2bafaa84fe2568a7290139e Mon Sep 17 00:00:00 2001 From: Andrew Snaith Date: Wed, 27 Oct 2021 11:00:48 -0700 Subject: [PATCH 2/2] finalize changes to survey banner tests --- .../files-ui/cypress/tests/survey-banner-spec.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/files-ui/cypress/tests/survey-banner-spec.ts b/packages/files-ui/cypress/tests/survey-banner-spec.ts index c11685ddb7..fb66f27708 100644 --- a/packages/files-ui/cypress/tests/survey-banner-spec.ts +++ b/packages/files-ui/cypress/tests/survey-banner-spec.ts @@ -1,9 +1,10 @@ import { profileCreatedDate } from "../fixtures/filesTestData" import { homePage } from "../support/page-objects/homePage" -import { DISMISSED_SURVEY_KEY } from "../../../../packages/files-ui/src/Components/SurveyBanner" describe("Survey Banner", () => { + const dismissedSurveyKey = "csf.dismissedSurveyBannerV3" + context("desktop", () => { it("User can view and dismiss the survey banner", () => { @@ -16,7 +17,7 @@ describe("Survey Banner", () => { // intercept and stub the response to ensure the banner is displayed cy.intercept("GET", "**/user/store", { - body: [{ [`${DISMISSED_SURVEY_KEY}`]: "false" }] + body: { [dismissedSurveyKey]: "false" } }) cy.web3Login() @@ -31,14 +32,14 @@ describe("Survey Banner", () => { // intercept POST to ensure the key was updated after the banner is dismissed cy.wait("@storePost").its("request.body").should("contain", { - [`${DISMISSED_SURVEY_KEY}`]: "true" + [dismissedSurveyKey]: "true" }) }) }) it("User should not see the survey banner if previously dismissed", () => { cy.intercept("GET", "**/user/store", { - body: [{ [`${DISMISSED_SURVEY_KEY}`]: "true" }] + body: { [dismissedSurveyKey]: "true" } }) cy.web3Login() @@ -47,7 +48,7 @@ describe("Survey Banner", () => { it("User should see banner if account age is greater than 7 days and api response is empty", () => { cy.intercept("GET", "**/user/store", { - body: [{}] + body: {} }) cy.web3Login() @@ -63,7 +64,7 @@ describe("Survey Banner", () => { }) cy.intercept("GET", "**/user/store", { - body: [{}] + body: {} }) cy.web3Login()