Files
loki/scripts/test/setup-redirects-when-done.ts
CatoandClaude Opus 5.5 f81e33c89a fix(public-copy): pricing, docs, download, whitepaper, README, support and essays say what Loki does today (#997)
- /pricing + plans.ts: no "local-first", no "your own box", no cross-model
  verification; agents = Claude, Codex, Cursor, Antigravity, Grok; free while
  prices are not announced; Pro "Recommended" badge removed.
- /docs/quickstart: OrangeCat-first sign-up, step numbers read from the step
  table, new "Start from an idea" flow (describe -> interview -> Make it happen
  -> repo in the bitbaum org -> <name>.orangecat.ch for supported starters).
- /docs/feedback-widget: current labels (Widget setup, Implement, Synthesize),
  owner notes start a build (40/day per project) while visitor text waits,
  data-fc-avoid / data-fc-place, Chat mode, Watch the fix, /my-feedback, no
  daily digest. Docs index links point at the right pages.
- /download: agent list without OpenClaw, Intel Mac stated.
- Whitepaper: autopilot (not the removed Groq router), cloud builder only for
  eligible accounts, project-keyed handoffs, runner-owned lifecycle, tiers that
  match plans.ts, self-hosting possible but undocumented.
- README: beta, sign-in providers, deploy workflow, Quality Bar list fixed.
- /support: Cato card (pointed at OrangeCat's home page) removed; three parts.
- /setup redirects to /sign-in once any account exists.
- Essays describing the May-Aug architecture carry supersededBy and render a
  dated notice pointing at /whitepaper.

Tests: plans-copy-truth, setup-redirects-when-done, thought-superseded.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-01 02:33:09 -07:00

41 lines
1.5 KiB
TypeScript

/**
* /setup must not offer "Create your admin account" once setup is done.
*
* Before 2026-10-01 the page was a client component that always rendered the
* form; the API answered 409 "Setup already complete" after the visitor had
* typed a name and two passwords. A dead end, publicly reachable.
*
* Pins both halves: the decision (any account → sign-in, none → the form) and
* that the page actually asks it on the server before rendering anything.
*
* Run: npx tsx scripts/test/setup-redirects-when-done.ts
*/
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { setupRedirectFor } from "@/lib/setup-gate";
import { ROUTES } from "@/config/auth";
const page = readFileSync(new URL("../../src/app/setup/page.tsx", import.meta.url), "utf8");
assert.equal(setupRedirectFor(0), null, "a fresh install shows the setup form");
assert.equal(setupRedirectFor(1), ROUTES.SIGN_IN, "one account → sign-in");
assert.equal(setupRedirectFor(7), ROUTES.SIGN_IN, "many accounts → sign-in");
assert.ok(
!/^\s*["']use client["']/m.test(page),
"setup/page.tsx must be a server component — a client page cannot redirect before it renders the form",
);
assert.match(
page,
/setupRedirectFor\(await getUserCount\(\)\)/,
"page asks the gate with the live count",
);
assert.match(page, /redirect\(/, "page redirects when the gate says so");
assert.match(
page,
/force-dynamic/,
"the answer depends on the live DB, never a build-time snapshot",
);
console.log("setup-redirects-when-done: ok");