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
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
123 lines
4.7 KiB
TypeScript
123 lines
4.7 KiB
TypeScript
// Canvas tests cover copy a2ui plugin behavior.
|
|
import fs from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { resolvePreferredOpenClawTmpDir, withTempWorkspace } from "openclaw/plugin-sdk/temp-path";
|
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
import { copyA2uiAssets } from "./copy-a2ui.mjs";
|
|
|
|
const ORIGINAL_SKIP_MISSING = process.env.OPENCLAW_A2UI_SKIP_MISSING;
|
|
const ORIGINAL_SPARSE_PROFILE = process.env.OPENCLAW_SPARSE_PROFILE;
|
|
|
|
describe("canvas a2ui copy", () => {
|
|
beforeEach(() => {
|
|
delete process.env.OPENCLAW_A2UI_SKIP_MISSING;
|
|
delete process.env.OPENCLAW_SPARSE_PROFILE;
|
|
});
|
|
|
|
afterEach(() => {
|
|
if (ORIGINAL_SKIP_MISSING === undefined) {
|
|
delete process.env.OPENCLAW_A2UI_SKIP_MISSING;
|
|
} else {
|
|
process.env.OPENCLAW_A2UI_SKIP_MISSING = ORIGINAL_SKIP_MISSING;
|
|
}
|
|
|
|
if (ORIGINAL_SPARSE_PROFILE === undefined) {
|
|
delete process.env.OPENCLAW_SPARSE_PROFILE;
|
|
} else {
|
|
process.env.OPENCLAW_SPARSE_PROFILE = ORIGINAL_SPARSE_PROFILE;
|
|
}
|
|
});
|
|
|
|
async function withA2uiFixture(run: (dir: string) => Promise<void>) {
|
|
await withTempWorkspace(
|
|
{ rootDir: resolvePreferredOpenClawTmpDir(), prefix: "openclaw-a2ui-" },
|
|
async ({ dir }) => await run(dir),
|
|
);
|
|
}
|
|
|
|
it("throws a helpful error when assets are missing", async () => {
|
|
await withA2uiFixture(async (dir) => {
|
|
await expect(
|
|
copyA2uiAssets({ srcDir: path.join(dir, "src"), outDir: path.join(dir, "out") }),
|
|
).rejects.toThrow('Run "pnpm canvas:a2ui:bundle"');
|
|
});
|
|
});
|
|
|
|
it("skips missing assets when OPENCLAW_A2UI_SKIP_MISSING=1", async () => {
|
|
await withA2uiFixture(async (dir) => {
|
|
process.env.OPENCLAW_A2UI_SKIP_MISSING = "1";
|
|
await expect(
|
|
copyA2uiAssets({ srcDir: path.join(dir, "src"), outDir: path.join(dir, "out") }),
|
|
).resolves.toBeUndefined();
|
|
});
|
|
});
|
|
|
|
it("skips missing assets when OPENCLAW_SPARSE_PROFILE is set", async () => {
|
|
await withA2uiFixture(async (dir) => {
|
|
process.env.OPENCLAW_SPARSE_PROFILE = "core";
|
|
await expect(
|
|
copyA2uiAssets({ srcDir: path.join(dir, "src"), outDir: path.join(dir, "out") }),
|
|
).resolves.toBeUndefined();
|
|
});
|
|
});
|
|
|
|
it("copies bundled assets to dist", async () => {
|
|
await withA2uiFixture(async (dir) => {
|
|
const srcDir = path.join(dir, "src");
|
|
const outDir = path.join(dir, "dist");
|
|
await fs.mkdir(srcDir, { recursive: true });
|
|
await fs.writeFile(path.join(srcDir, "index.html"), "<html></html>", "utf8");
|
|
await fs.writeFile(path.join(srcDir, "a2ui.bundle.js"), "console.log(1);", "utf8");
|
|
|
|
await copyA2uiAssets({ srcDir, outDir });
|
|
|
|
await expect(fs.readFile(path.join(outDir, "index.html"), "utf8")).resolves.toBe(
|
|
"<html></html>",
|
|
);
|
|
await expect(fs.readFile(path.join(outDir, "a2ui.bundle.js"), "utf8")).resolves.toBe(
|
|
"console.log(1);",
|
|
);
|
|
});
|
|
});
|
|
|
|
it("copies nested bundled assets and removes stale output", async () => {
|
|
await withA2uiFixture(async (dir) => {
|
|
const srcDir = path.join(dir, "src");
|
|
const outDir = path.join(dir, "dist");
|
|
const nestedAssetDir = path.join(srcDir, "assets", "demo");
|
|
await fs.mkdir(nestedAssetDir, { recursive: true });
|
|
await fs.mkdir(outDir, { recursive: true });
|
|
await fs.writeFile(path.join(srcDir, "index.html"), "<html></html>", "utf8");
|
|
await fs.writeFile(path.join(srcDir, "a2ui.bundle.js"), "console.log(1);", "utf8");
|
|
await fs.writeFile(path.join(nestedAssetDir, "sample.txt"), "nested-asset", "utf8");
|
|
await fs.writeFile(path.join(outDir, "stale.txt"), "stale-output", "utf8");
|
|
|
|
await copyA2uiAssets({ srcDir, outDir });
|
|
|
|
await expect(
|
|
fs.readFile(path.join(outDir, "assets", "demo", "sample.txt"), "utf8"),
|
|
).resolves.toBe("nested-asset");
|
|
await expect(fs.stat(path.join(outDir, "stale.txt"))).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
});
|
|
});
|
|
|
|
it("rejects overlapping source and output directories before cleaning output", async () => {
|
|
await withA2uiFixture(async (dir) => {
|
|
const srcDir = path.join(dir, "src");
|
|
await fs.mkdir(srcDir, { recursive: true });
|
|
await fs.writeFile(path.join(srcDir, "index.html"), "<html></html>", "utf8");
|
|
await fs.writeFile(path.join(srcDir, "a2ui.bundle.js"), "console.log(1);", "utf8");
|
|
|
|
await expect(copyA2uiAssets({ srcDir, outDir: srcDir })).rejects.toThrow("must not overlap");
|
|
await expect(fs.readFile(path.join(srcDir, "index.html"), "utf8")).resolves.toBe(
|
|
"<html></html>",
|
|
);
|
|
await expect(copyA2uiAssets({ srcDir, outDir: path.join(srcDir, "dist") })).rejects.toThrow(
|
|
"must not overlap",
|
|
);
|
|
});
|
|
});
|
|
});
|