


























@@ -37,17 +37,17 @@ describe("canvas a2ui copy", () => {
37373838it("throws a helpful error when assets are missing", async () => {
3939await withA2uiFixture(async (dir) => {
40-await expect(copyA2uiAssets({ srcDir: dir, outDir: path.join(dir, "out") })).rejects.toThrow(
41-'Run "pnpm canvas:a2ui:bundle"',
42-);
40+await expect(
41+copyA2uiAssets({ srcDir: path.join(dir, "src"), outDir: path.join(dir, "out") }),
42+).rejects.toThrow('Run "pnpm canvas:a2ui:bundle"');
4343});
4444});
45454646it("skips missing assets when OPENCLAW_A2UI_SKIP_MISSING=1", async () => {
4747await withA2uiFixture(async (dir) => {
4848process.env.OPENCLAW_A2UI_SKIP_MISSING = "1";
4949await expect(
50-copyA2uiAssets({ srcDir: dir, outDir: path.join(dir, "out") }),
50+copyA2uiAssets({ srcDir: path.join(dir, "src"), outDir: path.join(dir, "out") }),
5151).resolves.toBeUndefined();
5252});
5353});
@@ -56,7 +56,7 @@ describe("canvas a2ui copy", () => {
5656await withA2uiFixture(async (dir) => {
5757process.env.OPENCLAW_SPARSE_PROFILE = "core";
5858await expect(
59-copyA2uiAssets({ srcDir: dir, outDir: path.join(dir, "out") }),
59+copyA2uiAssets({ srcDir: path.join(dir, "src"), outDir: path.join(dir, "out") }),
6060).resolves.toBeUndefined();
6161});
6262});
@@ -102,4 +102,21 @@ describe("canvas a2ui copy", () => {
102102});
103103});
104104});
105+106+it("rejects overlapping source and output directories before cleaning output", async () => {
107+await withA2uiFixture(async (dir) => {
108+const srcDir = path.join(dir, "src");
109+await fs.mkdir(srcDir, { recursive: true });
110+await fs.writeFile(path.join(srcDir, "index.html"), "<html></html>", "utf8");
111+await fs.writeFile(path.join(srcDir, "a2ui.bundle.js"), "console.log(1);", "utf8");
112+113+await expect(copyA2uiAssets({ srcDir, outDir: srcDir })).rejects.toThrow("must not overlap");
114+await expect(fs.readFile(path.join(srcDir, "index.html"), "utf8")).resolves.toBe(
115+"<html></html>",
116+);
117+await expect(copyA2uiAssets({ srcDir, outDir: path.join(srcDir, "dist") })).rejects.toThrow(
118+"must not overlap",
119+);
120+});
121+});
105122});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。