From 3fbce499d825d421dec933ecb5c7785da7420a22 Mon Sep 17 00:00:00 2001 From: Ritel-T Date: Sun, 23 Aug 2026 18:58:51 +0900 Subject: [PATCH] Add group Fast form helpers --- .../admin/__tests__/groupsOpenAIFast.spec.ts | 36 +++++++++++++++++++ frontend/src/views/admin/groupsOpenAIFast.ts | 10 ++++++ 2 files changed, 46 insertions(+) create mode 100644 frontend/src/views/admin/__tests__/groupsOpenAIFast.spec.ts create mode 100644 frontend/src/views/admin/groupsOpenAIFast.ts diff --git a/frontend/src/views/admin/__tests__/groupsOpenAIFast.spec.ts b/frontend/src/views/admin/__tests__/groupsOpenAIFast.spec.ts new file mode 100644 index 0000000000..e94ee5a36c --- /dev/null +++ b/frontend/src/views/admin/__tests__/groupsOpenAIFast.spec.ts @@ -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"), + }); + }); +}); diff --git a/frontend/src/views/admin/groupsOpenAIFast.ts b/frontend/src/views/admin/groupsOpenAIFast.ts new file mode 100644 index 0000000000..a4e3f544a2 --- /dev/null +++ b/frontend/src/views/admin/groupsOpenAIFast.ts @@ -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; +}