fix(accounts): preserve Antigravity options on refresh token import

This commit is contained in:
r266-tech committed 2026-11-29 13:32:29 +09:00
1 parent f53641e53c
commit cd73d7975e
2 files changed
+31 -3

No files matched your search

@@ -7128,14 +7128,13 @@ const handleAntigravityValidateRT = async (refreshTokenInput: string) => {
// Generate account name with index for batch
const accountName = refreshTokens.length > 1 ? `${form.name} #${i + 1}` : form.name
// Note: Antigravity doesn't have buildExtraInfo, so we pass empty extra or rely on credentials
const createPayload = withAntigravityConfirmFlag({
name: accountName,
notes: form.notes,
platform: 'antigravity',
type: 'oauth',
credentials,
extra: withUpstreamRequestIdHeader({}),
extra: withUpstreamRequestIdHeader(buildAntigravityExtra()),
proxy_id: form.proxy_id,
concurrency: form.concurrency,
load_factor: form.load_factor ?? undefined,
@@ -54,6 +54,9 @@ vi.mock('@/api/admin', () => ({
importCodexSession: importCodexSessionMock,
createOpenAICodexPAT: createOpenAICodexPATMock,
},
antigravity: {
refreshAntigravityToken: vi.fn().mockResolvedValue({ access_token: 'test-access-token' }),
},
settings: {
getWebSearchEmulationConfig: vi.fn().mockResolvedValue({ enabled: false, providers: [] }),
getSettings: vi.fn().mockResolvedValue({}),
@@ -94,7 +97,7 @@ const OAuthAuthorizationFlowStub = defineComponent({
initialInputMethod: String,
},
data: () => ({ inputMethod: 'manual' }),
emits: ['import-codex-session', 'import-codex-pat'],
emits: ['import-codex-session', 'import-codex-pat', 'validate-refresh-token'],
template: `
<div>
<button data-testid="import-codex-session" @click="$emit('import-codex-session', 'session-json')">session</button>
@@ -900,6 +903,32 @@ describe('CreateAccountModal OpenAI long-context billing', () => {
expect(createAccountMock.mock.calls[0]?.[0]?.upstream_billing_probe_enabled).toBe(false)
})
it('preserves Antigravity account options for every refresh token imported', async () => {
const wrapper = mountModal()
await selectButtonByText(wrapper, 'Antigravity')
await wrapper.get('[data-tour="account-form-name"]').setValue('Antigravity import')
for (const option of ['mixedScheduling', 'allowOverages']) {
const label = wrapper.findAll('label').find(label => label.text() === `admin.accounts.${option}`)
if (!label) throw new Error(`Missing ${option} checkbox`)
await label.get('input').setValue(true)
}
await wrapper.get('[data-testid="upstream-request-id-header"]').setValue('x-trace-id')
await wrapper.get('#create-account-form').trigger('submit.prevent')
await flushPromises()
wrapper.getComponent(OAuthAuthorizationFlowStub).vm.$emit('validate-refresh-token', 'test-one\ntest-two')
await flushPromises()
expect(createAccountMock).toHaveBeenCalledTimes(2)
for (const [payload] of createAccountMock.mock.calls) {
expect(payload.extra).toEqual({
mixed_scheduling: true,
allow_overages: true,
upstream_request_id_header: 'x-trace-id',
})
}
wrapper.unmount()
})
it('antigravity upstream 创建默认携带上游倍率探测开关', async () => {
// antigravity upstream 走独立创建 helper,
// 也必须与其余 API-key 平台一样默认开启探测并传递开关。