mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-10-20 15:03:10 +08:00
* feat(pi): add native coding agent support * refactor(pi): align native provider management * fix(pi): allow removing global default provider * feat(pi): refine provider creation experience * refactor(pi): align prompt management UI * feat(pi): refine native prompt and provider UX * fix(pi): size config preview to content * feat(pi): refine native provider management * refactor(pi): remove unused integration paths * fix(pi): address review feedback * test(pi): align model picker assertions * fix(pi): preserve AGENTS.md during restore sync --------- Co-authored-by: Jason <farion1231@gmail.com>
34 lines
925 B
TypeScript
34 lines
925 B
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import {
|
|
extractErrorMessage,
|
|
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");
|
|
});
|
|
});
|