test: tighten command assertions

This commit is contained in:
Peter Steinberger
2026-05-11 15:58:39 +01:00
parent 3e332426fc
commit 8aa286476d
6 changed files with 31 additions and 35 deletions

View File

@@ -336,10 +336,15 @@ describe("acp translator stable lifecycle handlers", () => {
const result = await agent.resumeSession(createResumeSessionRequest("agent:main:work"));
expect(result.modes?.currentModeId).toBe("adaptive");
expect(result.configOptions).toBeDefined();
if (!result.configOptions) {
throw new Error("expected resume session config options");
}
const thoughtLevelOption = result.configOptions.find((option) => option.id === "thought_level");
expect(thoughtLevelOption?.currentValue).toBe("adaptive");
expect(sessionStore.getSession("agent:main:work")?.sessionKey).toBe("agent:main:work");
expect(request.mock.calls.map((call) => call[0])).not.toContain("sessions.get");
const requestCalls = (request as unknown as { mock: { calls: Array<[string]> } }).mock.calls;
expect(requestCalls.map((call) => call[0])).not.toContain("sessions.get");
expect(sessionUpdate).toHaveBeenCalledWith({
sessionId: "agent:main:work",
update: {

View File

@@ -207,11 +207,7 @@ function expectSetupSnapshotDoesNotScopeToPlugin(params: {
workspaceDir: "/tmp/openclaw-workspace",
});
expect(loadOpenClawPlugins).toHaveBeenCalledWith(
expect.not.objectContaining({
onlyPluginIds: [params.pluginId],
}),
);
expect(loadOpenClawPlugins).toHaveBeenCalledTimes(1);
const firstLoadCall = vi.mocked(loadOpenClawPlugins).mock.calls[0]?.[0] as
| { onlyPluginIds?: string[] }
| undefined;

View File

@@ -1455,11 +1455,9 @@ describe("doctor config flow", () => {
});
expect(noteImplicitFallbackClobberWarningsMock).toHaveBeenCalledTimes(1);
expect(noteImplicitFallbackClobberWarningsMock).toHaveBeenCalledWith(
expect.objectContaining({
agents: config.agents,
}),
);
const [[warningParams]] = noteImplicitFallbackClobberWarningsMock.mock
.calls as unknown as Array<[{ agents?: unknown }]>;
expect(warningParams.agents).toStrictEqual(config.agents);
const doctorWarnings = terminalNoteMock.mock.calls
.filter(([, title]) => title === "Doctor warnings")
.map(([message]) => message);

View File

@@ -398,18 +398,20 @@ describe("gateway-status command", () => {
expect(runtimeErrors).toHaveLength(0);
const parsed = JSON.parse(runtimeLogs.join("\n")) as {
degraded?: boolean;
warnings?: Array<{ code?: string; message?: string }>;
warnings?: Array<{ code?: string; message?: string; targetIds?: string[] }>;
};
expect(parsed.degraded).toBe(true);
expect(parsed.warnings).toEqual(
expect.arrayContaining([
expect.objectContaining({
code: "model_pricing_degraded",
message:
"Model pricing degraded: OpenRouter pricing fetch failed: TypeError: fetch failed",
}),
]),
);
const pricingWarnings =
parsed.warnings?.filter((warning) => warning.code === "model_pricing_degraded") ?? [];
expect(pricingWarnings).toHaveLength(2);
expect(pricingWarnings.map((warning) => warning.message)).toEqual([
"Model pricing degraded: OpenRouter pricing fetch failed: TypeError: fetch failed",
"Model pricing degraded: OpenRouter pricing fetch failed: TypeError: fetch failed",
]);
expect(pricingWarnings.map((warning) => warning.targetIds)).toEqual([
["sshTunnel"],
["configRemote"],
]);
});
it("includes diagnostic next steps when no gateway is reachable or discoverable", async () => {

View File

@@ -209,11 +209,10 @@ describe("status-json-payload", () => {
secretDiagnostics: [],
});
expect(payload.gateway).toMatchObject({
modelPricing: {
state: "degraded",
detail: "OpenRouter pricing fetch failed: TypeError: fetch failed",
},
});
const modelPricing = payload.gateway.modelPricing as
| { state?: string; detail?: string }
| undefined;
expect(modelPricing?.state).toBe("degraded");
expect(modelPricing?.detail).toBe("OpenRouter pricing fetch failed: TypeError: fetch failed");
});
});

View File

@@ -85,13 +85,9 @@ describe("buildStatusCommandReportData", () => {
}),
);
expect(result.overviewRows).toEqual(
expect.arrayContaining([
{
Item: "Model pricing",
Value: "warn(degraded · OpenRouter pricing fetch failed: TypeError: fetch failed)",
},
]),
);
expect(result.overviewRows).toContainEqual({
Item: "Model pricing",
Value: "warn(degraded · OpenRouter pricing fetch failed: TypeError: fetch failed)",
});
});
});