working
This commit is contained in:
parent
c0999370c6
commit
4e1a339432
17 changed files with 393 additions and 91 deletions
|
|
@ -4,9 +4,12 @@ import { Page } from "@playwright/test";
|
|||
* Auth helpers for e2e tests.
|
||||
*/
|
||||
|
||||
const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000";
|
||||
import { getBackendUrl } from "./backend-url";
|
||||
|
||||
export { API_URL };
|
||||
// Use dynamic backend URL based on worker index
|
||||
// Note: API_URL is evaluated at module load time, so it may use default value
|
||||
// For dynamic per-test URLs, use getBackendUrl() directly
|
||||
export const getApiUrl = () => getBackendUrl();
|
||||
|
||||
export function getRequiredEnv(name: string): string {
|
||||
const value = process.env[name];
|
||||
|
|
@ -30,23 +33,10 @@ export async function clearAuth(page: Page) {
|
|||
await page.context().clearCookies();
|
||||
}
|
||||
|
||||
export async function setEnglishLanguage(page: Page) {
|
||||
// Set English language in localStorage
|
||||
await page.evaluate(() => {
|
||||
window.localStorage.setItem("arbret-locale", "en");
|
||||
});
|
||||
}
|
||||
|
||||
export async function loginUser(page: Page, email: string, password: string) {
|
||||
await page.goto("/login");
|
||||
// Set language after navigation to ensure localStorage is available
|
||||
await setEnglishLanguage(page);
|
||||
// Reload to apply language setting
|
||||
await page.reload();
|
||||
await page.fill('input[type="email"]', email);
|
||||
await page.fill('input[type="password"]', password);
|
||||
await page.click('button[type="submit"]');
|
||||
await page.waitForURL((url) => !url.pathname.includes("/login"), { timeout: 10000 });
|
||||
// Set language again after navigation to new page
|
||||
await setEnglishLanguage(page);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue