mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-10-25 17:22:27 +08:00
Kimi Code saves every /model pick as default_model, so the default shown in CC Switch can go stale while the page stays open. The backend rereads config.toml and refuses to remove the provider Kimi Code is using, but the page kept showing the old default and an untranslated English reason. Reread the additive app's live state after a failed removal as well as a successful one (now including the OpenCode, OpenClaw and Hermes default model queries), reread Kimi providers after failed edits and deletions, and explain the two Kimi "model in use" refusals in all four locales.
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import {
|
|
extractErrorMessage,
|
|
translateKimiProviderMutationError,
|
|
translatePiProviderMutationError,
|
|
} from "@/utils/errorUtils";
|
|
|
|
describe("error utilities", () => {
|
|
it("extracts Tauri string errors", () => {
|
|
expect(extractErrorMessage("backend failed")).toBe("backend failed");
|
|
});
|
|
|
|
it("maps a simultaneous models.json write to a concise error", () => {
|
|
const t = vi.fn((key: string) => key);
|
|
|
|
expect(
|
|
translatePiProviderMutationError(
|
|
"Pi models.json changed outside CC Switch",
|
|
t,
|
|
),
|
|
).toBe("pi.provider.writeConflict");
|
|
});
|
|
|
|
it("maps a duplicate Pi provider key to validation feedback", () => {
|
|
const t = vi.fn((key: string) => key);
|
|
|
|
expect(
|
|
translatePiProviderMutationError(
|
|
"无效输入: Pi provider key 'duplicate' already exists in models.json",
|
|
t,
|
|
),
|
|
).toBe("pi.form.providerKeyDuplicate");
|
|
});
|
|
|
|
it("explains Kimi removals refused because Kimi Code still uses the model", () => {
|
|
const t = vi.fn((key: string) => key);
|
|
|
|
expect(
|
|
translateKimiProviderMutationError(
|
|
"无效输入: Select another default model in Kimi Code before removing this model or provider",
|
|
t,
|
|
),
|
|
).toBe("kimi.error.defaultModelInUse");
|
|
expect(
|
|
translateKimiProviderMutationError(
|
|
"无效输入: Update the secondary model selection in Kimi Code before removing this model or provider",
|
|
t,
|
|
),
|
|
).toBe("kimi.error.secondaryModelInUse");
|
|
expect(translateKimiProviderMutationError("other failure", t)).toBe("");
|
|
});
|
|
});
|