65 lines
3.3 KiB
JavaScript
65 lines
3.3 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { gates, s02OnboardingTestFiles, shellCommand, validateGateConfig } from "./verify-onboarding-flow.mjs";
|
|
|
|
const expectedS02Tests = [
|
|
"apps/web/app/modules/onboarding/services/OnboardingService.single-user-tenant-flow.test.ts",
|
|
"apps/web/app/modules/onboarding/services/OnboardingSessionService.tenant-events.test.ts",
|
|
"apps/web/app/modules/onboarding/routes/api/sessions/OnboardingSessionsIndexApi.tenant-filter.test.ts",
|
|
];
|
|
|
|
describe("Tenant Auth onboarding flow runner configuration", () => {
|
|
it("references exactly the three onboarding tests and the Tenant Auth baseline gate", () => {
|
|
expect(s02OnboardingTestFiles).toEqual(expectedS02Tests);
|
|
expect(gates.map((gate) => gate.id)).toEqual(["vitest-tenantAuth-s02-onboarding-flow", "tenantAuth-baseline-gates"]);
|
|
|
|
const vitestGate = gates.find((gate) => gate.id === "vitest-tenantAuth-s02-onboarding-flow");
|
|
const baselineGate = gates.find((gate) => gate.id === "tenantAuth-baseline-gates");
|
|
|
|
expect(vitestGate?.args).toEqual(["exec", "vitest", "run", ...expectedS02Tests]);
|
|
expect(baselineGate?.args).toEqual(["run", "verify:tenant-auth-baseline"]);
|
|
expect(validateGateConfig(gates)).toEqual({ valid: true, errors: [] });
|
|
});
|
|
|
|
it("does not reference browser, E2E, Cypress, Playwright, or watch-mode commands", () => {
|
|
const commands = gates.map(shellCommand).join("\n");
|
|
|
|
expect(commands).not.toMatch(/\b(?:playwright|cypress|browser|e2e|watch)\b/i);
|
|
expect(commands).toContain("pnpm exec vitest run");
|
|
expect(commands).toContain("pnpm run verify:tenant-auth-baseline");
|
|
});
|
|
|
|
it("rejects missing test entries", () => {
|
|
const invalidGates = [
|
|
{ id: "vitest-tenantAuth-s02-onboarding-flow", command: "pnpm", args: ["exec", "vitest", "run", expectedS02Tests[0], expectedS02Tests[1]] },
|
|
{ id: "tenantAuth-baseline-gates", command: "pnpm", args: ["run", "verify:tenant-auth-baseline"] },
|
|
];
|
|
|
|
expect(validateGateConfig(invalidGates)).toMatchObject({ valid: false });
|
|
expect(validateGateConfig(invalidGates).errors.join("\n")).toContain(expectedS02Tests[2]);
|
|
});
|
|
|
|
it("rejects extra test entries", () => {
|
|
const invalidGates = [
|
|
{ id: "vitest-tenantAuth-s02-onboarding-flow", command: "pnpm", args: ["exec", "vitest", "run", ...expectedS02Tests, "apps/web/app/modules/onboarding/extra.test.ts"] },
|
|
{ id: "tenantAuth-baseline-gates", command: "pnpm", args: ["run", "verify:tenant-auth-baseline"] },
|
|
];
|
|
|
|
expect(validateGateConfig(invalidGates)).toMatchObject({ valid: false });
|
|
expect(validateGateConfig(invalidGates).errors.join("\n")).toContain("apps/web/app/modules/onboarding/extra.test.ts");
|
|
});
|
|
|
|
it("rejects E2E command references and baseline bypasses", () => {
|
|
const invalidGates = [
|
|
{ id: "vitest-tenantAuth-s02-onboarding-flow", command: "pnpm", args: ["exec", "vitest", "run", ...expectedS02Tests] },
|
|
{ id: "tenantAuth-baseline-gates", command: "pnpm", args: ["exec", "playwright", "test"] },
|
|
];
|
|
|
|
const validation = validateGateConfig(invalidGates);
|
|
|
|
expect(validation.valid).toBe(false);
|
|
expect(validation.errors.join("\n")).toContain("baseline gate must run pnpm run verify:tenant-auth-baseline");
|
|
expect(validation.errors.join("\n")).toContain("forbidden E2E/watch command reference");
|
|
});
|
|
});
|