From d4d2c746c56f6aeb71b190fbac45b44136e7b3e8 Mon Sep 17 00:00:00 2001
From: IanShaw <131567472+IanShaw027@users.noreply.github.com>
Date: Wed, 19 Aug 2026 06:11:20 -0700
Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=EF=BC=9A=E4=BF=AE=E6=AD=A3?=
=?UTF-8?q?=E8=B4=A6=E5=8F=B7=E9=95=BF=E4=B8=8A=E4=B8=8B=E6=96=87=E5=BC=80?=
=?UTF-8?q?=E5=85=B3=E9=97=A8=E6=8E=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../components/account/CreateAccountModal.vue | 7 ++-
.../__tests__/CreateAccountModal.spec.ts | 63 +++++++++++++++++--
2 files changed, 63 insertions(+), 7 deletions(-)
diff --git a/frontend/src/components/account/CreateAccountModal.vue b/frontend/src/components/account/CreateAccountModal.vue
index fdcf33107a..47ee8c27d5 100644
--- a/frontend/src/components/account/CreateAccountModal.vue
+++ b/frontend/src/components/account/CreateAccountModal.vue
@@ -2957,7 +2957,8 @@
diff --git a/frontend/src/components/account/__tests__/CreateAccountModal.spec.ts b/frontend/src/components/account/__tests__/CreateAccountModal.spec.ts
index d70e7ec6d2..552998802f 100644
--- a/frontend/src/components/account/__tests__/CreateAccountModal.spec.ts
+++ b/frontend/src/components/account/__tests__/CreateAccountModal.spec.ts
@@ -7,11 +7,13 @@ const {
probeUpstreamBillingMock,
importCodexSessionMock,
createOpenAICodexPATMock,
+ authIsSimpleMode,
} = vi.hoisted(() => ({
createAccountMock: vi.fn(),
probeUpstreamBillingMock: vi.fn(),
importCodexSessionMock: vi.fn(),
createOpenAICodexPATMock: vi.fn(),
+ authIsSimpleMode: { value: true },
}))
vi.mock('@/stores/app', () => ({
@@ -23,7 +25,11 @@ vi.mock('@/stores/app', () => ({
}))
vi.mock('@/stores/auth', () => ({
- useAuthStore: () => ({ isSimpleMode: true }),
+ useAuthStore: () => ({
+ get isSimpleMode() {
+ return authIsSimpleMode.value
+ },
+ }),
}))
vi.mock('@/api/admin', () => ({
@@ -84,9 +90,29 @@ const OAuthAuthorizationFlowStub = defineComponent({
`,
})
-function mountModal() {
+const GroupSelectorStub = defineComponent({
+ name: 'GroupSelector',
+ props: {
+ modelValue: {
+ type: Array,
+ default: () => [],
+ },
+ },
+ emits: ['update:modelValue'],
+ template: `
+
+ `,
+})
+
+function mountModal(groups: any[] = []) {
return mount(CreateAccountModal, {
- props: { show: true, proxies: [], groups: [] },
+ props: { show: true, proxies: [], groups },
global: {
stubs: {
BaseDialog: BaseDialogStub,
@@ -97,7 +123,7 @@ function mountModal() {
PlatformIcon: true,
ProxySelector: true,
ProxyAdBanner: true,
- GroupSelector: true,
+ GroupSelector: GroupSelectorStub,
ModelWhitelistSelector: true,
QuotaLimitCard: true,
},
@@ -147,6 +173,7 @@ async function openCodexImportStep(toggleClicks = 0) {
describe('CreateAccountModal OpenAI long-context billing', () => {
beforeEach(() => {
+ authIsSimpleMode.value = true
createAccountMock.mockReset().mockResolvedValue({ id: 42, platform: 'openai', type: 'apikey' })
probeUpstreamBillingMock.mockReset().mockResolvedValue({})
importCodexSessionMock.mockReset().mockResolvedValue({
@@ -160,6 +187,34 @@ describe('CreateAccountModal OpenAI long-context billing', () => {
createOpenAICodexPATMock.mockReset().mockResolvedValue({})
})
+ it('hides only the redundant account toggle when every selected group enables tier pricing', async () => {
+ authIsSimpleMode.value = false
+ const wrapper = mountModal([
+ { id: 1, long_context_pricing_enabled: true },
+ { id: 2, long_context_pricing_enabled: true },
+ ])
+
+ await selectButtonByText(wrapper, 'OpenAI')
+ await wrapper.get('[data-testid="select-pricing-groups"]').trigger('click')
+
+ expect(wrapper.find('[data-testid="openai-long-context-billing-toggle"]').exists()).toBe(false)
+ expect(wrapper.find('[data-testid="create-openai-ws-mode"]').exists()).toBe(true)
+ })
+
+ it('keeps the account toggle when any selected group disables tier pricing', async () => {
+ authIsSimpleMode.value = false
+ const wrapper = mountModal([
+ { id: 1, long_context_pricing_enabled: true },
+ { id: 2, long_context_pricing_enabled: false },
+ ])
+
+ await selectButtonByText(wrapper, 'OpenAI')
+ await wrapper.get('[data-testid="select-pricing-groups"]').trigger('click')
+
+ expect(wrapper.find('[data-testid="openai-long-context-billing-toggle"]').exists()).toBe(true)
+ expect(wrapper.find('[data-testid="create-openai-ws-mode"]').exists()).toBe(true)
+ })
+
it('sends false explicitly for normal OpenAI account creation by default', async () => {
await submitApiKeyAccount('openai')