Skip to content

Commit bbf7e9f

Browse files
test: added cashtocode test cases
1 parent 8fb3704 commit bbf7e9f

File tree

3 files changed

+122
-0
lines changed

3 files changed

+122
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import * as testIds from "../../../src/Utilities/TestUtils.bs";
2+
import { getClientURL } from "../support/utils";
3+
import { createPaymentBody } from "../support/utils";
4+
import {
5+
changeObjectKeyValue,
6+
connectorProfileIdMapping,
7+
connectorEnum,
8+
} from "../support/utils";
9+
import { stripeCards } from "cypress/support/cards";
10+
11+
12+
describe("cashtocode E-voucher test ", () => {
13+
const publishableKey = Cypress.env("HYPERSWITCH_PUBLISHABLE_KEY");
14+
const secretKey = Cypress.env("HYPERSWITCH_SECRET_KEY");
15+
let getIframeBody: () => Cypress.Chainable<JQuery<HTMLBodyElement>>;
16+
let iframeSelector =
17+
"#orca-payment-element-iframeRef-orca-elements-payment-element-payment-element";
18+
changeObjectKeyValue(
19+
createPaymentBody,
20+
"profile_id",
21+
connectorProfileIdMapping.get(connectorEnum.CASHTOCODE),
22+
);
23+
changeObjectKeyValue(createPaymentBody, "currency", "USD");
24+
25+
beforeEach(() => {
26+
getIframeBody = () => cy.iframe(iframeSelector);
27+
cy.createPaymentIntent(secretKey, createPaymentBody).then(() => {
28+
cy.getGlobalState("clientSecret").then((clientSecret) => {
29+
cy.visit(getClientURL(clientSecret, publishableKey));
30+
});
31+
});
32+
});
33+
34+
it("title rendered correctly", () => {
35+
cy.contains("Hyperswitch Unified Checkout").should("be.visible");
36+
});
37+
38+
it("orca-payment-element iframe loaded", () => {
39+
cy.get(iframeSelector)
40+
.should("be.visible")
41+
.its("0.contentDocument")
42+
.its("body");
43+
});
44+
45+
it("should complete the E-voucher payment successfully", () => {
46+
cy.wait(2000);
47+
getIframeBody().find(`[data-testid=${testIds.addNewCardIcon}]`).click();
48+
getIframeBody().contains("div", "E-Voucher").click();
49+
getIframeBody()
50+
.get("#submit")
51+
.click()
52+
.then(() => {
53+
cy.url().should(
54+
"include",
55+
"https://dev.evoucher.cashtocode.com/",
56+
);
57+
});
58+
});
59+
});
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import * as testIds from "../../../src/Utilities/TestUtils.bs";
2+
import { getClientURL } from "../support/utils";
3+
import { createPaymentBody } from "../support/utils";
4+
import {
5+
changeObjectKeyValue,
6+
connectorProfileIdMapping,
7+
connectorEnum,
8+
} from "../support/utils";
9+
import { stripeCards } from "cypress/support/cards";
10+
11+
12+
13+
14+
describe("cashtocode cash / voucher test ", () => {
15+
const publishableKey = Cypress.env("HYPERSWITCH_PUBLISHABLE_KEY");
16+
const secretKey = Cypress.env("HYPERSWITCH_SECRET_KEY");
17+
let getIframeBody: () => Cypress.Chainable<JQuery<HTMLBodyElement>>;
18+
let iframeSelector =
19+
"#orca-payment-element-iframeRef-orca-elements-payment-element-payment-element";
20+
changeObjectKeyValue(
21+
createPaymentBody,
22+
"profile_id",
23+
connectorProfileIdMapping.get(connectorEnum.CASHTOCODE),
24+
);
25+
changeObjectKeyValue(createPaymentBody, "currency", "EUR");
26+
27+
beforeEach(() => {
28+
getIframeBody = () => cy.iframe(iframeSelector);
29+
cy.createPaymentIntent(secretKey, createPaymentBody).then(() => {
30+
cy.getGlobalState("clientSecret").then((clientSecret) => {
31+
cy.visit(getClientURL(clientSecret, publishableKey));
32+
});
33+
});
34+
});
35+
36+
it("title rendered correctly", () => {
37+
cy.contains("Hyperswitch Unified Checkout").should("be.visible");
38+
});
39+
40+
it("orca-payment-element iframe loaded", () => {
41+
cy.get(iframeSelector)
42+
.should("be.visible")
43+
.its("0.contentDocument")
44+
.its("body");
45+
});
46+
47+
it("should complete the Cash / Voucher payment successfully", () => {
48+
cy.wait(2000);
49+
getIframeBody().find(`[data-testid=${testIds.addNewCardIcon}]`).click();
50+
getIframeBody().contains("div", "Cash / Voucher").click();
51+
getIframeBody()
52+
.get("#submit")
53+
.click()
54+
.then(() => {
55+
cy.url().should(
56+
"include",
57+
"https://cluster05.wcl-test.cashtocode.com/",
58+
);
59+
});
60+
});
61+
});

cypress-tests/cypress/support/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const enum connectorEnum {
1414
CRYPTOPAY,
1515
BANK_OF_AMERICA,
1616
CYBERSOURCE,
17+
CASHTOCODE
1718
}
1819
export const connectorProfileIdMapping = new Map<connectorEnum, string>([
1920
[connectorEnum.TRUSTPAY, "pro_eP323T9e4ApKpilWBfPA"],
@@ -25,6 +26,7 @@ export const connectorProfileIdMapping = new Map<connectorEnum, string>([
2526
[connectorEnum.CRYPTOPAY, "pro_cy1AdBRB5jfCuiWgJUZM"],
2627
[connectorEnum.BANK_OF_AMERICA, "pro_Y90w9nPTg5eBOblKa2L9"],
2728
[connectorEnum.CYBERSOURCE, "pro_h9VHXnJx8s6W4KSZfSUL"],
29+
[connectorEnum.CASHTOCODE, "pro_JRdEyK7YyQaDAAzvJuMJ"],
2830
]);
2931

3032
export const createPaymentBody = {

0 commit comments

Comments
 (0)