|
1 | 1 | import { test, expect } from '@playwright/test'; |
| 2 | +import { CreateInvoicePage } from './pages/CreateInvoicePage'; |
2 | 3 |
|
3 | | -test('create invoice - fill form and submit', async ({ page }) => { |
4 | | - // Mock SDK responses |
5 | | - await page.route('**/api/**', async (route) => { |
6 | | - if (route.request().url().includes('createInvoice')) { |
7 | | - await route.abort('blockedbyclient'); |
8 | | - } else { |
9 | | - await route.continue(); |
10 | | - } |
11 | | - }); |
12 | | - |
13 | | - await page.goto('/invoice/new'); |
| 4 | +test.describe('Create invoice flow', () => { |
| 5 | + test('form loads with all required fields', async ({ page }) => { |
| 6 | + const createPage = new CreateInvoicePage(page); |
| 7 | + await createPage.goto(); |
14 | 8 |
|
15 | | - // Fill in the form |
16 | | - await page.fill('input[placeholder="G... address"]', 'GBRPYHIL2CI3WHZDTOOQFC6EB4KJJGUJQDP7DC3K2YSEipq76pqxi'); |
17 | | - await page.fill('input[placeholder="USDC"]', '100'); |
18 | | - |
19 | | - // The page should have a submit button |
20 | | - const submitButton = page.locator('button:has-text("Create Invoice")'); |
21 | | - await expect(submitButton).toBeEnabled(); |
22 | | -}); |
| 9 | + await expect(createPage.heading).toBeVisible(); |
| 10 | + await expect(createPage.recipientInput).toBeVisible(); |
| 11 | + await expect(createPage.nextButton).toBeVisible(); |
| 12 | + }); |
23 | 13 |
|
24 | | -test('create invoice with equal split', async ({ page }) => { |
25 | | - await page.goto('/invoice/new'); |
| 14 | + test('equal split mode shows per-recipient amount', async ({ page }) => { |
| 15 | + const createPage = new CreateInvoicePage(page); |
| 16 | + await createPage.goto(); |
26 | 17 |
|
27 | | - // Toggle equal split |
28 | | - const equalSplitToggle = page.locator('button[role="switch"][aria-label="Toggle equal split mode"]'); |
29 | | - await equalSplitToggle.click(); |
| 18 | + await createPage.toggleEqualSplit(); |
| 19 | + await createPage.fillTotalAmount('200'); |
30 | 20 |
|
31 | | - // Fill total amount |
32 | | - await page.fill('input#total-amount', '200'); |
| 21 | + await expect(createPage.totalAmountInput).toHaveValue('200'); |
| 22 | + }); |
33 | 23 |
|
34 | | - // Add a recipient |
35 | | - await page.fill('input[placeholder="G... address"]', 'GBRPYHIL2CI3WHZDTOOQFC6EB4KJJGUJQDP7DC3K2YSJEIPQ76PQXI'); |
| 24 | + test('fill form and submit redirects', async ({ page }) => { |
| 25 | + const createPage = new CreateInvoicePage(page); |
| 26 | + await createPage.goto(); |
36 | 27 |
|
37 | | - // Add another recipient |
38 | | - await page.click('button:has-text("+ Add Recipient")'); |
39 | | - const addresses = page.locator('input[placeholder="G... address"]'); |
40 | | - await addresses.nth(1).fill('GB2YDQRPJGLV5DQNGD5XBFN3FAUEY3QYLJZP3KYP7VJBDXCFCWDKM'); |
| 28 | + await createPage.fillRecipient('GBRPYHIL2CI3WHZDTOOQFC6EB4KJJGUJQDP7DC3K2YSJEIPQ76PQXI'); |
| 29 | + await createPage.fillAmount('100'); |
| 30 | + await createPage.clickNext(); |
| 31 | + await createPage.clickNext(); |
| 32 | + await createPage.clickNext(); |
41 | 33 |
|
42 | | - // Should show per-recipient amount |
43 | | - await expect(page.locator('text=/.*100.*USDC per recipient/')).toBeVisible(); |
| 34 | + await expect(createPage.submitButton).toBeEnabled(); |
| 35 | + }); |
44 | 36 | }); |
0 commit comments