import { readFileSync } from "node:fs"; import { fileURLToPath } from "node:url"; import { expect } from "vitest"; import { test } from "@openwork/testkit"; import { LINK_STEP, parseGuideStep, TOTAL_GUIDE_STEPS, } from "../../ee/apps/den-web/app/(den)/_lib/install-guide"; const installScreenPath = fileURLToPath( new URL("../../ee/apps/den-web/app/(den)/_components/install-screen.tsx", import.meta.url), ); const denShellPath = fileURLToPath( new URL("../../ee/apps/den-web/app/(den)/_components/onboarding-shell.tsx", import.meta.url), ); const sharedShellPath = fileURLToPath( new URL("../../packages/ui/src/react/dithered-onboarding-shell.tsx", import.meta.url), ); function stepBody(source: string, testId: string) { const start = source.indexOf(`testId="${testId}"`); expect(start).toBeGreaterThan(-1); const end = source.indexOf("", start); expect(end).toBeGreaterThan(start); return source.slice(start, end); } test("the enterprise install guide is three steps ending in one copy-paste link", async ({ evidence }) => { const source = readFileSync(installScreenPath, "utf8"); const downloadStep = stepBody(source, "install-guide-step-download"); const openStep = stepBody(source, "install-guide-step-open"); const linkStep = stepBody(source, "install-guide-step-link"); expect(TOTAL_GUIDE_STEPS).toBe(3); expect(LINK_STEP).toBe(3); expect(parseGuideStep("2")).toBe(2); expect(parseGuideStep("3")).toBe(3); expect(parseGuideStep("4")).toBe(1); expect(parseGuideStep(null)).toBe(1); expect(parseGuideStep("nonsense")).toBe(1); // Step 1 downloads with every OS available; step 2 installs and opens in one // sentence; step 3 connects with the workspace address, keeping the OpenWork // link as the quiet backup. expect(downloadStep).toContain("DownloadPlatformGrid"); expect(downloadStep).toContain("Already installed? Skip to step 3"); expect(openStep).toContain('data-testid="install-app-ready"'); expect(openStep).toContain("advanceGuide(LINK_STEP)"); expect(openStep).toContain('{guidance.actions.join(" ")}'); expect(openStep).toContain(' { const installSource = readFileSync(installScreenPath, "utf8"); const denShell = readFileSync(denShellPath, "utf8"); const sharedShell = readFileSync(sharedShellPath, "utf8"); const shellUsages = installSource.match(/]*>/g) ?? []; expect(shellUsages.length).toBeGreaterThanOrEqual(4); for (const usage of shellUsages) { expect(usage).toContain('background="surface"'); } // The surface variant mirrors the signed-in organization picker field. expect(denShell).toContain('colorFront="#000000"'); expect(denShell).toContain('colorBack="#00000000"'); expect(denShell).toContain('type="2x2"'); expect(denShell).toContain("size={20.3}"); expect(denShell).toContain("scale={1.19}"); expect(denShell).toContain("bg-[var(--dls-surface)]"); expect(denShell).toContain("const shaderSpeed = reducedMotion ? 0 : 0.01;"); expect(denShell).toContain("useWebGlSupported"); // The pre-sign-in onboarding wash is untouched for every other flow. expect(sharedShell).toContain('colorFront="#8FB7E8"'); expect(sharedShell).toContain("bg-[#f8fbff]"); expect(sharedShell).toContain("const shaderSpeed = reducedMotion ? 0 : 0.012;"); expect((sharedShell.match(/