|
| 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 | +}); |
0 commit comments