Updated to just use DATABASE_* in everything other than local docker.
This commit is contained in:
Stefan Lazic committed 2026-08-07 17:30:12 +01:00
1 parent 769d3f9ebc
commit 51de4f4ef5
19 files changed
+120 -56

No files matched your search

+8 -7
View File
@@ -2,16 +2,17 @@ import { execFileSync } from "node:child_process";
/**
* Applies migrations and loads the dev/demo seed data against whatever
* DATABASE_URL points at before the suite runs. Deliberately does not
* create or tear down the database itself — same division of
* responsibility as `npm run test:integration`, where the caller is
* responsible for pointing DATABASE_URL at a disposable Postgres.
* DATABASE_HOST/PORT/NAME/USER/PASSWORD point at before the suite runs.
* Deliberately does not create or tear down the database itself — same
* division of responsibility as `npm run test:integration`, where the
* caller is responsible for pointing these at a disposable database.
*/
export default function globalSetup() {
if (!process.env.DATABASE_URL) {
if (!process.env.DATABASE_HOST || !process.env.DATABASE_NAME || !process.env.DATABASE_USER) {
throw new Error(
"DATABASE_URL is not set. Point it at a disposable Postgres before running the e2e suite, e.g.\n" +
' DATABASE_URL="postgresql://user:pass@localhost:5432/nextchair_e2e" npm run test:e2e',
"Database connection is not configured. Point DATABASE_HOST, DATABASE_NAME, DATABASE_USER, and " +
"DATABASE_PASSWORD at a disposable MySQL database before running the e2e suite, e.g.\n" +
' DATABASE_HOST=localhost DATABASE_NAME=nextchair_e2e DATABASE_USER=user DATABASE_PASSWORD=pass npm run test:e2e',
);
}
+2 -2
View File
@@ -20,7 +20,7 @@ import { SEEDED, completeBookingFlow, signIn, uniqueEmail } from "./helpers";
test.describe.serial("owner administration journeys", () => {
test.afterAll(async () => {
const pool = createPool(buildMysqlPoolConfig(process.env.DATABASE_URL));
const pool = createPool(buildMysqlPoolConfig());
// Journey 7 creates a category/service with no deterministic id to
// upsert against on a re-run — clean up by name instead.
await pool.query("DELETE FROM `Service` WHERE name LIKE 'E2E Test Service%'");
@@ -108,7 +108,7 @@ test.describe.serial("owner administration journeys", () => {
// them from an earlier seed run their date is whatever it was back
// then, not necessarily still "N days from today" — read the real date
// straight from the database instead of predicting it from wall-clock time.
const pool = createPool(buildMysqlPoolConfig(process.env.DATABASE_URL));
const pool = createPool(buildMysqlPoolConfig());
const rows = await pool.query<{ id: string; start_at: Date; first_name: string; last_name: string }[]>(
"SELECT a.id, a.startAt as start_at, c.firstName as first_name, c.lastName as last_name" +
" FROM Appointment a JOIN CustomerProfile c ON c.id = a.customerId" +
+1 -1
View File
@@ -31,7 +31,7 @@ test.describe.serial("barber operations journeys", () => {
// safety net removes them directly regardless of how the tests above
// exited, on top of (not instead of) each test's own UI-driven cleanup.
test.afterAll(async () => {
const pool = createPool(buildMysqlPoolConfig(process.env.DATABASE_URL));
const pool = createPool(buildMysqlPoolConfig());
await pool.query("DELETE FROM `TimeOff` WHERE reason = 'E2E conflict test'");
await pool.query("DELETE FROM `Break` WHERE label = 'Afternoon tea'");
await pool.end();