mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-20 00:18:55 +00:00
Add group Fast form helpers
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user