Merge pull request #2521 from Brisbanehuang/codex/fix-subscription-model-scopes
fix: hide model scopes for non-antigravity plans
This commit is contained in:
commit
a84bf3fab9
@ -147,6 +147,7 @@ const MODEL_SCOPE_LABELS: Record<string, string> = {
|
||||
}
|
||||
|
||||
const modelScopeLabels = computed(() => {
|
||||
if (platform.value !== 'antigravity') return []
|
||||
const scopes = props.plan.supported_model_scopes
|
||||
if (!scopes || scopes.length === 0) return []
|
||||
return scopes.map(s => MODEL_SCOPE_LABELS[s] || s)
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createI18n } from "vue-i18n";
|
||||
import SubscriptionPlanCard from "../SubscriptionPlanCard.vue";
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: "en",
|
||||
fallbackWarn: false,
|
||||
missingWarn: false,
|
||||
messages: {
|
||||
en: {
|
||||
payment: {
|
||||
days: "days",
|
||||
models: "Models",
|
||||
planCard: {
|
||||
quota: "Quota",
|
||||
rate: "Rate",
|
||||
unlimited: "Unlimited",
|
||||
},
|
||||
subscribeNow: "Subscribe now",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const mountPlanCard = (groupPlatform: string) =>
|
||||
mount(SubscriptionPlanCard, {
|
||||
props: {
|
||||
plan: {
|
||||
id: 1,
|
||||
group_id: 10,
|
||||
group_platform: groupPlatform,
|
||||
name: "Pro",
|
||||
price: 10,
|
||||
amount: 1000,
|
||||
features: [],
|
||||
rate_multiplier: 1,
|
||||
validity_days: 30,
|
||||
validity_unit: "day",
|
||||
supported_model_scopes: ["claude", "gemini_text", "gemini_image"],
|
||||
is_active: true,
|
||||
},
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
describe("SubscriptionPlanCard", () => {
|
||||
it("does not show Antigravity model scopes for OpenAI plans", () => {
|
||||
const text = mountPlanCard("openai").text();
|
||||
|
||||
expect(text).not.toContain("Claude");
|
||||
expect(text).not.toContain("Gemini");
|
||||
expect(text).not.toContain("Imagen");
|
||||
});
|
||||
|
||||
it("shows model scopes for Antigravity plans", () => {
|
||||
const text = mountPlanCard("antigravity").text();
|
||||
|
||||
expect(text).toContain("Claude");
|
||||
expect(text).toContain("Gemini");
|
||||
expect(text).toContain("Imagen");
|
||||
});
|
||||
});
|
||||
@ -2862,6 +2862,7 @@ import {
|
||||
resetMessagesDispatchFormState,
|
||||
type MessagesDispatchMappingRow,
|
||||
} from "./groupsMessagesDispatch";
|
||||
import { normalizeSupportedModelScopesForPlatform } from "./groupsSupportedModelScopes";
|
||||
|
||||
const { t } = useI18n();
|
||||
const appStore = useAppStore();
|
||||
@ -3707,6 +3708,10 @@ const handleCreateGroup = async () => {
|
||||
model_routing: convertRoutingRulesToApiFormat(
|
||||
createModelRoutingRules.value,
|
||||
),
|
||||
supported_model_scopes: normalizeSupportedModelScopesForPlatform(
|
||||
createForm.platform,
|
||||
createForm.supported_model_scopes,
|
||||
),
|
||||
messages_dispatch_model_config:
|
||||
createForm.platform === "openai"
|
||||
? messagesDispatchFormStateToConfig({
|
||||
@ -3838,6 +3843,10 @@ const handleUpdateGroup = async () => {
|
||||
model_routing: convertRoutingRulesToApiFormat(
|
||||
editModelRoutingRules.value,
|
||||
),
|
||||
supported_model_scopes: normalizeSupportedModelScopesForPlatform(
|
||||
editForm.platform,
|
||||
editForm.supported_model_scopes,
|
||||
),
|
||||
messages_dispatch_model_config:
|
||||
editForm.platform === "openai"
|
||||
? messagesDispatchFormStateToConfig({
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { normalizeSupportedModelScopesForPlatform } from "../groupsSupportedModelScopes";
|
||||
|
||||
describe("normalizeSupportedModelScopesForPlatform", () => {
|
||||
it("preserves model scopes for Antigravity groups", () => {
|
||||
expect(
|
||||
normalizeSupportedModelScopesForPlatform("antigravity", [
|
||||
"claude",
|
||||
"gemini_text",
|
||||
]),
|
||||
).toEqual(["claude", "gemini_text"]);
|
||||
});
|
||||
|
||||
it("returns an empty array for Antigravity groups without scopes", () => {
|
||||
expect(normalizeSupportedModelScopesForPlatform("antigravity", undefined)).toEqual([]);
|
||||
});
|
||||
|
||||
it("drops hidden model scopes for OpenAI groups", () => {
|
||||
expect(
|
||||
normalizeSupportedModelScopesForPlatform("openai", [
|
||||
"claude",
|
||||
"gemini_text",
|
||||
"gemini_image",
|
||||
]),
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it("drops hidden model scopes for other non-Antigravity groups", () => {
|
||||
expect(normalizeSupportedModelScopesForPlatform("claude", ["claude"])).toEqual([]);
|
||||
});
|
||||
});
|
||||
7
frontend/src/views/admin/groupsSupportedModelScopes.ts
Normal file
7
frontend/src/views/admin/groupsSupportedModelScopes.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export const normalizeSupportedModelScopesForPlatform = (
|
||||
platform: string,
|
||||
scopes: string[] | undefined,
|
||||
): string[] => {
|
||||
if (platform !== "antigravity") return [];
|
||||
return scopes ?? [];
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user