01f8974314
CI / Architecture Guardrails (pull_request) Successful in 2m59s
CI / Typecheck (pull_request) Successful in 6m41s
CI / Lint (pull_request) Successful in 4m18s
CI / Assistant Split Regression (pull_request) Successful in 5m6s
CI / Unit Tests (pull_request) Successful in 7m21s
CI / Build (pull_request) Successful in 5m21s
CI / Fresh-Linux Docker Deploy (pull_request) Failing after 38s
CI / E2E Tests (pull_request) Successful in 3m28s
CI / Release Images (pull_request) Has been skipped
- docker-compose.yml / .prod.yml / .ci.yml: project names, POSTGRES_DB/USER, pg_isready, DATABASE_URL, volume names (nexus_pgdata, nexus_prod_*) - .github/workflows/ci.yml: POSTGRES_PASSWORD, pg_isready, psql credentials, GRANT statements, POSTGRES_PASSWORD=nexus_dev for Docker Deploy job - scripts/db-target-guard.mjs: expectedDatabase default, NEXUS_EXPECTED_DB_NAME - scripts/prisma-with-env.mjs, e2e/test-server.mjs: env-var rename - packages/db/src/safe-destructive-env.ts + reset-dispo-import.ts: DB name set - packages/db/src/destructive-db-guard.ts: PROTECTED_DATABASE_NAMES → "nexus" - packages/db/src/destructive-db-guard.test.ts: all fixture DB names + comments - .env.example, tooling/deploy/deploy.env.example: DATABASE_URL, image refs - packages/api: Redis channel/key prefixes (rbac-invalidate, sse, ratelimit), logger service name, app-base-url log prefix - E2E: DB container names, localStorage/sessionStorage keys, email domains - scripts: architecture-guardrails filter, export/import-dev-seed defaults, harden-postgres defaults, start.sh pg_isready, worktree-hygiene fixture - tooling/migrate/rename-to-nexus.sh: new maintenance-window cutover script Only intentional capakraken survivor: anonymization.ts DEFAULT_ANONYMIZATION_SEED (functional cryptographic constant — changing it would invalidate stored aliases). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
88 lines
3.4 KiB
TypeScript
88 lines
3.4 KiB
TypeScript
/**
|
|
* E2E — Invite flow
|
|
*
|
|
* Requires:
|
|
* - Dev server running on http://localhost:3100
|
|
* - Mailhog running on http://localhost:8025
|
|
* - SMTP_HOST=localhost, SMTP_PORT=1025, SMTP_TLS=false configured
|
|
*
|
|
* Flow:
|
|
* 1. Admin opens /admin/users → clicks "Invite User"
|
|
* 2. Fills in a unique test email address + role USER
|
|
* 3. Waits for "Invitation sent successfully." message in modal
|
|
* 4. Reads the invite email from Mailhog
|
|
* 5. Visits the invite link in a separate page context
|
|
* 6. Sets a password → account created
|
|
* 7. Signs in with the new credentials → lands on dashboard
|
|
*/
|
|
import { expect, test } from "@playwright/test";
|
|
import { STORAGE_STATE } from "../../playwright.dev.config.js";
|
|
import { clearMailhog, extractUrlFromEmail, getLatestEmailTo } from "./helpers.js";
|
|
|
|
test.describe("invite flow", () => {
|
|
test.use({ storageState: STORAGE_STATE.admin });
|
|
|
|
test.beforeEach(async () => {
|
|
await clearMailhog();
|
|
});
|
|
|
|
test("admin invites a new user and invited user can sign in", async ({ page, browser }) => {
|
|
const testEmail = `invite-e2e-${Date.now()}@nexus.test`;
|
|
|
|
// Step 1: Navigate to admin users page
|
|
await page.goto("/admin/users");
|
|
await page.waitForLoadState("networkidle");
|
|
|
|
// Step 2: Open invite modal
|
|
await page.click('button:has-text("Invite User")');
|
|
// Wait for the modal heading — AnimatedModal does not use role="dialog"
|
|
await page.waitForSelector("text=Invite User", { state: "visible" });
|
|
|
|
// Step 3: Fill in invite form
|
|
await page.fill('input[type="email"]', testEmail);
|
|
|
|
// Step 4: Submit
|
|
await page.click('button:has-text("Send Invite")');
|
|
|
|
// Step 5: Wait for success message (exact text from InviteUserModal.tsx)
|
|
await expect(page.locator("text=Invitation sent successfully.")).toBeVisible({
|
|
timeout: 10_000,
|
|
});
|
|
|
|
// Step 6: Read invite email from Mailhog
|
|
const email = await getLatestEmailTo(testEmail, { timeoutMs: 15_000 });
|
|
const inviteUrl = extractUrlFromEmail(email, "/invite/");
|
|
|
|
// Strip base URL — Playwright navigates relative to baseURL
|
|
const invitePath = new URL(inviteUrl).pathname;
|
|
|
|
// Step 7: Accept invite in a fresh unauthenticated context (no admin cookies)
|
|
const inviteContext = await browser.newContext();
|
|
const invitePage = await inviteContext.newPage();
|
|
await invitePage.goto(`http://localhost:3100${invitePath}`);
|
|
|
|
// Wait for the accept-invite form
|
|
await expect(invitePage.locator("text=Accept invitation")).toBeVisible({ timeout: 10_000 });
|
|
|
|
// Fill both password fields using consistent nth() indexing
|
|
const passwordInputs = invitePage.locator('input[type="password"]');
|
|
await passwordInputs.nth(0).fill("TestPass123!");
|
|
await passwordInputs.nth(1).fill("TestPass123!");
|
|
await invitePage.click('button[type="submit"]');
|
|
|
|
// Account created confirmation
|
|
await expect(invitePage.locator("text=Account created")).toBeVisible({ timeout: 15_000 });
|
|
|
|
// Step 8: Sign in with new credentials
|
|
await invitePage.click('button:has-text("Go to sign in")');
|
|
await invitePage.waitForURL(/\/auth\/signin/);
|
|
|
|
await invitePage.fill('input[type="email"]', testEmail);
|
|
await invitePage.fill('input[type="password"]', "TestPass123!");
|
|
await invitePage.click('button[type="submit"]');
|
|
|
|
await invitePage.waitForURL(/\/(dashboard|resources)/, { timeout: 15_000 });
|
|
await inviteContext.close();
|
|
});
|
|
});
|