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

Add ui test for downgrade plan selection #1958

Merged
merged 4 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
@@ -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]"),
Expand Down
27 changes: 27 additions & 0 deletions packages/files-ui/cypress/tests/subscription-plan-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,33 @@ 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 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()
Expand Down