(page: Page, email: string, password: string)
| 23 | } |
| 24 | |
| 25 | export async function login(page: Page, email: string, password: string) { |
| 26 | await page.goto('/login', { waitUntil: 'load' }); |
| 27 | await page.fill('input[name="email"]', email); |
| 28 | await page.fill('input[name="password"]', password); |
| 29 | |
| 30 | // Wait for navigation to complete or error to appear |
| 31 | try { |
| 32 | await Promise.all([page.waitForURL('/'), page.click('button[type="submit"]')]); |
| 33 | } catch (error) { |
| 34 | // If navigation fails, check for errors |
| 35 | const errorMsg = await page |
| 36 | .locator('.error-messages') |
| 37 | .textContent() |
| 38 | .catch(() => ''); |
| 39 | if (errorMsg) { |
| 40 | throw new Error(`Login failed: ${errorMsg}`); |
| 41 | } |
| 42 | throw error; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | export async function logout(page: Page) { |
| 47 | await page.click('a[href="/settings"]'); |
no outgoing calls
no test coverage detected