This commit is contained in:
counterweight 2025-12-26 19:21:34 +01:00
parent c0999370c6
commit 4e1a339432
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
17 changed files with 393 additions and 91 deletions

View file

@ -0,0 +1,21 @@
/**
* Helper to reset the database before each test.
* Calls the /api/test/reset endpoint on the worker's backend.
*/
import { APIRequestContext } from "@playwright/test";
import { getBackendUrl } from "./backend-url";
/**
* Reset the database for the current worker.
* Truncates all tables and re-seeds base data.
*/
export async function resetDatabase(request: APIRequestContext): Promise<void> {
const backendUrl = getBackendUrl();
const response = await request.post(`${backendUrl}/api/test/reset`);
if (!response.ok()) {
const text = await response.text();
throw new Error(`Failed to reset database: ${response.status()} - ${text}`);
}
}