Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions apps/e2e/e2e.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { randomBytes } from "node:crypto";
import { existsSync, readFileSync } from "node:fs";
import { resolve } from "node:path";
import { parseEnv } from "node:util";
import { web } from "@e2e-dev/web";
import { gateway } from "ai";
Expand All @@ -24,10 +25,10 @@ export default {
// Never reuse a running dev server: these overrides are what make a
// throwaway signup safe. Empty strings beat .env.local in Next's loader.
command: {
executable: "pnpm",
// Not `pnpm exec next`: the child env drops CI, so pnpm's pre-run
// dependency check tries to reinstall and aborts for want of a TTY.
executable: resolve("../web/node_modules/.bin/next"),
args: [
"exec",
"next",
"dev",
"--turbopack",
"--hostname",
Expand Down
20 changes: 14 additions & 6 deletions apps/e2e/tests/invitation-seed.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { randomUUID } from "node:crypto";
import { readFileSync } from "node:fs";
import { existsSync, readFileSync } from "node:fs";
import { parseEnv } from "node:util";
import pg from "pg";

// The dashboard under test runs against the dev database, so the invitation is
// written straight to it rather than through "invite member", which would also
// send a real email.
const databaseUrl = parseEnv(
readFileSync("../web/.env.local", "utf8")
).DATABASE_URL;
// send a real email. Same precedence as the app: .env.local wins locally; CI
// has none and passes DATABASE_URL. Read lazily: this module loads at
// collection time, before any test needs the database.
function resolveDatabaseUrl() {
if (existsSync("../web/.env.local")) {
return parseEnv(readFileSync("../web/.env.local", "utf8")).DATABASE_URL;
}
return process.env.DATABASE_URL;
}

export type SeededInvitation = {
id: string;
Expand All @@ -27,8 +32,11 @@ export async function seedInvitation({
}: {
inviteeHasAccount: boolean;
}) {
const databaseUrl = resolveDatabaseUrl();
if (!databaseUrl) {
throw new Error("DATABASE_URL missing from apps/web/.env.local");
throw new Error(
"DATABASE_URL missing: set it in apps/web/.env.local or the environment"
);
}

const runId = randomUUID().slice(0, 8);
Expand Down
Loading