baa-conductor


baa-conductor / tests / control-api
im_wower  ·  2026-03-26

control-api-smoke.test.mjs

 1import assert from "node:assert/strict";
 2import { existsSync, readFileSync } from "node:fs";
 3import path from "node:path";
 4import test from "node:test";
 5import { fileURLToPath } from "node:url";
 6
 7const repoRoot = path.resolve(
 8  path.dirname(fileURLToPath(import.meta.url)),
 9  "../.."
10);
11
12function repoPath(...segments) {
13  return path.join(repoRoot, ...segments);
14}
15
16test("legacy control-api worker entrypoints are no longer part of the repo", () => {
17  assert.equal(
18    existsSync(repoPath("apps", "control-api-worker", "local", "harness.mjs")),
19    false
20  );
21  assert.equal(
22    existsSync(repoPath("apps", "control-api-worker", "wrangler.jsonc")),
23    false
24  );
25  assert.equal(
26    existsSync(repoPath("apps", "control-api-worker", ".gitignore")),
27    false
28  );
29});
30
31test("legacy cloudflare and D1 helper entrypoints are removed with the worker", () => {
32  assert.equal(
33    existsSync(repoPath("ops", "cloudflare", "deploy-control-api-worker.sh")),
34    false
35  );
36  assert.equal(
37    existsSync(
38      repoPath("ops", "cloudflare", "apply-control-api-d1-migrations.sh")
39    ),
40    false
41  );
42  assert.equal(
43    existsSync(
44      repoPath("ops", "cloudflare", "control-api-worker.secrets.example.env")
45    ),
46    false
47  );
48  assert.equal(
49    existsSync(
50      repoPath("scripts", "cloudflare", "prepare-control-api-local-db.mjs")
51    ),
52    false
53  );
54});
55
56test("lockfile no longer keeps the removed control-api worker importer", () => {
57  const lockfile = readFileSync(repoPath("pnpm-lock.yaml"), "utf8");
58
59  assert.equal(lockfile.includes("apps/control-api-worker:"), false);
60});
61
62test("runtime static assets keep canonical names and label legacy fallbacks", () => {
63  const conductorTemplate = readFileSync(
64    repoPath("ops", "launchd", "so.makefile.baa-conductor.plist"),
65    "utf8"
66  );
67  const installMini = readFileSync(
68    repoPath("scripts", "runtime", "install-mini.sh"),
69    "utf8"
70  );
71
72  const canonicalIndex = conductorTemplate.indexOf("BAA_CONDUCTOR_PUBLIC_API_BASE");
73  const legacyIndex = conductorTemplate.indexOf("BAA_CONTROL_API_BASE");
74
75  assert.notEqual(canonicalIndex, -1);
76  assert.notEqual(legacyIndex, -1);
77  assert.ok(canonicalIndex < legacyIndex);
78  assert.match(
79    conductorTemplate,
80    /legacy compatibility fallback/
81  );
82  assert.match(
83    installMini,
84    /Defaults to ~\/\.config\/baa-conductor\/runtime-secrets\.env\./
85  );
86  assert.match(
87    installMini,
88    /Falls back to legacy[\s\S]*control-api-worker\.secrets\.env[\s\S]*only if the default file is missing\./
89  );
90});