-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(cypress): add corner cases #5481
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4405dc8
feat(cypress): add corner cases
pixincreate 2e7c0b3
refactor(cypress): check if error in response body is string or an ob…
pixincreate ee1442e
refactor(cypress): add `payment_method` to all configs since it is no…
pixincreate 8cbfa67
enhancement(cypress): add configs for edge case scenarios
pixincreate 6fdacd3
Merge branch 'main' of github.com:juspay/hyperswitch into variation-c…
pixincreate e43e2a4
enhancement: add a retrieve call to make it not fail not nmi
pixincreate 20604c4
refactor: skip tests if fail. useful for iatapay since card is unsupp…
pixincreate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
325 changes: 325 additions & 0 deletions
325
cypress-tests/cypress/e2e/PaymentTest/00020-Variations.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,325 @@ | ||
import * as fixtures from "../../fixtures/imports"; | ||
import State from "../../utils/State"; | ||
import getConnectorDetails, * as utils from "../PaymentUtils/Utils"; | ||
|
||
let globalState; | ||
let paymentIntentBody; | ||
let paymentCreateConfirmBody; | ||
|
||
describe("Corner cases", () => { | ||
// This is needed to get flush out old data | ||
beforeEach("seed global state", () => { | ||
paymentIntentBody = Cypress._.cloneDeep(fixtures.createPaymentBody); | ||
paymentCreateConfirmBody = Cypress._.cloneDeep( | ||
fixtures.createConfirmPaymentBody | ||
); | ||
}); | ||
|
||
context("[Payment] [Payment create] Invalid Card Info", () => { | ||
before("seed global state", () => { | ||
cy.task("getGlobalState").then((state) => { | ||
globalState = new State(state); | ||
}); | ||
}); | ||
|
||
after("flush global state", () => { | ||
cy.task("setGlobalState", globalState.data); | ||
}); | ||
|
||
it("[Payment create] Invalid card number", () => { | ||
let data = getConnectorDetails(globalState.get("commons"))["card_pm"][ | ||
"invalidCardNumber" | ||
]; | ||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
|
||
cy.createConfirmPaymentTest( | ||
paymentIntentBody, | ||
req_data, | ||
res_data, | ||
"three_ds", | ||
"automatic", | ||
globalState | ||
); | ||
}); | ||
|
||
it("[Payment create] Invalid expiry month", () => { | ||
let data = getConnectorDetails(globalState.get("commons"))["card_pm"][ | ||
"invalidExpiryMonth" | ||
]; | ||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
|
||
cy.createConfirmPaymentTest( | ||
paymentIntentBody, | ||
req_data, | ||
res_data, | ||
"three_ds", | ||
"automatic", | ||
globalState | ||
); | ||
}); | ||
|
||
it("[Payment create] Invalid expiry year", () => { | ||
let data = getConnectorDetails(globalState.get("commons"))["card_pm"][ | ||
"invalidExpiryYear" | ||
]; | ||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
|
||
cy.createConfirmPaymentTest( | ||
paymentIntentBody, | ||
req_data, | ||
res_data, | ||
"three_ds", | ||
"automatic", | ||
globalState | ||
); | ||
}); | ||
|
||
it("[Payment create] Invalid card CVV", () => { | ||
let data = getConnectorDetails(globalState.get("commons"))["card_pm"][ | ||
"invalidCardCvv" | ||
]; | ||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
|
||
cy.createConfirmPaymentTest( | ||
paymentIntentBody, | ||
req_data, | ||
res_data, | ||
"three_ds", | ||
"automatic", | ||
globalState | ||
); | ||
}); | ||
}); | ||
|
||
context("[Payment] Confirm w/o PMD", () => { | ||
before("seed global state", () => { | ||
cy.task("getGlobalState").then((state) => { | ||
globalState = new State(state); | ||
}); | ||
}); | ||
|
||
after("flush global state", () => { | ||
cy.task("setGlobalState", globalState.data); | ||
}); | ||
|
||
it("Create payment intent", () => { | ||
let data = getConnectorDetails(globalState.get("commons"))["card_pm"][ | ||
"PaymentIntent" | ||
]; | ||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
|
||
cy.createPaymentIntentTest( | ||
paymentIntentBody, | ||
req_data, | ||
res_data, | ||
"no_three_ds", | ||
"automatic", | ||
globalState | ||
); | ||
}); | ||
|
||
it("Confirm payment intent", () => { | ||
let data = getConnectorDetails(globalState.get("commons"))["card_pm"][ | ||
"PaymentIntentErrored" | ||
]; | ||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
|
||
cy.confirmCallTest( | ||
fixtures.confirmBody, | ||
req_data, | ||
res_data, | ||
true, | ||
globalState | ||
); | ||
}); | ||
}); | ||
|
||
context("[Payment] Capture greater amount", () => { | ||
let should_continue = true; // variable that will be used to skip tests if a previous test fails | ||
|
||
before("seed global state", () => { | ||
cy.task("getGlobalState").then((state) => { | ||
globalState = new State(state); | ||
}); | ||
}); | ||
|
||
after("flush global state", () => { | ||
cy.task("setGlobalState", globalState.data); | ||
}); | ||
|
||
beforeEach(function () { | ||
if (!should_continue) { | ||
this.skip(); | ||
} | ||
}); | ||
|
||
it("Create payment intent", () => { | ||
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ | ||
"No3DSManualCapture" | ||
]; | ||
|
||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
|
||
cy.createConfirmPaymentTest( | ||
paymentCreateConfirmBody, | ||
req_data, | ||
res_data, | ||
"no_three_ds", | ||
"manual", | ||
globalState | ||
); | ||
|
||
if (should_continue) | ||
should_continue = utils.should_continue_further(res_data); | ||
}); | ||
|
||
it("Capture call", () => { | ||
let data = getConnectorDetails(globalState.get("commons"))["card_pm"][ | ||
"CaptureGreaterAmount" | ||
]; | ||
|
||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
|
||
cy.captureCallTest( | ||
fixtures.captureBody, | ||
req_data, | ||
res_data, | ||
65000, | ||
globalState | ||
); | ||
|
||
if (should_continue) | ||
should_continue = utils.should_continue_further(res_data); | ||
}); | ||
}); | ||
|
||
context("[Payment] Capture successful payment", () => { | ||
let should_continue = true; // variable that will be used to skip tests if a previous test fails | ||
|
||
before("seed global state", () => { | ||
cy.task("getGlobalState").then((state) => { | ||
globalState = new State(state); | ||
}); | ||
}); | ||
|
||
after("flush global state", () => { | ||
cy.task("setGlobalState", globalState.data); | ||
}); | ||
|
||
beforeEach(function () { | ||
if (!should_continue) { | ||
this.skip(); | ||
} | ||
}); | ||
|
||
it("Create payment intent", () => { | ||
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ | ||
"No3DSAutoCapture" | ||
]; | ||
|
||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
|
||
cy.createConfirmPaymentTest( | ||
paymentCreateConfirmBody, | ||
req_data, | ||
res_data, | ||
"no_three_ds", | ||
"automatic", | ||
globalState | ||
); | ||
|
||
if (should_continue) | ||
should_continue = utils.should_continue_further(res_data); | ||
}); | ||
|
||
it("Retrieve payment", () => { | ||
cy.retrievePaymentCallTest(globalState); | ||
}); | ||
|
||
it("Capture call", () => { | ||
let data = getConnectorDetails(globalState.get("commons"))["card_pm"][ | ||
"CaptureCapturedAmount" | ||
]; | ||
|
||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
|
||
cy.captureCallTest( | ||
fixtures.captureBody, | ||
req_data, | ||
res_data, | ||
65000, | ||
globalState | ||
); | ||
|
||
if (should_continue) | ||
should_continue = utils.should_continue_further(res_data); | ||
}); | ||
}); | ||
|
||
context("[Payment] Void successful payment", () => { | ||
let should_continue = true; // variable that will be used to skip tests if a previous test fails | ||
|
||
before("seed global state", () => { | ||
cy.task("getGlobalState").then((state) => { | ||
globalState = new State(state); | ||
}); | ||
}); | ||
|
||
after("flush global state", () => { | ||
cy.task("setGlobalState", globalState.data); | ||
}); | ||
|
||
beforeEach(function () { | ||
if (!should_continue) { | ||
this.skip(); | ||
} | ||
}); | ||
|
||
it("Create payment intent", () => { | ||
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ | ||
"No3DSAutoCapture" | ||
]; | ||
|
||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
|
||
cy.createConfirmPaymentTest( | ||
paymentCreateConfirmBody, | ||
req_data, | ||
res_data, | ||
"no_three_ds", | ||
"automatic", | ||
globalState | ||
); | ||
|
||
if (should_continue) | ||
should_continue = utils.should_continue_further(res_data); | ||
}); | ||
|
||
it("Retrieve payment", () => { | ||
cy.retrievePaymentCallTest(globalState); | ||
}); | ||
|
||
it("Void call", () => { | ||
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ | ||
"VoidErrored" | ||
]; | ||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
cy.voidCallTest(fixtures.voidBody, req_data, res_data, globalState); | ||
|
||
if (should_continue) | ||
should_continue = utils.should_continue_further(res_data); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
commons
in here is intentional since we expect these to run against regardless of connector