working
This commit is contained in:
parent
c0999370c6
commit
4e1a339432
17 changed files with 393 additions and 91 deletions
|
|
@ -1,11 +1,35 @@
|
|||
import { test } from "@playwright/test";
|
||||
import { resetDatabase } from "./reset-db";
|
||||
|
||||
/**
|
||||
* Set language to English for e2e tests.
|
||||
* E2E tests should only test in English according to requirements.
|
||||
* This is applied globally via test.beforeEach in the setup file.
|
||||
*
|
||||
* Also sets NEXT_PUBLIC_API_URL based on worker index so each worker
|
||||
* connects to its own backend instance, and resets the database before
|
||||
* each test for isolation.
|
||||
*/
|
||||
test.beforeEach(async ({ context }) => {
|
||||
test.beforeEach(async ({ context, request }, testInfo) => {
|
||||
// Set API URL based on worker index
|
||||
// Each worker gets its own backend (port 8001 + workerIndex)
|
||||
const workerIndex = testInfo.workerIndex;
|
||||
const basePort = parseInt(process.env.E2E_PORT_START || "8001", 10);
|
||||
const backendPort = basePort + workerIndex;
|
||||
const backendUrl = `http://localhost:${backendPort}`;
|
||||
|
||||
// Set environment variable for this test run
|
||||
process.env.NEXT_PUBLIC_API_URL = backendUrl;
|
||||
|
||||
// Reset database before each test for isolation
|
||||
try {
|
||||
await resetDatabase(request);
|
||||
} catch (error) {
|
||||
// If reset fails, log but don't fail the test
|
||||
// This allows tests to run even if reset endpoint is unavailable
|
||||
console.warn(`Failed to reset database: ${error}`);
|
||||
}
|
||||
|
||||
// Add init script to set English language before any page loads
|
||||
// This must be called before any page.goto() calls
|
||||
await context.addInitScript(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue