mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 03:40:22 +00:00
test(integration): dedupe messaging, secrets, and plugin test suites
This commit is contained in:
@@ -158,6 +158,19 @@ function expectPluginFiles(result: { targetDir: string }, stateDir: string, plug
|
||||
expect(fs.existsSync(path.join(result.targetDir, "dist", "index.js"))).toBe(true);
|
||||
}
|
||||
|
||||
function expectSuccessfulArchiveInstall(params: {
|
||||
result: Awaited<ReturnType<typeof installPluginFromArchive>>;
|
||||
stateDir: string;
|
||||
pluginId: string;
|
||||
}) {
|
||||
expect(params.result.ok).toBe(true);
|
||||
if (!params.result.ok) {
|
||||
return;
|
||||
}
|
||||
expect(params.result.pluginId).toBe(params.pluginId);
|
||||
expectPluginFiles(params.result, params.stateDir, params.pluginId);
|
||||
}
|
||||
|
||||
function setupPluginInstallDirs() {
|
||||
const tmpDir = makeTempDir();
|
||||
const pluginDir = path.join(tmpDir, "plugin-src");
|
||||
@@ -200,6 +213,30 @@ async function installFromDirWithWarnings(params: { pluginDir: string; extension
|
||||
return { result, warnings };
|
||||
}
|
||||
|
||||
function setupManifestInstallFixture(params: { manifestId: string }) {
|
||||
const { pluginDir, extensionsDir } = setupPluginInstallDirs();
|
||||
fs.mkdirSync(path.join(pluginDir, "dist"), { recursive: true });
|
||||
fs.writeFileSync(
|
||||
path.join(pluginDir, "package.json"),
|
||||
JSON.stringify({
|
||||
name: "@openclaw/cognee-openclaw",
|
||||
version: "0.0.1",
|
||||
openclaw: { extensions: ["./dist/index.js"] },
|
||||
}),
|
||||
"utf-8",
|
||||
);
|
||||
fs.writeFileSync(path.join(pluginDir, "dist", "index.js"), "export {};", "utf-8");
|
||||
fs.writeFileSync(
|
||||
path.join(pluginDir, "openclaw.plugin.json"),
|
||||
JSON.stringify({
|
||||
id: params.manifestId,
|
||||
configSchema: { type: "object", properties: {} },
|
||||
}),
|
||||
"utf-8",
|
||||
);
|
||||
return { pluginDir, extensionsDir };
|
||||
}
|
||||
|
||||
async function expectArchiveInstallReservedSegmentRejection(params: {
|
||||
packageName: string;
|
||||
outName: string;
|
||||
@@ -281,12 +318,7 @@ describe("installPluginFromArchive", () => {
|
||||
archivePath,
|
||||
extensionsDir,
|
||||
});
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) {
|
||||
return;
|
||||
}
|
||||
expect(result.pluginId).toBe("voice-call");
|
||||
expectPluginFiles(result, stateDir, "voice-call");
|
||||
expectSuccessfulArchiveInstall({ result, stateDir, pluginId: "voice-call" });
|
||||
});
|
||||
|
||||
it("rejects installing when plugin already exists", async () => {
|
||||
@@ -324,13 +356,7 @@ describe("installPluginFromArchive", () => {
|
||||
archivePath,
|
||||
extensionsDir,
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) {
|
||||
return;
|
||||
}
|
||||
expect(result.pluginId).toBe("zipper");
|
||||
expectPluginFiles(result, stateDir, "zipper");
|
||||
expectSuccessfulArchiveInstall({ result, stateDir, pluginId: "zipper" });
|
||||
});
|
||||
|
||||
it("allows updates when mode is update", async () => {
|
||||
@@ -515,26 +541,9 @@ describe("installPluginFromDir", () => {
|
||||
});
|
||||
|
||||
it("uses openclaw.plugin.json id as install key when it differs from package name", async () => {
|
||||
const { pluginDir, extensionsDir } = setupPluginInstallDirs();
|
||||
fs.mkdirSync(path.join(pluginDir, "dist"), { recursive: true });
|
||||
fs.writeFileSync(
|
||||
path.join(pluginDir, "package.json"),
|
||||
JSON.stringify({
|
||||
name: "@openclaw/cognee-openclaw",
|
||||
version: "0.0.1",
|
||||
openclaw: { extensions: ["./dist/index.js"] },
|
||||
}),
|
||||
"utf-8",
|
||||
);
|
||||
fs.writeFileSync(path.join(pluginDir, "dist", "index.js"), "export {};", "utf-8");
|
||||
fs.writeFileSync(
|
||||
path.join(pluginDir, "openclaw.plugin.json"),
|
||||
JSON.stringify({
|
||||
id: "memory-cognee",
|
||||
configSchema: { type: "object", properties: {} },
|
||||
}),
|
||||
"utf-8",
|
||||
);
|
||||
const { pluginDir, extensionsDir } = setupManifestInstallFixture({
|
||||
manifestId: "memory-cognee",
|
||||
});
|
||||
|
||||
const infoMessages: string[] = [];
|
||||
const res = await installPluginFromDir({
|
||||
@@ -559,26 +568,9 @@ describe("installPluginFromDir", () => {
|
||||
});
|
||||
|
||||
it("normalizes scoped manifest ids to unscoped install keys", async () => {
|
||||
const { pluginDir, extensionsDir } = setupPluginInstallDirs();
|
||||
fs.mkdirSync(path.join(pluginDir, "dist"), { recursive: true });
|
||||
fs.writeFileSync(
|
||||
path.join(pluginDir, "package.json"),
|
||||
JSON.stringify({
|
||||
name: "@openclaw/cognee-openclaw",
|
||||
version: "0.0.1",
|
||||
openclaw: { extensions: ["./dist/index.js"] },
|
||||
}),
|
||||
"utf-8",
|
||||
);
|
||||
fs.writeFileSync(path.join(pluginDir, "dist", "index.js"), "export {};", "utf-8");
|
||||
fs.writeFileSync(
|
||||
path.join(pluginDir, "openclaw.plugin.json"),
|
||||
JSON.stringify({
|
||||
id: "@team/memory-cognee",
|
||||
configSchema: { type: "object", properties: {} },
|
||||
}),
|
||||
"utf-8",
|
||||
);
|
||||
const { pluginDir, extensionsDir } = setupManifestInstallFixture({
|
||||
manifestId: "@team/memory-cognee",
|
||||
});
|
||||
|
||||
const res = await installPluginFromDir({
|
||||
dirPath: pluginDir,
|
||||
|
||||
Reference in New Issue
Block a user