19 lines
681 B
TypeScript
19 lines
681 B
TypeScript
import type { Page } from "@playwright/test";
|
|
import { expect } from "@playwright/test";
|
|
|
|
export async function loginViaUi(page: Page): Promise<void> {
|
|
const email = process.env.E2E_USER_EMAIL;
|
|
const password = process.env.E2E_USER_PASSWORD;
|
|
|
|
if (!(email && password)) {
|
|
throw new Error("E2E requires E2E_USER_EMAIL and E2E_USER_PASSWORD in apps/server/.env.e2e.");
|
|
}
|
|
|
|
await page.goto("/login");
|
|
await page.locator("#login-email").fill(email);
|
|
await page.locator("#login-password").fill(password);
|
|
await page.locator("#login-submit").click();
|
|
await expect(page).not.toHaveURL(/\/login(?:\?|$)/);
|
|
await expect(page.locator("#account-menu")).toBeVisible();
|
|
}
|