-
Notifications
You must be signed in to change notification settings - Fork 60
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
test: add 3DS flow E2E test for card payments for Adyen connector #754
base: main
Are you sure you want to change the base?
test: add 3DS flow E2E test for card payments for Adyen connector #754
Conversation
… connector 3DS flow e2e test
Changed Files
|
@@ -15,7 +15,7 @@ | |||
"author": "juspay/hyperswitch-web-sdk", | |||
"license": "ISC", | |||
"devDependencies": { | |||
"cypress": "^13.13.2", | |||
"cypress": "^13.15.1", |
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.
"cypress": "^13.15.1", | |
"cypress": "^13.13.2", |
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.
This change is not needed
@@ -15,7 +15,7 @@ | |||
"author": "juspay/hyperswitch-web-sdk", | |||
"license": "ISC", | |||
"devDependencies": { | |||
"cypress": "^13.13.2", | |||
"cypress": "^13.15.1", |
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.
This change is not needed
fillCardDetails( | ||
selector: string, | ||
cardData: CardData | ||
): Chainable<Response<any>> |
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.
fillCardDetails( | |
selector: string, | |
cardData: CardData | |
): Chainable<Response<any>> |
Cypress.Commands.add( | ||
"createPaymentIntent", | ||
(secretKey: string, createPaymentBody: any) => { | ||
return cy | ||
.request({ | ||
method: "POST", | ||
url: "https://sandbox.hyperswitch.io/payments", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Accept: "application/json", | ||
"api-key": secretKey, | ||
}, | ||
body: JSON.stringify(createPaymentBody), | ||
}) | ||
.then((response) => { | ||
expect(response.headers["content-type"]).to.include("application/json"); | ||
expect(response.body).to.have.property("client_secret"); | ||
const clientSecret = response.body.client_secret; | ||
cy.log(clientSecret); | ||
cy.log(response.toString()); | ||
|
||
globalState["clientSecret"] = clientSecret; | ||
}); | ||
} | ||
); |
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.
This is not needed, please revert this change
const cardData: CardData = { | ||
cardNo: adyenTestCard, | ||
expiryDate: "03/30", | ||
cvc: "737", | ||
}; |
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.
Move this to support/utils.ts
// const cardData: CardData = { | ||
// cardNo: adyenTestCard, | ||
// expiryDate: adyenExpiryDate, | ||
// cvc: adyenCvc, | ||
// } |
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.
remove the comments
|
||
// Test to fill in card details and complete payment | ||
it("should check card payment for adyen connector 3DS flow", function () { | ||
cy.fillCardDetails(iframeSelector, cardData); |
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.
cy.fillCardDetails(iframeSelector, cardData); | |
getIframeBody().find(`[data-testid=${testIds.addNewCardIcon}]`).click(); | |
getIframeBody() | |
.find(`[data-testid=${testIds.cardNoInputTestId}]`) | |
.type(cardData.cardNo); | |
getIframeBody() | |
.find(`[data-testid=${testIds.expiryInputTestId}]`) | |
.type(cardData.expiryDate); | |
getIframeBody() | |
.find(`[data-testid=${testIds.cardCVVInputTestId}]`) | |
.should("be.ok") | |
.type(cardData.cvc); | |
getIframeBody().get("#submit").click(); |
cy.log(`Current URL: ${url}`); | ||
}); | ||
|
||
cy.wait(5000); |
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.
cy.wait(5000); |
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.
Why is this required? Can we please remove this?
Cypress.Commands.add( | ||
"fillCardDetails", | ||
(iframeSelector: string, cardData: any) => { | ||
const getIframeBody = () => cy.iframe(iframeSelector); | ||
|
||
// Find and interact with card details input fields within the iframe | ||
getIframeBody().find(`[data-testid=${testIds.addNewCardIcon}]`).click(); | ||
getIframeBody() | ||
.find(`[data-testid=${testIds.cardNoInputTestId}]`) | ||
.type(cardData.cardNo); | ||
getIframeBody() | ||
.find(`[data-testid=${testIds.expiryInputTestId}]`) | ||
.type(cardData.expiryDate); | ||
getIframeBody() | ||
.find(`[data-testid=${testIds.cardCVVInputTestId}]`) | ||
.should("be.ok") | ||
.type(cardData.cvc); | ||
|
||
// Submit the payment details | ||
getIframeBody().get("#submit").click(); | ||
} | ||
); |
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.
Cypress.Commands.add( | |
"fillCardDetails", | |
(iframeSelector: string, cardData: any) => { | |
const getIframeBody = () => cy.iframe(iframeSelector); | |
// Find and interact with card details input fields within the iframe | |
getIframeBody().find(`[data-testid=${testIds.addNewCardIcon}]`).click(); | |
getIframeBody() | |
.find(`[data-testid=${testIds.cardNoInputTestId}]`) | |
.type(cardData.cardNo); | |
getIframeBody() | |
.find(`[data-testid=${testIds.expiryInputTestId}]`) | |
.type(cardData.expiryDate); | |
getIframeBody() | |
.find(`[data-testid=${testIds.cardCVVInputTestId}]`) | |
.should("be.ok") | |
.type(cardData.cvc); | |
// Submit the payment details | |
getIframeBody().get("#submit").click(); | |
} | |
); |
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.
This is not needed, please revert this change
Cypress.Commands.add( | ||
"createPaymentIntent", | ||
(secretKey: string, createPaymentBody: any) => { | ||
return cy | ||
.request({ | ||
method: "POST", | ||
url: "https://sandbox.hyperswitch.io/payments", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Accept: "application/json", | ||
"api-key": secretKey, | ||
}, | ||
body: JSON.stringify(createPaymentBody), | ||
}) | ||
.then((response) => { | ||
expect(response.headers["content-type"]).to.include("application/json"); | ||
expect(response.body).to.have.property("client_secret"); | ||
const clientSecret = response.body.client_secret; | ||
cy.log(clientSecret); | ||
cy.log(response.toString()); | ||
|
||
globalState["clientSecret"] = clientSecret; | ||
}); | ||
} | ||
); |
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.
Cypress.Commands.add( | |
"createPaymentIntent", | |
(secretKey: string, createPaymentBody: any) => { | |
return cy | |
.request({ | |
method: "POST", | |
url: "https://sandbox.hyperswitch.io/payments", | |
headers: { | |
"Content-Type": "application/json", | |
Accept: "application/json", | |
"api-key": secretKey, | |
}, | |
body: JSON.stringify(createPaymentBody), | |
}) | |
.then((response) => { | |
expect(response.headers["content-type"]).to.include("application/json"); | |
expect(response.body).to.have.property("client_secret"); | |
const clientSecret = response.body.client_secret; | |
cy.log(clientSecret); | |
cy.log(response.toString()); | |
globalState["clientSecret"] = clientSecret; | |
}); | |
} | |
); |
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.
Please revert back any changes in package-lock.json
Type of Change
Description
This PR introduces an end-to-end test for the 3DS flow of card payments using the Adyen connector. The test ensures that the 3DS authentication process is correctly implemented and functions as expected during the payment flow. It simulates user interactions with the payment interface, verifies the handling of 3DS challenges, and ensures the transaction completes successfully.
Motivation and Context
This change is required to validate the implementation of 3DS card payments, ensuring compliance with security standards and enhancing the reliability of payment transactions. It addresses the need for automated testing in the payment workflow, reducing the risk of issues in production.
How did you test it?
Cypress
Checklist
npm run re:build