-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(cypress): add testIds as selectors in card payment for adyen…
… connector 3DS flow e2e test
- Loading branch information
kamini08
committed
Oct 25, 2024
1 parent
d21029c
commit 2052a9d
Showing
2 changed files
with
123 additions
and
113 deletions.
There are no files selected for viewing
151 changes: 75 additions & 76 deletions
151
cypress-tests/cypress/e2e/card-payment-adyen-connector-3ds-flow.cy.ts
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 |
---|---|---|
@@ -1,81 +1,80 @@ | ||
import { | ||
adyenTestCard, | ||
changeObjectKeyValue, | ||
confirmBody, | ||
adyenTestCard, | ||
changeObjectKeyValue, | ||
confirmBody, | ||
createPaymentBody, | ||
getClientURL, | ||
} from "cypress/support/utils"; | ||
import { CardData } from "cypress/support/types"; | ||
|
||
describe("Card Payment for Adyen Connector for 3DS Flow Test", () => { | ||
const publishableKey = Cypress.env("HYPERSWITCH_PUBLISHABLE_KEY"); | ||
const secretKey = Cypress.env("HYPERSWITCH_SECRET_KEY"); | ||
let getIframeBody: () => Cypress.Chainable<JQuery<HTMLBodyElement>>; | ||
const iframeSelector = | ||
"#orca-payment-element-iframeRef-orca-elements-payment-element-payment-element"; | ||
|
||
const cardData: CardData = { | ||
cardNo: adyenTestCard, | ||
expiryDate: "03/30", | ||
cvc: "737", | ||
}; | ||
// const cardData: CardData = { | ||
// cardNo: adyenTestCard, | ||
// expiryDate: adyenExpiryDate, | ||
// cvc: adyenCvc, | ||
// } | ||
changeObjectKeyValue( | ||
createPaymentBody, | ||
getClientURL, | ||
} from "cypress/support/utils"; | ||
import { CardData } from "cypress/support/types"; | ||
|
||
describe("Card Payment for Adyen Connector for 3DS Flow Test", () => { | ||
const publishableKey = Cypress.env("HYPERSWITCH_PUBLISHABLE_KEY"); | ||
const secretKey = Cypress.env("HYPERSWITCH_SECRET_KEY"); | ||
let getIframeBody: () => Cypress.Chainable<JQuery<HTMLBodyElement>>; | ||
const iframeSelector = | ||
"#orca-payment-element-iframeRef-orca-elements-payment-element-payment-element"; | ||
|
||
const cardData: CardData = { | ||
cardNo: "4212 3456 7891 0006", | ||
expiryDate: "03/30", | ||
cvc: "737", | ||
}; | ||
// const cardData: CardData = { | ||
// cardNo: adyenTestCard, | ||
// expiryDate: adyenExpiryDate, | ||
// cvc: adyenCvc, | ||
// } | ||
changeObjectKeyValue( | ||
createPaymentBody, | ||
"profile_id", | ||
Cypress.env("PROFILE_ID") | ||
); | ||
changeObjectKeyValue(createPaymentBody, "authentication_type", "three_ds"); | ||
createPaymentBody["request_external_three_ds_authentication"] = true; | ||
|
||
beforeEach(() => { | ||
getIframeBody = () => cy.iframe(iframeSelector); | ||
cy.createPaymentIntent(secretKey, createPaymentBody).then(() => { | ||
cy.getGlobalState("clientSecret").then((clientSecret) => { | ||
cy.visit(getClientURL(clientSecret, publishableKey)); | ||
}); | ||
"profile_id", | ||
Cypress.env("PROFILE_ID") | ||
); | ||
changeObjectKeyValue(createPaymentBody, "authentication_type", "three_ds"); | ||
createPaymentBody["request_external_three_ds_authentication"] = true; | ||
|
||
beforeEach(() => { | ||
getIframeBody = () => cy.iframe(iframeSelector); | ||
cy.createPaymentIntent(secretKey, createPaymentBody).then(() => { | ||
cy.getGlobalState("clientSecret").then((clientSecret) => { | ||
cy.visit(getClientURL(clientSecret, publishableKey)); | ||
}); | ||
}); | ||
|
||
// Test for rendering the correct page title | ||
it("title rendered correctly", () => { | ||
cy.contains("Hyperswitch Unified Checkout").should("be.visible"); | ||
}); | ||
|
||
it("orca-payment-element iframe loaded", () => { | ||
cy.get( | ||
"#orca-payment-element-iframeRef-orca-elements-payment-element-payment-element" | ||
) | ||
.should("be.visible") | ||
.its("0.contentDocument") | ||
.its("body"); | ||
}); | ||
|
||
// Test to fill in card details and complete payment | ||
it("should check card payment for adyen connector 3DS flow", function () { | ||
cy.fillCardDetails(iframeSelector, cardData); | ||
|
||
// Validate URL redirection to Adyen connector for 3DS Auth | ||
cy.url() | ||
.should("include", "adyen.com") | ||
.then((url) => { | ||
// Log the URL to the Cypress command log | ||
cy.log(`Current URL: ${url}`); | ||
}); | ||
|
||
cy.wait(5000); | ||
cy.get("#root").should("be.ok"); | ||
|
||
// Interact with the 3DS secure authentication iframe | ||
cy.iframe(".adyen-checkout__iframe").find("[name=answer]").type("password"); | ||
|
||
cy.iframe(".adyen-checkout__iframe").find("#buttonSubmit").click(); | ||
cy.wait(2000); // Wait for confirmation message to display | ||
cy.contains("Thanks for your order!").should("be.visible"); | ||
}); | ||
}); | ||
|
||
|
||
// Test for rendering the correct page title | ||
it("title rendered correctly", () => { | ||
cy.contains("Hyperswitch Unified Checkout").should("be.visible"); | ||
}); | ||
|
||
it("orca-payment-element iframe loaded", () => { | ||
cy.get( | ||
"#orca-payment-element-iframeRef-orca-elements-payment-element-payment-element" | ||
) | ||
.should("be.visible") | ||
.its("0.contentDocument") | ||
.its("body"); | ||
}); | ||
|
||
// Test to fill in card details and complete payment | ||
it("should check card payment for adyen connector 3DS flow", function () { | ||
cy.fillCardDetails(iframeSelector, cardData); | ||
|
||
// Validate URL redirection to Adyen connector for 3DS Auth | ||
cy.url() | ||
.should("include", "adyen.com") | ||
.then((url) => { | ||
// Log the URL to the Cypress command log | ||
cy.log(`Current URL: ${url}`); | ||
}); | ||
|
||
cy.wait(5000); | ||
cy.get("#root").should("be.ok"); | ||
|
||
// Interact with the 3DS secure authentication iframe | ||
cy.iframe(".adyen-checkout__iframe").find("[name=answer]").type("password"); | ||
|
||
cy.iframe(".adyen-checkout__iframe").find("#buttonSubmit").click(); | ||
cy.wait(2000); // Wait for confirmation message to display | ||
cy.contains("Thanks for your order!").should("be.visible"); | ||
}); | ||
}); |
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