Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make intercepts in tests less version specific #1658

Merged
merged 4 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/files-ui/cypress/tests/file-preview-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
28 changes: 15 additions & 13 deletions packages/files-ui/cypress/tests/survey-banner-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,52 @@ import { homePage } from "../support/page-objects/homePage"

describe("Survey Banner", () => {

const dismissedSurveyKey = "csf.dismissedSurveyBannerV3"

context("desktop", () => {

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: { [dismissedSurveyKey]: "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()
homePage.surveyBanner().should("not.exist")

// intercept POST to ensure the key was updated after the banner is dismissed
cy.wait("@storePost").its("request.body").should("contain", {
"csf.dismissedSurveyBannerV3": "true"
[dismissedSurveyKey]: "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: { [dismissedSurveyKey]: "true" }
})

cy.web3Login()
homePage.surveyBanner().should("not.exist")
})

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", {
body: [{}]
cy.intercept("GET", "**/user/store", {
body: {}
})

cy.web3Login()
Expand All @@ -55,14 +57,14 @@ 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", {
body: [{}]
cy.intercept("GET", "**/user/store", {
body: {}
})

cy.web3Login()
Expand Down