Files
Jyotisha/frontend/tests/admin-model-id.test.ts
Jesse_Chen fc47939ba9
Staging Backend Quality Gate / validate (push) Successful in 14m16s
Staging Backend Quality Gate / publish (push) Successful in 1h2m51s
fix(admin): repair model discovery and simplify model setup
2026-08-08 17:29:17 +08:00

28 lines
1018 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import assert from "node:assert/strict";
import test from "node:test";
import { createDiscoveredModelId } from "../src/components/admin/model-id.ts";
const providerA = "11111111-1111-4111-8111-111111111111";
const providerB = "22222222-2222-4222-8222-222222222222";
test("discovered model IDs are deterministic, distinct, and API-compatible", async () => {
const inputs = [
[providerA, "gpt-4o"],
[providerB, "gpt-4o"],
[providerA, "GPT-4o"],
[providerA, " gpt-4o"],
[providerA, "gpt-4o "],
[providerA, "模型-α"],
] as const;
const ids = await Promise.all(inputs.map(([providerId, providerModel]) => createDiscoveredModelId(providerId, providerModel)));
assert.equal(new Set(ids).size, inputs.length);
assert.equal(ids[0], "m-f1966f65ba46e2c192e274f77c120dbc90f32e6caa2bcd75bb52e4f985b8cb");
assert.equal(await createDiscoveredModelId(providerA, "gpt-4o"), ids[0]);
for (const id of ids) {
assert.equal(id.length, 64);
assert.match(id, /^m-[0-9a-f]{62}$/);
}
});