From 3ab7a2d2a42578bf9d07d9602aa88578e917a02d Mon Sep 17 00:00:00 2001 From: Andrew Snaith Date: Thu, 17 Feb 2022 22:07:31 -0800 Subject: [PATCH 1/2] add new test for downgrade plan selection --- .../modals/billing/selectPlanModal.ts | 1 + .../cypress/tests/subscription-plan-spec.ts | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/packages/files-ui/cypress/support/page-objects/modals/billing/selectPlanModal.ts b/packages/files-ui/cypress/support/page-objects/modals/billing/selectPlanModal.ts index c933549121..965005fde3 100644 --- a/packages/files-ui/cypress/support/page-objects/modals/billing/selectPlanModal.ts +++ b/packages/files-ui/cypress/support/page-objects/modals/billing/selectPlanModal.ts @@ -1,5 +1,6 @@ export const selectPlanModal = { body: () => cy.get("[data-testid=modal-container-select]", { timeout: 10000 }), + closeButton: () => cy.get("[data-testid=button-close-modal-container-select]"), planBoxContainer: () => cy.get("[data-cy=container-plan-box]", { timeout: 10000 }), switchPlanHeader: () => cy.get("[data-cy=header-switch-plan]"), selectPlanButton: () => cy.get("[data-testid=button-select-plan]"), diff --git a/packages/files-ui/cypress/tests/subscription-plan-spec.ts b/packages/files-ui/cypress/tests/subscription-plan-spec.ts index 4a35dfc872..fc2c765b0a 100644 --- a/packages/files-ui/cypress/tests/subscription-plan-spec.ts +++ b/packages/files-ui/cypress/tests/subscription-plan-spec.ts @@ -210,6 +210,40 @@ describe("Subscription Plan", () => { selectPlanModal.body().should("be.visible") }) + it("cannot downgrade if used storage exceeds plan allowance", () => { + cy.web3Login({ deleteCreditCard: true, resetToFreePlan: true }) + + // upgrade to a premium plan first + navigationMenu.settingsNavButton().click() + settingsPage.upgradeSubscription("premium") + + // setup intercepter, stub the used storage value to be higher + cy.intercept("GET", "**/buckets/summary", (req) => { + req.on("response", (res) => { + res.body.used_storage = "9704775608" + }) + }) + + // setup intercepter, stub the used products response to disallow update + cy.intercept("GET", "**/billing/products", (req) => { + req.on("response", (res) => { + res.body = [{ "prices": [{ "is_update_allowed": false }] }] + }) + }) + + settingsPage.changePlanButton().click() + selectPlanModal.body().should("be.visible") + selectPlanModal.planBoxContainer().should("have.length.greaterThan", 0) + + // ensure warning is shown and the free plan is not selectable + cy.get("@freePlanBox").parent().within(() => { + selectPlanModal.storageCapacityWarningLabel().should("be.visible") + selectPlanModal.selectPlanButton() + .should("be.visible") + .should("be.disabled") + }) + }) + it("can toggle between monthly and annual billing price", () => { cy.web3Login({ deleteCreditCard: true, resetToFreePlan: true }) navigationMenu.settingsNavButton().click() From 9473b36d2a5c7fb0f6cbca5c4a1b3945b31a0608 Mon Sep 17 00:00:00 2001 From: Andrew Snaith Date: Fri, 18 Feb 2022 10:20:50 -0800 Subject: [PATCH 2/2] Remove unnecessary stub as per PR feedback Co-authored-by: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com> --- packages/files-ui/cypress/tests/subscription-plan-spec.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/files-ui/cypress/tests/subscription-plan-spec.ts b/packages/files-ui/cypress/tests/subscription-plan-spec.ts index 25f4047fa9..d400f25ee3 100644 --- a/packages/files-ui/cypress/tests/subscription-plan-spec.ts +++ b/packages/files-ui/cypress/tests/subscription-plan-spec.ts @@ -221,13 +221,6 @@ describe("Subscription Plan", () => { navigationMenu.settingsNavButton().click() settingsPage.upgradeSubscription("premium") - // setup intercepter, stub the used storage value to be higher - cy.intercept("GET", "**/buckets/summary", (req) => { - req.on("response", (res) => { - res.body.used_storage = "9704775608" - }) - }) - // setup intercepter, stub the used products response to disallow update cy.intercept("GET", "**/billing/products", (req) => { req.on("response", (res) => {