e2e: add medium-priority Playwright coverage (#44)
All checks were successful
Build and Push Image / docker-build-and-push (push) Successful in 2m29s
All checks were successful
Build and Push Image / docker-build-and-push (push) Successful in 2m29s
Co-authored-by: Shaun Campbell <shaun@campbellwireless.net> Reviewed-on: #44 Co-authored-by: AI Agent <ai-agent@campbellwireless.net> Co-committed-by: AI Agent <ai-agent@campbellwireless.net>
This commit was merged in pull request #44.
This commit is contained in:
27
e2e/helpers/auth.ts
Normal file
27
e2e/helpers/auth.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { expect, type Page } from '@playwright/test';
|
||||
import { TEST_USERS } from '../setup/test-users.js';
|
||||
|
||||
const LOGIN_URL = '/trips/login';
|
||||
const DASHBOARD_URL = '/trips/dashboard';
|
||||
const PROFILE_URL = '/trips/profile';
|
||||
|
||||
export async function loginAsLocalUser(
|
||||
page: Page,
|
||||
username: string,
|
||||
password: string
|
||||
): Promise<void> {
|
||||
await page.goto(LOGIN_URL);
|
||||
await page.fill('input[name="identifier"]', username);
|
||||
await page.fill('input[name="password"]', password);
|
||||
await page.click('button[type="submit"]:has-text("Sign in locally")');
|
||||
await page.waitForURL(`**${DASHBOARD_URL}`, { timeout: 15_000 });
|
||||
}
|
||||
|
||||
export async function ensureSelfProfile(page: Page, email = TEST_USERS.regular.email): Promise<void> {
|
||||
await page.goto(PROFILE_URL);
|
||||
await page.fill('#first_name', 'E2E');
|
||||
await page.fill('#last_name', 'User');
|
||||
await page.fill('#email', email);
|
||||
await page.getByRole('button', { name: 'Save profile' }).click();
|
||||
await expect(page.getByRole('heading', { name: 'My Profile' })).toBeVisible();
|
||||
}
|
||||
Reference in New Issue
Block a user