mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 15:20:23 +00:00
test: dedupe plugin utility install suites
This commit is contained in:
@@ -288,9 +288,9 @@ function expectFailedInstallResult<
|
||||
expect(params.result.code).toBe(params.code);
|
||||
}
|
||||
expect(params.result.error).toBeDefined();
|
||||
for (const fragment of params.messageIncludes) {
|
||||
params.messageIncludes.forEach((fragment) => {
|
||||
expect(params.result.error).toContain(fragment);
|
||||
}
|
||||
});
|
||||
return params.result;
|
||||
}
|
||||
|
||||
@@ -305,6 +305,12 @@ function mockSuccessfulCommandRun(run: ReturnType<typeof vi.mocked<typeof runCom
|
||||
});
|
||||
}
|
||||
|
||||
function expectInstalledFiles(targetDir: string, expectedFiles: readonly string[]) {
|
||||
expectedFiles.forEach((relativePath) => {
|
||||
expect(fs.existsSync(path.join(targetDir, relativePath))).toBe(true);
|
||||
});
|
||||
}
|
||||
|
||||
function setupBundleInstallFixture(params: {
|
||||
bundleFormat: "codex" | "claude" | "cursor";
|
||||
name: string;
|
||||
@@ -553,14 +559,16 @@ beforeAll(async () => {
|
||||
"utf-8",
|
||||
);
|
||||
|
||||
for (const preset of DYNAMIC_ARCHIVE_TEMPLATE_PRESETS) {
|
||||
await ensureDynamicArchiveTemplate({
|
||||
packageJson: preset.packageJson,
|
||||
outName: preset.outName,
|
||||
withDistIndex: preset.withDistIndex,
|
||||
flatRoot: false,
|
||||
});
|
||||
}
|
||||
await Promise.all(
|
||||
DYNAMIC_ARCHIVE_TEMPLATE_PRESETS.map((preset) =>
|
||||
ensureDynamicArchiveTemplate({
|
||||
packageJson: preset.packageJson,
|
||||
outName: preset.outName,
|
||||
withDistIndex: preset.withDistIndex,
|
||||
flatRoot: false,
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -1003,9 +1011,7 @@ describe("installPluginFromDir", () => {
|
||||
if (!res.ok) {
|
||||
return;
|
||||
}
|
||||
for (const relativePath of expectedFiles) {
|
||||
expect(fs.existsSync(path.join(res.targetDir, relativePath))).toBe(true);
|
||||
}
|
||||
expectInstalledFiles(res.targetDir, expectedFiles);
|
||||
});
|
||||
|
||||
it("prefers native package installs over bundle installs for dual-format directories", async () => {
|
||||
|
||||
Reference in New Issue
Block a user