(page: Page, username: string, email: string, password: string)
| 1 | import { Page } from '@playwright/test'; |
| 2 | |
| 3 | export async function register(page: Page, username: string, email: string, password: string) { |
| 4 | await page.goto('/register', { waitUntil: 'load' }); |
| 5 | await page.fill('input[name="username"]', username); |
| 6 | await page.fill('input[name="email"]', email); |
| 7 | await page.fill('input[name="password"]', password); |
| 8 | |
| 9 | // Wait for navigation to complete or error to appear |
| 10 | try { |
| 11 | await Promise.all([page.waitForURL('/'), page.click('button[type="submit"]')]); |
| 12 | } catch (error) { |
| 13 | // If navigation fails, check for errors |
| 14 | const errorMsg = await page |
| 15 | .locator('.error-messages') |
| 16 | .textContent() |
| 17 | .catch(() => ''); |
| 18 | if (errorMsg) { |
| 19 | throw new Error(`Registration failed: ${errorMsg}`); |
| 20 | } |
| 21 | throw error; |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | export async function login(page: Page, email: string, password: string) { |
| 26 | await page.goto('/login', { waitUntil: 'load' }); |
no outgoing calls
no test coverage detected