Skip to content

Commit fe7e4eb

Browse files
Merge branch 'main' of github.com:juspay/hyperswitch-web into new-test-cases
2 parents 8f8b5f5 + bbdf7ca commit fe7e4eb

27 files changed

+1117
-765
lines changed

cypress-tests/cypress/e2e/card-number-validation-test.cy.ts

Lines changed: 204 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -5,146 +5,209 @@ import { changeObjectKeyValue } from "../support/utils";
55
import { stripeCards } from "cypress/support/cards";
66

77
describe("Card number validation test", () => {
8-
9-
const publishableKey = Cypress.env('HYPERSWITCH_PUBLISHABLE_KEY')
10-
const secretKey = Cypress.env('HYPERSWITCH_SECRET_KEY')
11-
let getIframeBody: () => Cypress.Chainable<JQuery<HTMLBodyElement>>;
12-
let iframeSelector =
13-
"#orca-payment-element-iframeRef-orca-elements-payment-element-payment-element";
14-
15-
// changeObjectKeyValue(createPaymentBody,"profile_id","YOUR_PROFILE_ID")
16-
changeObjectKeyValue(createPaymentBody,"customer_id","new_user")
17-
18-
19-
beforeEach(() => {
20-
getIframeBody = () => cy.iframe(iframeSelector);
21-
cy.createPaymentIntent(secretKey, createPaymentBody).then(() => {
22-
cy.getGlobalState("clientSecret").then((clientSecret) => {
23-
24-
cy.visit(getClientURL(clientSecret, publishableKey));
25-
});
26-
27-
})
28-
});
29-
30-
it("should fail with an undetectable card brand and invalid card number", () => {
31-
const { card_exp_month, card_exp_year, cvc } = stripeCards.successCard;
32-
33-
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type("111111");
34-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_month);
35-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_year);
36-
getIframeBody().find(`[data-testid=${testIds.cardCVVInputTestId}]`).type(cvc);
37-
38-
getIframeBody().get("#submit").click();
39-
40-
getIframeBody().find('.Error.pt-1').should('be.visible')
41-
.and('contain.text', "Please enter a valid card number.");
42-
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).click();
43-
getIframeBody().find('.Error.pt-1').should('not.exist');
44-
45-
});
46-
47-
it("should fail with a detectable but invalid card number", () => {
48-
const { card_exp_month, card_exp_year, cvc } = stripeCards.successCard;
49-
50-
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type("424242");
51-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_month);
52-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_year);
53-
getIframeBody().find(`[data-testid=${testIds.cardCVVInputTestId}]`).type(cvc);
54-
55-
getIframeBody().get("#submit").click();
56-
57-
getIframeBody().find('.Error.pt-1').should('be.visible')
58-
.and('contain.text', "Card number is invalid.");
59-
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).click();
60-
getIframeBody().find('.Error.pt-1').should('not.exist');
61-
});
62-
63-
it("should fail with an unsupported card brand (RuPay)", () => {
64-
const { card_exp_month, card_exp_year, cvc } = stripeCards.successCard;
65-
66-
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type("6082015309577308");
67-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_month);
68-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_year);
69-
getIframeBody().find(`[data-testid=${testIds.cardCVVInputTestId}]`).type(cvc);
70-
71-
getIframeBody().get("#submit").click();
72-
73-
getIframeBody().find('.Error.pt-1').should('be.visible')
74-
.and('contain.text', "RuPay is not supported at the moment.");
75-
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).click();
76-
getIframeBody().find('.Error.pt-1').should('not.exist');
77-
});
78-
79-
it("should fail with an empty card number", () => {
80-
const { card_exp_month, card_exp_year, cvc } = stripeCards.successCard;
81-
82-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_month);
83-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_year);
84-
getIframeBody().find(`[data-testid=${testIds.cardCVVInputTestId}]`).type(cvc);
85-
86-
getIframeBody().get("#submit").click();
87-
88-
getIframeBody().find('.Error.pt-1').should('be.visible')
89-
.and('contain.text', "Card Number cannot be empty");
90-
});
91-
92-
it("19 digit unionpay card", () => {
93-
const { cardNo, card_exp_month, card_exp_year, cvc } = stripeCards.unionPay19;
94-
95-
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type(cardNo);
96-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_month);
97-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_year);
98-
getIframeBody().find(`[data-testid=${testIds.cardCVVInputTestId}]`).type(cvc);
99-
cy.wait(2000);
100-
101-
getIframeBody().get("#submit").click();
102-
103-
104-
cy.contains("Thanks for your order!").should("be.visible");
105-
});
106-
107-
108-
it("16 digit master card", () => {
109-
const { cardNo, card_exp_month, card_exp_year, cvc } = stripeCards.masterCard16;
110-
111-
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type(cardNo);
112-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_month);
113-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_year);
114-
getIframeBody().find(`[data-testid=${testIds.cardCVVInputTestId}]`).type(cvc);
115-
116-
getIframeBody().get("#submit").click();
117-
118-
119-
cy.contains("Thanks for your order!").should("be.visible");
120-
});
121-
122-
it("15 digit american express card", () => {
123-
const { cardNo, card_exp_month, card_exp_year, cvc } = stripeCards.amexCard15;
124-
125-
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type(cardNo);
126-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_month);
127-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_year);
128-
getIframeBody().find(`[data-testid=${testIds.cardCVVInputTestId}]`).type(cvc);
129-
130-
getIframeBody().get("#submit").click();
131-
132-
133-
cy.contains("Thanks for your order!").should("be.visible");
8+
const publishableKey = Cypress.env("HYPERSWITCH_PUBLISHABLE_KEY");
9+
const secretKey = Cypress.env("HYPERSWITCH_SECRET_KEY");
10+
let getIframeBody: () => Cypress.Chainable<JQuery<HTMLBodyElement>>;
11+
let iframeSelector =
12+
"#orca-payment-element-iframeRef-orca-elements-payment-element-payment-element";
13+
14+
// changeObjectKeyValue(createPaymentBody,"profile_id","YOUR_PROFILE_ID")
15+
changeObjectKeyValue(createPaymentBody, "customer_id", "new_user");
16+
17+
beforeEach(() => {
18+
getIframeBody = () => cy.iframe(iframeSelector);
19+
cy.createPaymentIntent(secretKey, createPaymentBody).then(() => {
20+
cy.getGlobalState("clientSecret").then((clientSecret) => {
21+
cy.visit(getClientURL(clientSecret, publishableKey));
13422
});
135-
136-
it("14 digit diners club card", () => {
137-
const { cardNo, card_exp_month, card_exp_year, cvc } = stripeCards.dinersClubCard14;
138-
139-
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type(cardNo);
140-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_month);
141-
getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_year);
142-
getIframeBody().find(`[data-testid=${testIds.cardCVVInputTestId}]`).type(cvc);
143-
144-
getIframeBody().get("#submit").click();
145-
146-
147-
cy.contains("Thanks for your order!").should("be.visible");
148-
});
149-
23+
});
24+
});
25+
26+
it("should fail with an undetectable card brand and invalid card number", () => {
27+
const { card_exp_month, card_exp_year, cvc } = stripeCards.successCard;
28+
29+
getIframeBody()
30+
.find(`[data-testid=${testIds.cardNoInputTestId}]`)
31+
.type("111111");
32+
getIframeBody()
33+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
34+
.type(card_exp_month);
35+
getIframeBody()
36+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
37+
.type(card_exp_year);
38+
getIframeBody()
39+
.find(`[data-testid=${testIds.cardCVVInputTestId}]`)
40+
.type(cvc);
41+
42+
getIframeBody().get("#submit").click();
43+
44+
getIframeBody()
45+
.find(".Error.pt-1")
46+
.should("be.visible")
47+
.and("contain.text", "Please enter a valid card number.");
48+
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).click();
49+
getIframeBody().find(".Error.pt-1").should("not.exist");
50+
});
51+
52+
it("should fail with a detectable but invalid card number", () => {
53+
const { card_exp_month, card_exp_year, cvc } = stripeCards.successCard;
54+
55+
getIframeBody()
56+
.find(`[data-testid=${testIds.cardNoInputTestId}]`)
57+
.type("424242");
58+
getIframeBody()
59+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
60+
.type(card_exp_month);
61+
getIframeBody()
62+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
63+
.type(card_exp_year);
64+
getIframeBody()
65+
.find(`[data-testid=${testIds.cardCVVInputTestId}]`)
66+
.type(cvc);
67+
68+
getIframeBody().get("#submit").click();
69+
70+
getIframeBody()
71+
.find(".Error.pt-1")
72+
.should("be.visible")
73+
.and("contain.text", "Card number is invalid.");
74+
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).click();
75+
getIframeBody().find(".Error.pt-1").should("not.exist");
76+
});
77+
78+
it("should fail with an unsupported card brand (RuPay)", () => {
79+
const { card_exp_month, card_exp_year, cvc } = stripeCards.successCard;
80+
81+
getIframeBody()
82+
.find(`[data-testid=${testIds.cardNoInputTestId}]`)
83+
.type("6082015309577308");
84+
getIframeBody()
85+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
86+
.type(card_exp_month);
87+
getIframeBody()
88+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
89+
.type(card_exp_year);
90+
getIframeBody()
91+
.find(`[data-testid=${testIds.cardCVVInputTestId}]`)
92+
.type(cvc);
93+
94+
getIframeBody().get("#submit").click();
95+
96+
getIframeBody()
97+
.find(".Error.pt-1")
98+
.should("be.visible")
99+
.and("contain.text", "RuPay is not supported at the moment.");
100+
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).click();
101+
getIframeBody().find(".Error.pt-1").should("not.exist");
102+
});
103+
104+
it("should fail with an empty card number", () => {
105+
const { card_exp_month, card_exp_year, cvc } = stripeCards.successCard;
106+
107+
getIframeBody()
108+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
109+
.type(card_exp_month);
110+
getIframeBody()
111+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
112+
.type(card_exp_year);
113+
getIframeBody()
114+
.find(`[data-testid=${testIds.cardCVVInputTestId}]`)
115+
.type(cvc);
116+
117+
getIframeBody().get("#submit").click();
118+
119+
getIframeBody()
120+
.find(".Error.pt-1")
121+
.should("be.visible")
122+
.and("contain.text", "Card Number cannot be empty");
123+
});
124+
125+
it("19 digit unionpay card", () => {
126+
const { cardNo, card_exp_month, card_exp_year, cvc } =
127+
stripeCards.unionPay19;
128+
129+
getIframeBody()
130+
.find(`[data-testid=${testIds.cardNoInputTestId}]`)
131+
.type(cardNo);
132+
getIframeBody()
133+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
134+
.type(card_exp_month);
135+
getIframeBody()
136+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
137+
.type(card_exp_year);
138+
getIframeBody()
139+
.find(`[data-testid=${testIds.cardCVVInputTestId}]`)
140+
.type(cvc);
141+
cy.wait(2000);
142+
143+
getIframeBody().get("#submit").click();
144+
145+
cy.contains("Thanks for your order!").should("be.visible");
146+
});
147+
148+
it("16 digit master card", () => {
149+
const { cardNo, card_exp_month, card_exp_year, cvc } =
150+
stripeCards.masterCard16;
151+
152+
getIframeBody()
153+
.find(`[data-testid=${testIds.cardNoInputTestId}]`)
154+
.type(cardNo);
155+
getIframeBody()
156+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
157+
.type(card_exp_month);
158+
getIframeBody()
159+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
160+
.type(card_exp_year);
161+
getIframeBody()
162+
.find(`[data-testid=${testIds.cardCVVInputTestId}]`)
163+
.type(cvc);
164+
165+
getIframeBody().get("#submit").click();
166+
167+
cy.contains("Thanks for your order!").should("be.visible");
168+
});
169+
170+
it("15 digit american express card", () => {
171+
const { cardNo, card_exp_month, card_exp_year, cvc } =
172+
stripeCards.amexCard15;
173+
174+
getIframeBody()
175+
.find(`[data-testid=${testIds.cardNoInputTestId}]`)
176+
.type(cardNo);
177+
getIframeBody()
178+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
179+
.type(card_exp_month);
180+
getIframeBody()
181+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
182+
.type(card_exp_year);
183+
getIframeBody()
184+
.find(`[data-testid=${testIds.cardCVVInputTestId}]`)
185+
.type(cvc);
186+
187+
getIframeBody().get("#submit").click();
188+
189+
cy.contains("Thanks for your order!").should("be.visible");
190+
});
191+
192+
it("14 digit diners club card", () => {
193+
const { cardNo, card_exp_month, card_exp_year, cvc } =
194+
stripeCards.dinersClubCard14;
195+
196+
getIframeBody()
197+
.find(`[data-testid=${testIds.cardNoInputTestId}]`)
198+
.type(cardNo);
199+
getIframeBody()
200+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
201+
.type(card_exp_month);
202+
getIframeBody()
203+
.find(`[data-testid=${testIds.expiryInputTestId}]`)
204+
.type(card_exp_year);
205+
getIframeBody()
206+
.find(`[data-testid=${testIds.cardCVVInputTestId}]`)
207+
.type(cvc);
208+
209+
getIframeBody().get("#submit").click();
210+
211+
cy.contains("Thanks for your order!").should("be.visible");
212+
});
150213
});

cypress-tests/cypress/e2e/crpto-flow-test.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe("Card payment flow test", () => {
1717
changeObjectKeyValue(
1818
createPaymentBody,
1919
"profile_id",
20-
connectorProfileIdMapping.get(connectorEnum.CRYPTOPAY)
20+
connectorProfileIdMapping.get(connectorEnum.CRYPTOPAY),
2121
);
2222

2323
beforeEach(() => {
@@ -50,7 +50,7 @@ describe("Card payment flow test", () => {
5050
.then(() => {
5151
cy.url().should(
5252
"include",
53-
"hosted-business-sandbox.cryptopay.me/invoices"
53+
"hosted-business-sandbox.cryptopay.me/invoices",
5454
);
5555
});
5656
});

0 commit comments

Comments
 (0)