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

test: add 3DS flow E2E test for card payments for Adyen connector #754

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kamini08
Copy link

@kamini08 kamini08 commented Oct 26, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

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

Screenshot 2024-10-26 103058

Checklist

  • I ran npm run re:build
  • I reviewed submitted code
  • I added unit tests for my changes where possible

Copy link

semanticdiff-com bot commented Oct 26, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  package-lock.json  76% smaller
  cypress-tests/cypress/support/commands.ts  70% smaller
  cypress-tests/package-lock.json  8% smaller
  cypress-tests/cypress/e2e/card-payment-adyen-connector-3ds-flow.cy.ts  0% smaller
  cypress-tests/cypress/support/types.ts  0% smaller
  cypress-tests/package.json  0% smaller

@kamini08 kamini08 changed the title feat(cypress): add 3DS flow E2E test for card payments for Adyen connector test: add 3DS flow E2E test for card payments for Adyen connector Oct 26, 2024
@gorakhnathy7 gorakhnathy7 added the Hacktoberfest Issues that are up for grabs for Hacktoberfest participants label Oct 26, 2024
@PritishBudhiraja PritishBudhiraja added the Testing Add this label if the PR contains Testing related changes label Oct 29, 2024
@@ -15,7 +15,7 @@
"author": "juspay/hyperswitch-web-sdk",
"license": "ISC",
"devDependencies": {
"cypress": "^13.13.2",
"cypress": "^13.15.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"cypress": "^13.15.1",
"cypress": "^13.13.2",

Copy link
Contributor

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",
Copy link
Contributor

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

Comment on lines +35 to +38
fillCardDetails(
selector: string,
cardData: CardData
): Chainable<Response<any>>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fillCardDetails(
selector: string,
cardData: CardData
): Chainable<Response<any>>

Comment on lines +149 to +173
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;
});
}
);
Copy link
Contributor

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

Comment on lines +17 to +21
const cardData: CardData = {
cardNo: adyenTestCard,
expiryDate: "03/30",
cvc: "737",
};
Copy link
Contributor

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

Comment on lines +22 to +26
// const cardData: CardData = {
// cardNo: adyenTestCard,
// expiryDate: adyenExpiryDate,
// cvc: adyenCvc,
// }
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cy.wait(5000);

Copy link
Contributor

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?

Comment on lines +179 to +200
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();
}
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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();
}
);

Copy link
Contributor

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

Comment on lines +149 to +173
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;
});
}
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested 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;
});
}
);

Copy link
Contributor

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

@PritishBudhiraja PritishBudhiraja added the Added Comments - waiting for author Add this label when comments added in the PR and waiting for the author to get those resolved. label Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Added Comments - waiting for author Add this label when comments added in the PR and waiting for the author to get those resolved. Hacktoberfest Issues that are up for grabs for Hacktoberfest participants hacktoberfest-accepted Testing Add this label if the PR contains Testing related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CYPRESS] Add e2e test for card payment for Adyen Connector for 3DS Flow
4 participants