Files
adolf/test/scripts/onboard-config-fixtures.test.ts
alvis bedb527145
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Vendor OpenClaw source as Adolf fork baseline
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11),
free to diverge. Tree copied sans upstream .git; upstream remote added for
future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19.
Preserves docs/ARCHITECTURE.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
2026-07-05 09:36:54 +00:00

210 lines
6.5 KiB
TypeScript

// Onboard Config Fixtures tests cover onboard E2E config writer/assertion helpers.
import { spawnSync } from "node:child_process";
import { readFileSync, writeFileSync } from "node:fs";
import path from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import { cleanupTempDirs, makeTempDir } from "../helpers/temp-dir.js";
const ASSERT_CONFIG_SCRIPT = "scripts/e2e/lib/onboard/assert-config.mjs";
const WRITE_CONFIG_SCRIPT = "scripts/e2e/lib/onboard/write-config.mjs";
const tempDirs: string[] = [];
afterEach(() => {
cleanupTempDirs(tempDirs);
});
function runScript(scriptPath: string, args: string[]) {
return spawnSync(process.execPath, [scriptPath, ...args], {
encoding: "utf8",
env: { ...process.env },
});
}
function readJson(file: string) {
return JSON.parse(readFileSync(file, "utf8"));
}
describe("onboard config fixture helpers", () => {
it("writes reset fixtures consumed by the reset assertion", () => {
const root = makeTempDir(tempDirs, "openclaw-onboard-config-");
const configPath = path.join(root, "openclaw.json");
const writeResult = runScript(WRITE_CONFIG_SCRIPT, ["reset", configPath]);
expect(writeResult.status).toBe(0);
expect(readJson(configPath)).toEqual({
meta: {},
agents: { defaults: { workspace: "/root/old" } },
gateway: { mode: "remote", remote: { url: "ws://old.example:18789", token: "old-token" } },
});
expect(readFileSync(configPath, "utf8")).toMatch(/\n$/u);
writeFileSync(
configPath,
`${JSON.stringify(
{
gateway: { mode: "local" },
wizard: { lastRunMode: "local" },
},
null,
2,
)}\n`,
"utf8",
);
const assertResult = runScript(ASSERT_CONFIG_SCRIPT, ["reset", configPath]);
expect(assertResult.status).toBe(0);
expect(assertResult.stderr).toBe("");
});
it("writes skills fixtures consumed by the skills assertion", () => {
const root = makeTempDir(tempDirs, "openclaw-onboard-config-skills-");
const configPath = path.join(root, "openclaw.json");
const writeResult = runScript(WRITE_CONFIG_SCRIPT, ["skills", configPath]);
expect(writeResult.status).toBe(0);
expect(readJson(configPath)).toEqual({
meta: {},
skills: { allowBundled: ["__none__"], install: { nodeManager: "bun" } },
});
writeFileSync(
configPath,
`${JSON.stringify(
{
...readJson(configPath),
wizard: { lastRunCommand: "configure", lastRunMode: "local" },
},
null,
2,
)}\n`,
"utf8",
);
const assertResult = runScript(ASSERT_CONFIG_SCRIPT, ["skills", configPath]);
expect(assertResult.status).toBe(0);
expect(assertResult.stderr).toBe("");
});
it("accepts local and remote onboard assertion fixtures", () => {
const root = makeTempDir(tempDirs, "openclaw-onboard-config-success-");
const workspace = path.join(root, "workspace");
const localConfigPath = path.join(root, "local.json");
const remoteConfigPath = path.join(root, "remote.json");
writeFileSync(
localConfigPath,
`${JSON.stringify(
{
agents: { defaults: { workspace } },
gateway: { bind: "loopback", mode: "local", tailscale: { mode: "off" } },
wizard: {
lastRunAt: "2026-01-01T00:00:00.000Z",
lastRunCommand: "onboard",
lastRunMode: "local",
lastRunVersion: "test-version",
},
},
null,
2,
)}\n`,
"utf8",
);
writeFileSync(
remoteConfigPath,
`${JSON.stringify(
{
gateway: {
mode: "remote",
remote: { url: "ws://gateway.local:18789", token: "remote-token" },
},
wizard: { lastRunMode: "remote" },
},
null,
2,
)}\n`,
"utf8",
);
const localResult = runScript(ASSERT_CONFIG_SCRIPT, [
"local-basic",
localConfigPath,
workspace,
]);
const remoteResult = runScript(ASSERT_CONFIG_SCRIPT, [
"remote-non-interactive",
remoteConfigPath,
]);
expect(localResult.status).toBe(0);
expect(localResult.stderr).toBe("");
expect(remoteResult.status).toBe(0);
expect(remoteResult.stderr).toBe("");
});
it("accepts channel configuration assertions for scrubbed channel secrets", () => {
const root = makeTempDir(tempDirs, "openclaw-onboard-config-channels-");
const configPath = path.join(root, "channels.json");
writeFileSync(
configPath,
`${JSON.stringify(
{
wizard: { lastRunCommand: "configure", lastRunMode: "local" },
},
null,
2,
)}\n`,
"utf8",
);
const result = runScript(ASSERT_CONFIG_SCRIPT, ["channels", configPath]);
expect(result.status).toBe(0);
expect(result.stderr).toBe("");
});
it("reports assertion mismatches with stable field labels", () => {
const root = makeTempDir(tempDirs, "openclaw-onboard-config-mismatch-");
const configPath = path.join(root, "openclaw.json");
writeFileSync(
configPath,
`${JSON.stringify(
{
gateway: { mode: "remote", bind: "lan", tailscale: { mode: "on" } },
wizard: { lastRunCommand: "configure", lastRunMode: "remote" },
},
null,
2,
)}\n`,
"utf8",
);
const result = runScript(ASSERT_CONFIG_SCRIPT, [
"local-basic",
configPath,
path.join(root, "workspace"),
]);
expect(result.status).toBe(1);
expect(result.stderr).toContain("agents.defaults.workspace mismatch");
expect(result.stderr).toContain("gateway.mode mismatch");
expect(result.stderr).toContain("gateway.bind mismatch");
expect(result.stderr).toContain("gateway.tailscale.mode mismatch");
expect(result.stderr).toContain("wizard.lastRunCommand mismatch");
});
it("rejects unknown writer and assertion scenarios", () => {
const root = makeTempDir(tempDirs, "openclaw-onboard-config-unknown-");
const configPath = path.join(root, "openclaw.json");
writeFileSync(configPath, "{}\n", "utf8");
const writeResult = runScript(WRITE_CONFIG_SCRIPT, ["unknown", configPath]);
const assertResult = runScript(ASSERT_CONFIG_SCRIPT, ["unknown", configPath]);
expect(writeResult.status).not.toBe(0);
expect(writeResult.stderr).toContain("unknown config scenario: unknown");
expect(assertResult.status).not.toBe(0);
expect(assertResult.stderr).toContain("unknown onboard assertion scenario: unknown");
});
});