droboticflow/tests/frontend/devboot.test.mjs
d-robotics 58e0e50570
Some checks failed
web-ci / checks (push) Has been cancelled
web-ci / checks (pull_request) Has been cancelled
🧪 Retro 2026-10-12: CI gate, known-failure baselines, devboot regression test, workbench smoke, review standards
Six follow-ups from the round8-12 hotfix retrospective:

- web-ci.yml: lint + Go/frontend tests on every push and PR (nothing ran
  app checks before; the round10 dev-mode regression shipped green)
- tests/known-failures.json + check-test-baseline.mjs: gate by exact
  failing-test id instead of hand-counted failure totals (14 frontend,
  70 Go upstream debts recorded from the dev tip)
- devboot.test.mjs: boots the real Vite dev server and pins the movi
  loader contract that broke round10 (query-less DEV url, /vendor stays
  off the module pipeline)
- scripts/local/smoke-workbench.mjs: pre-release smoke covering the
  seven recurring acceptance points (login/pool/claim/play-while-loading/
  captions/4x/playhead), 3x green against the local replica
- docs/CODING_STANDARDS.md + AGENTS pointer: eligibility flags are
  server-shipped, the UI renders them (rounds 9+12 lesson)
- vendor README host-element quirks section, HANDOFF gate pointers and
  movi-path verification rule, perf-audit report pinned with the
  post-round12 production 500 observation
- husky pre-commit: lint-staged (repo prettier scope) + tsc + gofmt
- gofmt: restore lint:go green on the dev tip (drift shipped silently
  in the perf merge and round12 because nothing gated it)
2026-10-12 18:07:02 +05:30

59 lines
2.7 KiB
JavaScript

// Dev-boot regression guard (2026-10-12 round10 class): a source-level import
// of a public-dir /vendor/ asset with a cache-bust query ("?v=...") broke every
// Vite dev page with an error overlay while the production build stayed green.
// This test boots the real dev server and pins the contract from three sides:
// the entry pipeline is healthy, the movi loader never routes /vendor assets
// through the module pipeline in DEV, and the prod cache-bust URL — if anyone
// re-imports it from source — is exactly the shape the pipeline rejects.
import { test } from "node:test";
import assert from "node:assert/strict";
import { createServer } from "vite";
test("vite dev boots and keeps the movi loader off the module pipeline", async () => {
const server = await createServer({
root: process.cwd(),
logLevel: "error",
server: { host: "127.0.0.1", port: 0 },
});
await server.listen();
try {
const origin = new URL(server.resolvedUrls.local[0]).origin;
// 1) The dev transform pipeline itself is healthy on the app entry.
const entry = await server.transformRequest("/src/main.tsx");
assert.ok(entry, "dev server must transform the app entry module");
// 2) The real loader module, executed in DEV mode, must emit a query-less
// /vendor URL: dev serves public assets as static files only, and a
// query defeats the static resolver (the round10 overlay break).
const movi = await server.ssrLoadModule("/src/lib/movi-player.ts");
assert.ok(movi.MOVI_ELEMENT_CACHE_BUST, "cache-bust marker must stay defined");
assert.equal(
new URL(movi.MOVI_ELEMENT_JS_URL, origin).search,
"",
"DEV movi URL must not carry a cache-bust query (round10 regression class)",
);
// 3) That DEV URL must be fetchable as a plain static asset (script-tag path).
const asset = await fetch(`${origin}${movi.MOVI_ELEMENT_JS_URL}`);
assert.equal(asset.status, 200, "dev server must statically serve the movi element script");
// 4) Negative control — the prod-shaped URL is exactly what the module
// pipeline rejects; this is why importing /vendor assets from source is
// forbidden in dev and the loader uses a script tag there instead.
await assert.rejects(
server.transformRequest(
`/vendor/movi-player-${movi.MOVI_VERSION}/element.slim.js?v=${movi.MOVI_ELEMENT_CACHE_BUST}`,
),
/Failed to load url/,
"module pipeline must keep refusing /vendor assets (documented break class)",
);
// 5) The shell page itself still responds.
const index = await fetch(`${origin}/`);
assert.equal(index.status, 200, "dev server must serve the app shell");
} finally {
await server.close();
}
});