mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 23:56:07 +00:00
test: tighten release plugin install assertions
This commit is contained in:
@@ -7,6 +7,47 @@ const mocks = vi.hoisted(() => ({
|
||||
resolveProviderInstallCatalogEntries: vi.fn(),
|
||||
}));
|
||||
|
||||
type AutoEnableDetectionCall = {
|
||||
config: {
|
||||
agents?: {
|
||||
defaults?: {
|
||||
model?: string;
|
||||
agentRuntime?: { id?: string };
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
type MissingPluginInstallRepairCall = {
|
||||
pluginIds: string[];
|
||||
channelIds?: string[];
|
||||
env?: NodeJS.ProcessEnv;
|
||||
};
|
||||
|
||||
function readOnlyAutoEnableDetectionCall(): AutoEnableDetectionCall {
|
||||
expect(mocks.detectPluginAutoEnableCandidates).toHaveBeenCalledOnce();
|
||||
const calls = mocks.detectPluginAutoEnableCandidates.mock.calls as unknown as Array<
|
||||
[AutoEnableDetectionCall]
|
||||
>;
|
||||
const call = calls[0]?.[0];
|
||||
if (!call) {
|
||||
throw new Error("Expected auto-enable detection call");
|
||||
}
|
||||
return call;
|
||||
}
|
||||
|
||||
function readOnlyMissingPluginInstallRepairCall(): MissingPluginInstallRepairCall {
|
||||
expect(mocks.repairMissingPluginInstallsForIds).toHaveBeenCalledOnce();
|
||||
const calls = mocks.repairMissingPluginInstallsForIds.mock.calls as unknown as Array<
|
||||
[MissingPluginInstallRepairCall]
|
||||
>;
|
||||
const call = calls[0]?.[0];
|
||||
if (!call) {
|
||||
throw new Error("Expected missing plugin install repair call");
|
||||
}
|
||||
return call;
|
||||
}
|
||||
|
||||
vi.mock("../../../config/plugin-auto-enable.js", () => ({
|
||||
detectPluginAutoEnableCandidates: mocks.detectPluginAutoEnableCandidates,
|
||||
}));
|
||||
@@ -154,18 +195,9 @@ describe("configured plugin install release step", () => {
|
||||
env: {},
|
||||
});
|
||||
|
||||
expect(mocks.detectPluginAutoEnableCandidates).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
config: expect.objectContaining({
|
||||
agents: expect.objectContaining({
|
||||
defaults: expect.objectContaining({
|
||||
model: "openai/gpt-5.4",
|
||||
agentRuntime: { id: "codex" },
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
);
|
||||
const detectionCall = readOnlyAutoEnableDetectionCall();
|
||||
expect(detectionCall.config.agents?.defaults?.model).toBe("openai/gpt-5.4");
|
||||
expect(detectionCall.config.agents?.defaults?.agentRuntime).toEqual({ id: "codex" });
|
||||
expect(result.pluginIds).toEqual(["codex"]);
|
||||
expect(result.channelIds).toStrictEqual([]);
|
||||
});
|
||||
@@ -270,13 +302,10 @@ describe("configured plugin install release step", () => {
|
||||
env: {},
|
||||
});
|
||||
|
||||
expect(mocks.repairMissingPluginInstallsForIds).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
pluginIds: ["codex"],
|
||||
channelIds: [],
|
||||
env: {},
|
||||
}),
|
||||
);
|
||||
const repairCall = readOnlyMissingPluginInstallRepairCall();
|
||||
expect(repairCall.pluginIds).toEqual(["codex"]);
|
||||
expect(repairCall.channelIds).toEqual([]);
|
||||
expect(repairCall.env).toEqual({});
|
||||
expect(result.touchedConfig).toBe(true);
|
||||
expect(result.completed).toBe(true);
|
||||
});
|
||||
@@ -305,12 +334,9 @@ describe("configured plugin install release step", () => {
|
||||
env: { OPENCLAW_UPDATE_IN_PROGRESS: "1" },
|
||||
});
|
||||
|
||||
expect(mocks.repairMissingPluginInstallsForIds).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
pluginIds: ["codex"],
|
||||
env: { OPENCLAW_UPDATE_IN_PROGRESS: "1" },
|
||||
}),
|
||||
);
|
||||
const repairCall = readOnlyMissingPluginInstallRepairCall();
|
||||
expect(repairCall.pluginIds).toEqual(["codex"]);
|
||||
expect(repairCall.env).toEqual({ OPENCLAW_UPDATE_IN_PROGRESS: "1" });
|
||||
expect(result).toEqual({
|
||||
changes: [
|
||||
'Skipped package-manager repair for configured plugin "codex" during package update; rerun "openclaw doctor --fix" after the update completes.',
|
||||
@@ -342,13 +368,10 @@ describe("configured plugin install release step", () => {
|
||||
env: {},
|
||||
});
|
||||
|
||||
expect(mocks.repairMissingPluginInstallsForIds).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
pluginIds: ["discord"],
|
||||
channelIds: [],
|
||||
env: {},
|
||||
}),
|
||||
);
|
||||
const repairCall = readOnlyMissingPluginInstallRepairCall();
|
||||
expect(repairCall.pluginIds).toEqual(["discord"]);
|
||||
expect(repairCall.channelIds).toEqual([]);
|
||||
expect(repairCall.env).toEqual({});
|
||||
expect(result).toEqual({
|
||||
changes: ['Installed missing configured plugin "discord".'],
|
||||
warnings: [],
|
||||
|
||||
Reference in New Issue
Block a user