From 64abf9a92575ab361c5a5801479785a5f3313098 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 2 Mar 2026 19:33:45 +0000 Subject: [PATCH] test(perf): use prebuilt plugin install archive fixtures --- src/plugins/install.test.ts | 65 +----------------- .../plugins-install/voice-call-0.0.1.tgz | Bin 0 -> 299 bytes .../plugins-install/voice-call-0.0.2.tgz | Bin 0 -> 300 bytes .../fixtures/plugins-install/zipper-0.0.1.zip | Bin 0 -> 560 bytes 4 files changed, 3 insertions(+), 62 deletions(-) create mode 100644 test/fixtures/plugins-install/voice-call-0.0.1.tgz create mode 100644 test/fixtures/plugins-install/voice-call-0.0.2.tgz create mode 100644 test/fixtures/plugins-install/zipper-0.0.1.zip diff --git a/src/plugins/install.test.ts b/src/plugins/install.test.ts index 248294da7..de1041a26 100644 --- a/src/plugins/install.test.ts +++ b/src/plugins/install.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; -import JSZip from "jszip"; import * as tar from "tar"; import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import * as skillScanner from "../security/skill-scanner.js"; @@ -24,6 +23,7 @@ let installPluginFromPath: typeof import("./install.js").installPluginFromPath; let runCommandWithTimeout: typeof import("../process/exec.js").runCommandWithTimeout; let suiteTempRoot = ""; let tempDirCounter = 0; +const pluginFixturesDir = path.resolve(process.cwd(), "test", "fixtures", "plugins-install"); function ensureSuiteTempRoot() { if (suiteTempRoot) { @@ -62,57 +62,8 @@ async function packToArchive({ return dest; } -function writePluginPackage(params: { - pkgDir: string; - name: string; - version: string; - extensions: string[]; -}) { - fs.mkdirSync(path.join(params.pkgDir, "dist"), { recursive: true }); - fs.writeFileSync( - path.join(params.pkgDir, "package.json"), - JSON.stringify( - { - name: params.name, - version: params.version, - openclaw: { extensions: params.extensions }, - }, - null, - 2, - ), - "utf-8", - ); - fs.writeFileSync(path.join(params.pkgDir, "dist", "index.js"), "export {};", "utf-8"); -} - -async function createVoiceCallArchive(params: { - workDir: string; - outName: string; - version: string; -}) { - const pkgDir = path.join(params.workDir, "package"); - writePluginPackage({ - pkgDir, - name: "@openclaw/voice-call", - version: params.version, - extensions: ["./dist/index.js"], - }); - const archivePath = await packToArchive({ - pkgDir, - outDir: params.workDir, - outName: params.outName, - }); - return { pkgDir, archivePath }; -} - async function createVoiceCallArchiveBuffer(version: string): Promise { - const workDir = makeTempDir(); - const { archivePath } = await createVoiceCallArchive({ - workDir, - outName: `plugin-${version}.tgz`, - version, - }); - return fs.readFileSync(archivePath); + return fs.readFileSync(path.join(pluginFixturesDir, `voice-call-${version}.tgz`)); } function writeArchiveBuffer(params: { outName: string; buffer: Buffer }): string { @@ -123,17 +74,7 @@ function writeArchiveBuffer(params: { outName: string; buffer: Buffer }): string } async function createZipperArchiveBuffer(): Promise { - const zip = new JSZip(); - zip.file( - "package/package.json", - JSON.stringify({ - name: "@openclaw/zipper", - version: "0.0.1", - openclaw: { extensions: ["./dist/index.js"] }, - }), - ); - zip.file("package/dist/index.js", "export {};"); - return zip.generateAsync({ type: "nodebuffer" }); + return fs.readFileSync(path.join(pluginFixturesDir, "zipper-0.0.1.zip")); } const VOICE_CALL_ARCHIVE_V1_BUFFER_PROMISE = createVoiceCallArchiveBuffer("0.0.1"); diff --git a/test/fixtures/plugins-install/voice-call-0.0.1.tgz b/test/fixtures/plugins-install/voice-call-0.0.1.tgz new file mode 100644 index 0000000000000000000000000000000000000000..eb34dbd3ebfcf9c6c11ae7501870e01c393de698 GIT binary patch literal 299 zcmV+`0o48GPEOli%jl-h zIAEiTO7%$)Lrk4IrdzpR$12zwRDGtl+QXn(HFn2Kp?28X9TpAxqrG=ww^DCBjt}Sm xXwb~x_-6irvh(@RfN?+n*YcD3$F{B-Lyp~jxKfoKkH_O#gLjFYag+cM005K+nbKm?F*&KL>A zl0}W|wULc2MH?(?H2B+f#vd8uA7I+k>GPEO&OU{yAD&TkWevb8`gf}{$nS}&_O zKX3K3pn!l=-e-J6Hw6V0ozV9<>wV5s=lc3nIvO6jL6;a$PFpG_n*Qv0qlm-{$rqAN zE{R@^hpsx<1*mLYq+-gyWRrx37_S&}*Q=MyQ^cmfNPo6;N!W{2QSHW~$&D$x;kpbk zCt*6A7s*K}nZ+e&t`Br!cK|8j24YckrI~ptsTDvEc(2tsp|2IVV%^qfOhBs`nM4?H zhZ4{bAP|61NMQ!kg+0`u%7K&`5W_+mISldH3-SR3fb87~#4r<}UPiSX-P2ILK