Add group Fast form helpers

This commit is contained in:
Ritel-T
2026-09-01 04:34:06 +09:00
parent 1a40e5690f
commit 3fbce499d8
2 changed files with 46 additions and 0 deletions
@@ -0,0 +1,36 @@
import { describe, expect, it } from "vitest";
import {
normalizeGroupOpenAIFast,
supportsGroupOpenAIFast,
} from "../groupsOpenAIFast";
import en from "@/i18n/locales/en/admin/overview";
import zh from "@/i18n/locales/zh/admin/overview";
describe("groupsOpenAIFast", () => {
it("supports OpenAI and composite groups", () => {
expect(supportsGroupOpenAIFast("openai")).toBe(true);
expect(supportsGroupOpenAIFast("composite")).toBe(true);
expect(supportsGroupOpenAIFast("anthropic")).toBe(false);
});
it("clears stale enabled state on unsupported platforms", () => {
expect(normalizeGroupOpenAIFast("openai", true)).toBe(true);
expect(normalizeGroupOpenAIFast("composite", true)).toBe(true);
expect(normalizeGroupOpenAIFast("anthropic", true)).toBe(false);
expect(normalizeGroupOpenAIFast("openai", false)).toBe(false);
});
it("provides localized switch labels", () => {
expect(zh.groups.openaiFast).toMatchObject({
title: expect.any(String),
force: expect.any(String),
hint: expect.stringContaining("service_tier=priority"),
});
expect(en.groups.openaiFast).toMatchObject({
title: expect.any(String),
force: expect.any(String),
hint: expect.stringContaining("service_tier=priority"),
});
});
});
@@ -0,0 +1,10 @@
export function supportsGroupOpenAIFast(platform: string): boolean {
return platform === "openai" || platform === "composite";
}
export function normalizeGroupOpenAIFast(
platform: string,
enabled: boolean,
): boolean {
return supportsGroupOpenAIFast(platform) && enabled;
}