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 checking invalid card details #1868

Merged
merged 4 commits into from
Jan 20, 2022
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
5 changes: 4 additions & 1 deletion packages/files-ui/cypress/fixtures/cardData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ export const visaCvc = "123"
export const visaExpiry = "12/30"
export const mastercardNumber = "5555555555554444"
export const mastercardCvc = "456"
export const mastercardExpiry = "01/31"
export const mastercardExpiry = "01/31"
export const invalidCardNumber = "6242424242424255"
export const invalidCvc = "11"
export const invalidExpiry = "02/21"
57 changes: 57 additions & 0 deletions packages/files-ui/cypress/tests/subscription-plan-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { navigationMenu } from "../support/page-objects/navigationMenu"
import { settingsPage } from "../support/page-objects/settingsPage"
import { addOrUpdateCardModal } from "../support/page-objects/modals/addOrUpdateCardModal"
import { invalidCardNumber, invalidExpiry, invalidCvc } from "../fixtures/cardData"
import { visaNumber, visaExpiry, visaCvc } from "../fixtures/cardData"
import { mastercardNumber, mastercardExpiry, mastercardCvc } from "../fixtures/cardData"
import { cardAddedToast } from "../support/page-objects/toasts/cardAddedToast"
Expand Down Expand Up @@ -80,6 +81,62 @@ describe("Subscription Plan", () => {
settingsPage.addCardButton().should("be.visible")
})

it("can not add an invalid card to the profile", () => {
cy.web3Login({ deleteCreditCard: true })

// navigate to settings
navigationMenu.settingsNavButton().click()
settingsPage.subscriptionTabButton().click()

// attempt to add card with invalid number
settingsPage.addCardButton()
.should("be.visible")
.click()
addOrUpdateCardModal.body().should("be.visible")
addOrUpdateCardModal.addCardHeader().should("be.visible")
addOrUpdateCardModal.awaitStripeElementReady()
addOrUpdateCardModal.cardNumberInput().type(invalidCardNumber)
addOrUpdateCardModal.expiryDateInput().type(visaExpiry)
addOrUpdateCardModal.cvcNumberInput().type(visaCvc)
addOrUpdateCardModal.addCardButton().click()

// ensure error is displayed and modal remains in view
addOrUpdateCardModal.cardErrorLabel().should("be.visible")
addOrUpdateCardModal.body().should("be.visible")

// attempt to add card with invalid expiry
addOrUpdateCardModal.cardNumberInput()
.type("{selectall}{del}")
.type(visaNumber)
addOrUpdateCardModal.expiryDateInput()
.type("{selectall}{del}")
.type(invalidExpiry)
addOrUpdateCardModal.cvcNumberInput()
.type("{selectall}{del}")
.type(visaCvc)
addOrUpdateCardModal.addCardButton().click()

// ensure error is displayed and modal remains in view
addOrUpdateCardModal.cardErrorLabel().should("be.visible")
addOrUpdateCardModal.body().should("be.visible")

// attempt to add card with invalid cvc
addOrUpdateCardModal.cardNumberInput()
.type("{selectall}{del}")
.type(visaNumber)
addOrUpdateCardModal.expiryDateInput()
.type("{selectall}{del}")
.type(visaExpiry)
addOrUpdateCardModal.cvcNumberInput()
.type("{selectall}{del}")
.type(invalidCvc)
addOrUpdateCardModal.addCardButton().click()

// ensure error is displayed and modal remains in view
addOrUpdateCardModal.cardErrorLabel().should("be.visible")
addOrUpdateCardModal.body().should("be.visible")
})

it("can select a subscription plan and view plan details", () => {
cy.web3Login()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ const AddCard = ({ onClose, onCardAdd, footerClassName, submitText, goBack }: IA
component="p"
variant="body1"
className={classes.error}
data-cy="label-add-card-error"
>
{cardAddError}
</Typography>
Expand Down