|
| 1 | +import { test, expect } from '@playwright/test'; |
| 2 | +import { TestFaucet } from './setupTest/TestFaucet'; |
| 3 | + |
| 4 | +test.setTimeout(120_000); |
| 5 | + |
| 6 | +test.describe('Federation Join + Lightning Flow', () => { |
| 7 | + let faucet: TestFaucet; |
| 8 | + |
| 9 | + test.beforeEach(() => { |
| 10 | + faucet = new TestFaucet(); |
| 11 | + }); |
| 12 | + |
| 13 | + test('join federation and do a receive/send cycle', async ({ page }) => { |
| 14 | + await page.goto('/'); |
| 15 | + await expect(page).toHaveTitle(/Fedimint/); |
| 16 | + |
| 17 | + // Step 1: Join federation |
| 18 | + await test.step('Join federation with invite code', async () => { |
| 19 | + const inviteCode = await faucet.getInviteCode(); |
| 20 | + expect(inviteCode).toBeTruthy(); |
| 21 | + |
| 22 | + await page.getByTestId('invite-code-input').fill(inviteCode); |
| 23 | + await page.getByTestId('continue-button').click(); |
| 24 | + |
| 25 | + await expect(page.getByTestId('federation-title')).toContainText('Fedi Testnet'); |
| 26 | + await expect(page.getByTestId('wallet-main')).toContainText('Onchain deposit:'); |
| 27 | + }); |
| 28 | + |
| 29 | + // Step 2: Create invoice |
| 30 | + let invoice: string; |
| 31 | + await test.step('Create invoice', async () => { |
| 32 | + await page.getByRole('button', { name: /Receive/ }).click(); |
| 33 | + await page.getByTestId('amount-input').fill('2'); |
| 34 | + await page.getByTestId('description-input').fill('this is an invoice'); |
| 35 | + await page.getByRole('button', { name: /Create/ }).click(); |
| 36 | + |
| 37 | + invoice = await page.getByTestId('invoice-output').inputValue(); |
| 38 | + expect(invoice).toMatch(/^ln/i); |
| 39 | + }); |
| 40 | + |
| 41 | + // Step 3: Pay invoice via faucet |
| 42 | + await test.step('Pay invoice using faucet', async () => { |
| 43 | + await faucet.payFaucetInvoice(invoice); |
| 44 | + await expect(page.getByText(/Payment Received/)).toBeVisible(); |
| 45 | + }); |
| 46 | + |
| 47 | + // Step 4: Verify balance increased |
| 48 | + await test.step('Verify balance', async () => { |
| 49 | + await expect(page.getByTestId('wallet-balance')).toContainText('2'); |
| 50 | + }); |
| 51 | + |
| 52 | + await page.getByRole('button', { name: ' Ecash' }).click(); |
| 53 | + |
| 54 | + await page.getByRole('textbox', { name: 'Enter amount in sat:' }).fill('1'); |
| 55 | + await page.getByRole('button', { name: ' Generate & Spend' }).click(); |
| 56 | + |
| 57 | + const notes = await page.getByRole('textbox', { name: 'Generated notes:' }).inputValue(); |
| 58 | + |
| 59 | + await page.getByRole('textbox', { name: 'Enter or Scan the notes:' }).fill(notes); |
| 60 | + await page.getByRole('button', { name: ' Confirm Redeem' }).click(); |
| 61 | + }); |
| 62 | +}); |
0 commit comments