-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added nested iframe test support in cypress and external 3ds ne…
…tcetera test case
- Loading branch information
1 parent
f55f61a
commit 139a62f
Showing
4 changed files
with
96 additions
and
3 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
cypress-tests/cypress/e2e/external-3DS-netcetera-e2e-test.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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import * as testIds from "../../../src/Utilities/TestUtils.bs"; | ||
import { getClientURL, netceteraChallengeTestCard, createPaymentBody, changeObjectKeyValue, connectorProfileIdMapping, connectorEnum } from "../support/utils"; | ||
describe("External 3DS using Netcetera Checks", () => { | ||
let getIframeBody: () => Cypress.Chainable<JQuery<HTMLBodyElement>>; | ||
const publishableKey = Cypress.env('HYPERSWITCH_PUBLISHABLE_KEY') | ||
const secretKey = Cypress.env('HYPERSWITCH_SECRET_KEY') | ||
changeObjectKeyValue(createPaymentBody, "profile_id", connectorProfileIdMapping.get(connectorEnum.NETCETERA)) | ||
changeObjectKeyValue(createPaymentBody, "request_external_three_ds_authentication", true) | ||
changeObjectKeyValue(createPaymentBody, "authentication_type", "three_ds") | ||
let iframeSelector = | ||
"#orca-payment-element-iframeRef-orca-elements-payment-element-payment-element"; | ||
|
||
beforeEach(() => { | ||
getIframeBody = () => cy.iframe(iframeSelector); | ||
cy.createPaymentIntent(secretKey, createPaymentBody).then(() => { | ||
cy.getGlobalState("clientSecret").then((clientSecret) => { | ||
|
||
cy.visit(getClientURL(clientSecret, publishableKey)); | ||
}); | ||
|
||
}) | ||
}); | ||
|
||
|
||
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"); | ||
}); | ||
|
||
|
||
it('If the user completes the challenge, the payment should be successful.', () => { | ||
getIframeBody().find(`[data-testid=${testIds.addNewCardIcon}]`).click() | ||
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type(netceteraChallengeTestCard) | ||
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type("0444") | ||
cy.wait(1000) | ||
getIframeBody().find(`[data-testid=${testIds.cardCVVInputTestId}]`).type("1234") | ||
getIframeBody().get("#submit").click(); | ||
cy.wait(4000) | ||
|
||
cy.nestedIFrame("#threeDsAuthFrame", ($body) => { | ||
cy.wrap($body).find('#otp') | ||
.type('1234') | ||
|
||
cy.wrap($body).find('#sendOtp') | ||
.click() | ||
cy.contains("Thanks for your order!").should("be.visible"); | ||
}) | ||
|
||
}) | ||
|
||
it('If the user closes the challenge, the payment should fail.', () => { | ||
getIframeBody().find(`[data-testid=${testIds.addNewCardIcon}]`).click() | ||
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type(netceteraChallengeTestCard) | ||
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type("0444") | ||
cy.wait(1000) | ||
getIframeBody().find(`[data-testid=${testIds.cardCVVInputTestId}]`).type("1234") | ||
getIframeBody().get("#submit").click(); | ||
cy.wait(4000) | ||
|
||
cy.nestedIFrame("#threeDsAuthFrame", ($body) => { | ||
cy.wrap($body) | ||
.find('#cancel') | ||
.click() | ||
cy.contains("Payment Failed!").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
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
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