Skip to content

Commit 6917458

Browse files
committed
Payment Link and Virtual Terminal Playwright tests
1 parent 22c48f9 commit 6917458

File tree

4 files changed

+116
-23
lines changed

4 files changed

+116
-23
lines changed

Test/End-2-End/Components/PaymentMethods/CardCheckout.js

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,14 @@ export default class CardCheckout {
88

99
async checkout() {
1010
await this.checkoutPage.selectCard();
11-
// Credit card form
12-
await this.page
13-
.frameLocator(".st-card-number-iframe")
14-
.getByLabel("Card Number")
15-
.fill("4111 1111 1111 1111");
16-
await this.page
17-
.frameLocator(".st-expiration-date-iframe")
18-
.getByLabel("Expiration Date")
19-
.fill("1233");
20-
await this.page
21-
.frameLocator(".st-security-code-iframe")
22-
.getByLabel("Security Code")
23-
.fill("123");
11+
12+
await CardCheckout.fillDefaultCard(this.page);
2413

2514
await this.checkoutPage.pressPlaceOrder();
26-
// OTP form
27-
await this.page
28-
.frameLocator('iframe[title="Bank Authentication"]')
29-
.getByPlaceholder(" Enter Code Here")
30-
.fill("1234");
31-
await this.page
32-
.frameLocator('iframe[title="Bank Authentication"]')
33-
.getByRole("button", { name: "SUBMIT" })
34-
.click();
15+
await CardCheckout.fillOtp(this.page);
3516
}
3617

18+
3719
async checkoutUsingFrictionless3DsCard() {
3820
await this.checkoutPage.selectCard();
3921
// Credit card form
@@ -71,4 +53,30 @@ export default class CardCheckout {
7153

7254
await this.checkoutPage.pressPlaceOrder();
7355
}
56+
57+
static async fillDefaultCard(locator) {
58+
await locator
59+
.frameLocator(".st-card-number-iframe")
60+
.getByLabel("Card Number")
61+
.fill("4111 1111 1111 1111");
62+
await locator
63+
.frameLocator(".st-expiration-date-iframe")
64+
.getByLabel("Expiration Date")
65+
.fill("1233");
66+
await locator
67+
.frameLocator(".st-security-code-iframe")
68+
.getByLabel("Security Code")
69+
.fill("123");
70+
}
71+
72+
static async fillOtp(locator){
73+
await locator
74+
.frameLocator('iframe[title="Bank Authentication"]')
75+
.getByPlaceholder(" Enter Code Here")
76+
.fill("1234");
77+
await locator
78+
.frameLocator('iframe[title="Bank Authentication"]')
79+
.getByRole("button", { name: "SUBMIT" })
80+
.click();
81+
}
7482
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import {expect, test} from "@playwright/test";
2+
import GoTo from "./Components/GoTo";
3+
import {v7 as uuidv7} from 'uuid';
4+
import CardCheckout from "./Components/PaymentMethods/CardCheckout";
5+
6+
test.describe.configure({mode: 'serial'});
7+
8+
9+
test("payment link order", async ({browser, page}) => {
10+
await new GoTo(page).admin.ordersList();
11+
12+
await page.getByRole('button', {name: 'Create New Order'}).click();
13+
await page.getByRole('button', {name: 'Create New Customer'}).click();
14+
await page.getByRole('button', {name: 'Add Products'}).click();
15+
await page.locator("#sales_order_create_search_grid_table tbody tr").nth(3).click();
16+
await page.getByRole('button', {name: 'Add Selected Product(s) to Order'}).click();
17+
await page.getByLabel('Email', {exact: true}).fill('virtual-terminal-' + uuidv7() + '@example.com');
18+
await page.getByRole('group', {name: 'Billing Address'}).getByLabel('First Name').fill('John');
19+
await page.getByRole('group', {name: 'Billing Address'}).getByLabel('Last Name').fill('Doe');
20+
await page.locator('#order-billing_address_street0').fill('123 Main St');
21+
await page.locator('#order-billing_address_street1').fill('Test');
22+
await page.getByRole('group', {name: 'Billing Address'}).getByLabel('City').fill('Birmingham');
23+
await page.getByRole('group', {name: 'Billing Address'}).getByLabel('Zip/Postal Code').fill('BZ1 1ZZ');
24+
await page.getByRole('group', {name: 'Billing Address'}).getByLabel('Phone Number').fill('0123456789');
25+
await page.getByRole('link', {name: 'Get available payment methods'}).click();
26+
await page.getByText('Rvvup Payment Link').click();
27+
await page.getByRole('link', {name: 'Get shipping methods and rates'}).click();
28+
await page.getByLabel('Fixed - £').click();
29+
await page.getByRole('button', {name: 'Submit Order'}).first().click();
30+
const paymentLink = (await (await page.getByText('This order requires payment, please pay using following button: ').first()).innerText()).replace("This order requires payment, please pay using following button: ", "")
31+
const context = await browser.newContext();
32+
const paymentLinkPage = await context.newPage()
33+
await paymentLinkPage.goto(paymentLink);
34+
await paymentLinkPage.getByRole('button', {name: 'Pay by Card'}).click();
35+
await paymentLinkPage.getByLabel('First name').fill('John');
36+
await paymentLinkPage.getByLabel('Last name').fill('Doe');
37+
await paymentLinkPage.getByLabel('Email').fill('[email protected]');
38+
await paymentLinkPage.getByRole('button', {name: 'Billing Address'}).click();
39+
await paymentLinkPage.getByLabel('Name', {exact: true}).fill('John Doe');
40+
await paymentLinkPage.getByLabel('Address line 1').fill('111 Fake Street');
41+
await paymentLinkPage.getByLabel('City').fill('London');
42+
await paymentLinkPage.getByLabel('Postcode').fill('WC2R 0EX');
43+
await paymentLinkPage.getByRole('button', {name: 'Save changes'}).click();
44+
await paymentLinkPage.getByRole('button', {name: 'Continue'}).click();
45+
46+
await CardCheckout.fillDefaultCard(paymentLinkPage);
47+
await page.waitForTimeout(1000);
48+
await paymentLinkPage.getByRole('button', {name: 'Submit'}).click();
49+
await CardCheckout.fillOtp(paymentLinkPage);
50+
await expect(paymentLinkPage.getByText("Payment Successful")).toBeVisible();
51+
});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {expect, test} from "@playwright/test";
2+
import GoTo from "./Components/GoTo";
3+
import {v7 as uuidv7} from 'uuid';
4+
import CardCheckout from "./Components/PaymentMethods/CardCheckout";
5+
6+
test.describe.configure({mode: 'serial'});
7+
8+
9+
test("virtual terminal order", async ({page}) => {
10+
await new GoTo(page).admin.ordersList();
11+
await page.getByRole('button', {name: 'Create New Order'}).click();
12+
await page.getByRole('button', {name: 'Create New Customer'}).click();
13+
await page.getByRole('button', {name: 'Add Products'}).click();
14+
await page.locator("#sales_order_create_search_grid_table tbody tr").nth(3).click();
15+
await page.getByRole('button', {name: 'Add Selected Product(s) to Order'}).click();
16+
await page.getByLabel('Email', {exact: true}).fill('virtual-terminal-' + uuidv7() + '@example.com');
17+
await page.getByRole('group', {name: 'Billing Address'}).getByLabel('First Name').fill('John');
18+
await page.getByRole('group', {name: 'Billing Address'}).getByLabel('Last Name').fill('Doe');
19+
await page.locator('#order-billing_address_street0').fill('123 Main St');
20+
await page.locator('#order-billing_address_street1').fill('Test');
21+
await page.getByRole('group', {name: 'Billing Address'}).getByLabel('City').fill('Birmingham');
22+
await page.getByRole('group', {name: 'Billing Address'}).getByLabel('Zip/Postal Code').fill('BZ1 1ZZ');
23+
await page.getByRole('group', {name: 'Billing Address'}).getByLabel('Phone Number').fill('0123456789');
24+
await page.getByRole('link', {name: 'Get available payment methods'}).click();
25+
await page.getByText('Rvvup Virtual Terminal').click();
26+
await page.getByRole('link', {name: 'Get shipping methods and rates'}).click();
27+
await page.getByLabel('Fixed - £').click();
28+
await page.getByRole('button', {name: 'Submit Order'}).first().click();
29+
await page.getByRole('button', {name: 'Launch virtual terminal'}).click();
30+
await CardCheckout.fillDefaultCard(page.frameLocator('.rvvup-embedded-checkout iframe'));
31+
await page.waitForTimeout(1000);
32+
await page.frameLocator('.rvvup-embedded-checkout iframe').getByRole('button', {name: 'Submit'}).click();
33+
await expect(page.locator('#order_status')).toHaveText('Processing');
34+
});

playwright.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = defineConfig({
2121
fullyParallel: true,
2222
/* Fail the build on CI if you accidentally left test.only in the source code. */
2323
forbidOnly: !!process.env.CI,
24-
retries: 3,
24+
retries: 10,
2525
/* Opt out of parallel tests. */
2626
workers: 3,
2727
/* Reporter to use. See https://playwright.dev/docs/test-reporters */

0 commit comments

Comments
 (0)