





















@@ -30,6 +30,10 @@ async function expectPathExists(filePath: string) {
3030await expect(fs.access(filePath)).resolves.toBeUndefined();
3131}
323233+async function expectPathMissing(filePath: string) {
34+await expect(fs.access(filePath)).rejects.toHaveProperty("code", "ENOENT");
35+}
36+3337async function writePluginPackage(
3438extensionsDir: string,
3539pluginId: string,
@@ -242,9 +246,7 @@ describe("bundled plugin postinstall", () => {
242246log: { log: vi.fn(), warn: vi.fn() },
243247});
244248245-await expect(fs.stat(path.join(extensionsDir, "acpx", "node_modules"))).rejects.toMatchObject({
246-code: "ENOENT",
247-});
249+await expectPathMissing(path.join(extensionsDir, "acpx", "node_modules"));
248250});
249251250252it("keeps source-checkout prune non-fatal", async () => {
@@ -453,7 +455,7 @@ describe("bundled plugin postinstall", () => {
453455).toEqual(["dist/channel-CJUAgRQR.js"]);
454456455457await expectPathExists(currentFile);
456-await expect(fs.stat(staleFile)).rejects.toMatchObject({ code: "ENOENT" });
458+await expectPathMissing(staleFile);
457459});
458460459461it("prunes legacy plugin runtime deps state during packaged postinstall", async () => {
@@ -514,11 +516,11 @@ describe("bundled plugin postinstall", () => {
514516 log,
515517});
516518517-await expect(fs.stat(defaultLegacyRoot)).rejects.toMatchObject({ code: "ENOENT" });
518-await expect(fs.stat(oldBrandLegacyRoot)).rejects.toMatchObject({ code: "ENOENT" });
519-await expect(fs.stat(overrideLegacyRoot)).rejects.toMatchObject({ code: "ENOENT" });
520-await expect(fs.stat(systemLegacyRoot)).rejects.toMatchObject({ code: "ENOENT" });
521-await expect(fs.lstat(legacySymlink)).rejects.toMatchObject({ code: "ENOENT" });
519+await expectPathMissing(defaultLegacyRoot);
520+await expectPathMissing(oldBrandLegacyRoot);
521+await expectPathMissing(overrideLegacyRoot);
522+await expectPathMissing(systemLegacyRoot);
523+await expectPathMissing(legacySymlink);
522524await expectPathExists(thirdPartyNodeModules);
523525expect(log.warn).not.toHaveBeenCalled();
524526expect(log.log).toHaveBeenCalledWith(
@@ -555,8 +557,8 @@ describe("bundled plugin postinstall", () => {
555557 log,
556558});
557559558-await expect(fs.lstat(slackLink)).rejects.toMatchObject({ code: "ENOENT" });
559-await expect(fs.stat(legacyRuntimeRoot)).rejects.toMatchObject({ code: "ENOENT" });
560+await expectPathMissing(slackLink);
561+await expectPathMissing(legacyRuntimeRoot);
560562expect(log.warn).not.toHaveBeenCalled();
561563expect(log.log).toHaveBeenCalledWith(
562564expect.stringContaining("[postinstall] pruned legacy plugin runtime deps symlinks:"),
@@ -625,7 +627,7 @@ describe("bundled plugin postinstall", () => {
625627).toEqual(["dist/memory-state-old.js"]);
626628627629await expectPathExists(importedChunk);
628-await expect(fs.stat(staleFile)).rejects.toMatchObject({ code: "ENOENT" });
630+await expectPathMissing(staleFile);
629631});
630632631633it("does not abort dist pruning when a listed chunk disappears before import expansion", async () => {
@@ -653,7 +655,7 @@ describe("bundled plugin postinstall", () => {
653655}),
654656).toEqual(["dist/stale.js"]);
655657656-await expect(fs.stat(staleFile)).rejects.toMatchObject({ code: "ENOENT" });
658+await expectPathMissing(staleFile);
657659});
658660659661it("prunes stale private QA files without restoring compat sidecars", async () => {
@@ -678,20 +680,20 @@ describe("bundled plugin postinstall", () => {
678680log: { log: vi.fn(), warn: vi.fn() },
679681});
680682681-await expect(fs.stat(stalePackage)).rejects.toMatchObject({ code: "ENOENT" });
682-await expect(fs.stat(staleManifest)).rejects.toMatchObject({ code: "ENOENT" });
683-await expect(
684-fs.stat(path.join(packageRoot, "dist", "extensions", "qa-channel", "runtime-api.js")),
685-).rejects.toMatchObject({ code: "ENOENT" });
686-await expect(
687-fs.stat(path.join(packageRoot, "dist", "extensions", "qa-channel", "package.json")),
688-).rejects.toMatchObject({ code: "ENOENT" });
689-await expect(
690-fs.stat(path.join(packageRoot, "dist", "extensions", "qa-channel", "openclaw.plugin.json")),
691-).rejects.toMatchObject({ code: "ENOENT" });
692-await expect(
693-fs.stat(path.join(packageRoot, "dist", "extensions", "qa-lab", "runtime-api.js")),
694-).rejects.toMatchObject({ code: "ENOENT" });
683+await expectPathMissing(stalePackage);
684+await expectPathMissing(staleManifest);
685+await expectPathMissing(
686+path.join(packageRoot, "dist", "extensions", "qa-channel", "runtime-api.js"),
687+);
688+await expectPathMissing(
689+path.join(packageRoot, "dist", "extensions", "qa-channel", "package.json"),
690+);
691+await expectPathMissing(
692+path.join(packageRoot, "dist", "extensions", "qa-channel", "openclaw.plugin.json"),
693+);
694+await expectPathMissing(
695+path.join(packageRoot, "dist", "extensions", "qa-lab", "runtime-api.js"),
696+);
695697});
696698697699it("keeps packaged postinstall non-fatal when the dist inventory is missing", async () => {
@@ -842,15 +844,9 @@ describe("bundled plugin postinstall", () => {
842844log: { log: vi.fn(), warn: vi.fn() },
843845}),
844846).toEqual(["dist/stale-runtime.js"]);
845-await expect(
846-fs.stat(path.join(packageRoot, "dist", "extensions", "slack", "node_modules")),
847-).rejects.toMatchObject({ code: "ENOENT" });
848-await expect(fs.stat(path.dirname(installStageFile))).rejects.toMatchObject({
849-code: "ENOENT",
850-});
851-await expect(fs.stat(path.dirname(retryInstallStageFile))).rejects.toMatchObject({
852-code: "ENOENT",
853-});
847+await expectPathMissing(path.join(packageRoot, "dist", "extensions", "slack", "node_modules"));
848+await expectPathMissing(path.dirname(installStageFile));
849+await expectPathMissing(path.dirname(retryInstallStageFile));
854850});
855851856852it("unlinks stale files instead of recursive pruning them", () => {
@@ -899,9 +895,7 @@ describe("bundled plugin postinstall", () => {
899895900896pruneBundledPluginSourceNodeModules({ extensionsDir });
901897902-await expect(fs.stat(path.join(extensionsDir, "acpx", "node_modules"))).rejects.toMatchObject({
903-code: "ENOENT",
904-});
898+await expectPathMissing(path.join(extensionsDir, "acpx", "node_modules"));
905899await expectPathExists(path.join(extensionsDir, "fixtures", "node_modules"));
906900});
907901此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。