mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-25 01:13:03 +00:00
test: tighten model catalog assertions
This commit is contained in:
@@ -174,13 +174,10 @@ describe("channelsRemoveCommand", () => {
|
||||
|
||||
expect(ensureChannelSetupPluginInstalled).not.toHaveBeenCalled();
|
||||
expect(registryRefreshMocks.refreshPluginRegistryAfterConfigMutation).not.toHaveBeenCalled();
|
||||
expect(configMocks.writeConfigFile).toHaveBeenCalledWith(
|
||||
expect.not.objectContaining({
|
||||
channels: expect.objectContaining({
|
||||
"external-chat": expect.anything(),
|
||||
}),
|
||||
}),
|
||||
);
|
||||
const writtenConfig = configMocks.writeConfigFile.mock.calls[0]?.[0] as
|
||||
| { channels?: Record<string, unknown> }
|
||||
| undefined;
|
||||
expect(writtenConfig?.channels?.["external-chat"]).toBeUndefined();
|
||||
expect(runtime.error).not.toHaveBeenCalled();
|
||||
expect(runtime.exit).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -243,12 +240,9 @@ describe("channelsRemoveCommand", () => {
|
||||
clientName: "gateway-client",
|
||||
deviceIdentity: null,
|
||||
});
|
||||
expect(configMocks.writeConfigFile).toHaveBeenCalledWith(
|
||||
expect.not.objectContaining({
|
||||
channels: expect.objectContaining({
|
||||
"external-chat": expect.anything(),
|
||||
}),
|
||||
}),
|
||||
);
|
||||
const writtenConfig = configMocks.writeConfigFile.mock.calls[0]?.[0] as
|
||||
| { channels?: Record<string, unknown> }
|
||||
| undefined;
|
||||
expect(writtenConfig?.channels?.["external-chat"]).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -118,9 +118,7 @@ describe("resolveGatewayInstallToken", () => {
|
||||
expect(result.token).toBeUndefined();
|
||||
expect(result.tokenRefConfigured).toBe(true);
|
||||
expect(result.unavailableReason).toBeUndefined();
|
||||
expect(result.warnings).toEqual(
|
||||
expect.arrayContaining([expect.stringContaining("SecretRef-managed")]),
|
||||
);
|
||||
expect(result.warnings.join("\n")).toContain("SecretRef-managed");
|
||||
});
|
||||
|
||||
it("returns unavailable reason when token SecretRef is unresolved in token mode", async () => {
|
||||
@@ -174,9 +172,7 @@ describe("resolveGatewayInstallToken", () => {
|
||||
|
||||
expect(result.token).toBe("generated-token");
|
||||
expect(result.unavailableReason).toBeUndefined();
|
||||
expect(result.warnings).toEqual(
|
||||
expect.arrayContaining([expect.stringContaining("without saving to config")]),
|
||||
);
|
||||
expect(result.warnings.join("\n")).toContain("without saving to config");
|
||||
expect(replaceConfigFileMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -193,9 +189,7 @@ describe("resolveGatewayInstallToken", () => {
|
||||
persistGeneratedToken: true,
|
||||
});
|
||||
|
||||
expect(result.warnings).toEqual(
|
||||
expect.arrayContaining([expect.stringContaining("saving to config")]),
|
||||
);
|
||||
expect(result.warnings.join("\n")).toContain("saving to config");
|
||||
expect(replaceConfigFileMock).toHaveBeenCalledOnce();
|
||||
expect(replaceConfigFileMock.mock.calls[0]?.[0]).toStrictEqual({
|
||||
nextConfig: {
|
||||
@@ -241,9 +235,7 @@ describe("resolveGatewayInstallToken", () => {
|
||||
});
|
||||
|
||||
expect(result.token).toBeUndefined();
|
||||
expect(result.warnings).toEqual(
|
||||
expect.arrayContaining([expect.stringContaining("skipping plaintext token persistence")]),
|
||||
);
|
||||
expect(result.warnings.join("\n")).toContain("skipping plaintext token persistence");
|
||||
expect(replaceConfigFileMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
@@ -286,13 +286,9 @@ describe("buildProbeTargets reason codes", () => {
|
||||
const plan = await buildAnthropicPlanFromModelsJsonApiKey("ALLCAPS_SAMPLE");
|
||||
expect(plan.results).toStrictEqual([]);
|
||||
expect(plan.targets).toHaveLength(1);
|
||||
expect(plan.targets[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
provider: "anthropic",
|
||||
source: "models.json",
|
||||
label: "models.json",
|
||||
}),
|
||||
);
|
||||
expect(plan.targets[0]?.provider).toBe("anthropic");
|
||||
expect(plan.targets[0]?.source).toBe("models.json");
|
||||
expect(plan.targets[0]?.label).toBe("models.json");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -331,14 +327,10 @@ describe("buildProbeTargets reason codes", () => {
|
||||
|
||||
expect(plan.results).toStrictEqual([]);
|
||||
expect(plan.targets).toHaveLength(1);
|
||||
expect(plan.targets[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
provider: "zai",
|
||||
model: { provider: "zai", model: "glm-4.7" },
|
||||
source: "models.json",
|
||||
label: "models.json",
|
||||
}),
|
||||
);
|
||||
expect(plan.targets[0]?.provider).toBe("zai");
|
||||
expect(plan.targets[0]?.model).toStrictEqual({ provider: "zai", model: "glm-4.7" });
|
||||
expect(plan.targets[0]?.source).toBe("models.json");
|
||||
expect(plan.targets[0]?.label).toBe("models.json");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -376,14 +368,13 @@ describe("buildProbeTargets reason codes", () => {
|
||||
|
||||
expect(withoutWorkspace.targets).toStrictEqual([]);
|
||||
expect(withWorkspace.targets).toHaveLength(1);
|
||||
expect(withWorkspace.targets[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
provider: "workspace-cloud",
|
||||
source: "env",
|
||||
label: "env",
|
||||
model: { provider: "workspace-cloud", model: "workspace-model" },
|
||||
}),
|
||||
);
|
||||
expect(withWorkspace.targets[0]?.provider).toBe("workspace-cloud");
|
||||
expect(withWorkspace.targets[0]?.source).toBe("env");
|
||||
expect(withWorkspace.targets[0]?.label).toBe("env");
|
||||
expect(withWorkspace.targets[0]?.model).toStrictEqual({
|
||||
provider: "workspace-cloud",
|
||||
model: "workspace-model",
|
||||
});
|
||||
});
|
||||
|
||||
it("uses the requested agent auth store when building profile probe targets", async () => {
|
||||
@@ -431,12 +422,8 @@ describe("buildProbeTargets reason codes", () => {
|
||||
expect(defaultPlan.targets).toStrictEqual([]);
|
||||
expect(agentPlan.results).toStrictEqual([]);
|
||||
expect(agentPlan.targets).toHaveLength(1);
|
||||
expect(agentPlan.targets[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
provider: "anthropic",
|
||||
profileId: "anthropic:coder",
|
||||
source: "profile",
|
||||
}),
|
||||
);
|
||||
expect(agentPlan.targets[0]?.provider).toBe("anthropic");
|
||||
expect(agentPlan.targets[0]?.profileId).toBe("anthropic:coder");
|
||||
expect(agentPlan.targets[0]?.source).toBe("profile");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -172,9 +172,7 @@ describe("loadProviderCatalogModelsForList", () => {
|
||||
});
|
||||
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
expect(rows.map((row) => `${row.provider}/${row.id}`)).toEqual(
|
||||
expect.arrayContaining(["moonshot/kimi-k2.6"]),
|
||||
);
|
||||
expect(rows.map((row) => `${row.provider}/${row.id}`)).toContain("moonshot/kimi-k2.6");
|
||||
});
|
||||
|
||||
it("requires complete discovery-entry coverage for static-only loads", async () => {
|
||||
@@ -184,13 +182,11 @@ describe("loadProviderCatalogModelsForList", () => {
|
||||
staticOnly: true,
|
||||
});
|
||||
|
||||
expect(providerDiscoveryMocks.resolveRuntimePluginDiscoveryProviders).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
onlyPluginIds: ["moonshot"],
|
||||
requireCompleteDiscoveryEntryCoverage: true,
|
||||
discoveryEntriesOnly: true,
|
||||
}),
|
||||
);
|
||||
const discoveryRequest =
|
||||
providerDiscoveryMocks.resolveRuntimePluginDiscoveryProviders.mock.calls[0]?.[0];
|
||||
expect(discoveryRequest?.onlyPluginIds).toStrictEqual(["moonshot"]);
|
||||
expect(discoveryRequest?.requireCompleteDiscoveryEntryCoverage).toBe(true);
|
||||
expect(discoveryRequest?.discoveryEntriesOnly).toBe(true);
|
||||
});
|
||||
|
||||
it("resolves provider owners from the installed plugin index before manifest fallback", async () => {
|
||||
@@ -287,13 +283,11 @@ describe("loadProviderCatalogModelsForList", () => {
|
||||
}),
|
||||
).resolves.toBe(false);
|
||||
|
||||
expect(providerDiscoveryMocks.resolveRuntimePluginDiscoveryProviders).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
onlyPluginIds: ["ollama"],
|
||||
requireCompleteDiscoveryEntryCoverage: true,
|
||||
discoveryEntriesOnly: true,
|
||||
}),
|
||||
);
|
||||
const discoveryRequest =
|
||||
providerDiscoveryMocks.resolveRuntimePluginDiscoveryProviders.mock.calls[0]?.[0];
|
||||
expect(discoveryRequest?.onlyPluginIds).toStrictEqual(["ollama"]);
|
||||
expect(discoveryRequest?.requireCompleteDiscoveryEntryCoverage).toBe(true);
|
||||
expect(discoveryRequest?.discoveryEntriesOnly).toBe(true);
|
||||
});
|
||||
|
||||
it("does not skip registry when a bundled provider has no lightweight static entry", async () => {
|
||||
@@ -368,12 +362,10 @@ describe("loadProviderCatalogModelsForList", () => {
|
||||
...baseParams,
|
||||
});
|
||||
|
||||
expect(providerDiscoveryMocks.resolveRuntimePluginDiscoveryProviders).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
onlyPluginIds: ["bundled-demo"],
|
||||
includeUntrustedWorkspacePlugins: false,
|
||||
}),
|
||||
);
|
||||
const discoveryRequest =
|
||||
providerDiscoveryMocks.resolveRuntimePluginDiscoveryProviders.mock.calls[0]?.[0];
|
||||
expect(discoveryRequest?.onlyPluginIds).toStrictEqual(["bundled-demo"]);
|
||||
expect(discoveryRequest?.includeUntrustedWorkspacePlugins).toBe(false);
|
||||
expect(workspaceStaticCatalog).not.toHaveBeenCalled();
|
||||
expect(rows).toStrictEqual([]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user