mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-03 16:41:20 +00:00
fix(frontend): preserve legacy Codex config mode
This commit is contained in:
1 parent
f09d63f54e
commit
ad3522e34b
4 files changed
+207
-9
No files matched your search
@@ -78,7 +78,7 @@ describe('UseKeyModal', () => {
|
||||
expect(parsed.provider.grok.models['gpt-5.6']).toBeUndefined()
|
||||
})
|
||||
|
||||
it('renders minimal image executor authorization in OpenAI Codex config', () => {
|
||||
it('keeps legacy OpenAI Codex config as the default', () => {
|
||||
const wrapper = mount(UseKeyModal, {
|
||||
props: {
|
||||
show: true,
|
||||
@@ -107,8 +107,8 @@ describe('UseKeyModal', () => {
|
||||
expect(configToml).not.toContain('model = "gpt-5.4"')
|
||||
expect(configToml).not.toContain('model_context_window')
|
||||
expect(configToml).not.toContain('model_auto_compact_token_limit')
|
||||
expect(configToml).toContain('requires_openai_auth = false')
|
||||
expect(configToml).toContain('http_headers = { "x-openai-actor-authorization" = "local-image-extension" }')
|
||||
expect(configToml).toContain('requires_openai_auth = true')
|
||||
expect(configToml).not.toContain('x-openai-actor-authorization')
|
||||
expect(configToml).not.toContain('env_key')
|
||||
expect(configToml).not.toContain('image_generation')
|
||||
expect(configToml).not.toContain('supports_websockets')
|
||||
@@ -118,7 +118,44 @@ describe('UseKeyModal', () => {
|
||||
expect(wrapper.text()).toContain('auth.json')
|
||||
})
|
||||
|
||||
it('renders minimal image executor authorization in OpenAI Codex WebSocket config', async () => {
|
||||
it('renders API Key Mode authorization in OpenAI Codex config', async () => {
|
||||
const wrapper = mount(UseKeyModal, {
|
||||
props: {
|
||||
show: true,
|
||||
apiKey: 'sk-test',
|
||||
baseUrl: 'https://example.com/v1',
|
||||
platform: 'openai'
|
||||
},
|
||||
global: {
|
||||
stubs: {
|
||||
BaseDialog: {
|
||||
template: '<div><slot /><slot name="footer" /></div>'
|
||||
},
|
||||
Icon: {
|
||||
template: '<span />'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const apiKeyMode = wrapper.get('[data-testid="codex-auth-mode-api-key"]')
|
||||
await apiKeyMode.trigger('click')
|
||||
await nextTick()
|
||||
|
||||
const codeBlocks = wrapper.findAll('pre code').map((code) => code.text())
|
||||
const configToml = codeBlocks.find((content) => content.includes('model_provider = "OpenAI"'))
|
||||
|
||||
expect(apiKeyMode.attributes('aria-checked')).toBe('true')
|
||||
expect(configToml).toBeDefined()
|
||||
expect(configToml).toContain('requires_openai_auth = false')
|
||||
expect(configToml).toContain('http_headers = { "x-openai-actor-authorization" = "local-image-extension" }')
|
||||
expect(configToml).not.toContain('env_key')
|
||||
expect(configToml).not.toContain('image_generation')
|
||||
expect(codeBlocks).toContain('{\n "OPENAI_API_KEY": "sk-test"\n}')
|
||||
expect(wrapper.text()).toContain('auth.json')
|
||||
})
|
||||
|
||||
it('keeps legacy OpenAI Codex WebSocket config as the default', async () => {
|
||||
const wrapper = mount(UseKeyModal, {
|
||||
props: {
|
||||
show: true,
|
||||
@@ -155,6 +192,51 @@ describe('UseKeyModal', () => {
|
||||
expect(configToml).not.toContain('model = "gpt-5.4"')
|
||||
expect(configToml).not.toContain('model_context_window')
|
||||
expect(configToml).not.toContain('model_auto_compact_token_limit')
|
||||
expect(configToml).toContain('requires_openai_auth = true')
|
||||
expect(configToml).not.toContain('x-openai-actor-authorization')
|
||||
expect(configToml).not.toContain('env_key')
|
||||
expect(configToml).not.toContain('image_generation')
|
||||
expect(configToml).toContain('supports_websockets = true')
|
||||
expect(configToml).toContain('[features]\nresponses_websockets_v2 = true\ngoals = true')
|
||||
expect(codeBlocks).toContain('{\n "OPENAI_API_KEY": "sk-test"\n}')
|
||||
expect(wrapper.text()).toContain('auth.json')
|
||||
})
|
||||
|
||||
it('preserves API Key Mode when switching to OpenAI Codex WebSocket config', async () => {
|
||||
const wrapper = mount(UseKeyModal, {
|
||||
props: {
|
||||
show: true,
|
||||
apiKey: 'sk-test',
|
||||
baseUrl: 'https://example.com/v1',
|
||||
platform: 'openai'
|
||||
},
|
||||
global: {
|
||||
stubs: {
|
||||
BaseDialog: {
|
||||
template: '<div><slot /><slot name="footer" /></div>'
|
||||
},
|
||||
Icon: {
|
||||
template: '<span />'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const apiKeyMode = wrapper.get('[data-testid="codex-auth-mode-api-key"]')
|
||||
await apiKeyMode.trigger('click')
|
||||
|
||||
const wsTab = wrapper.findAll('button').find((button) =>
|
||||
button.text().includes('keys.useKeyModal.cliTabs.codexCliWs')
|
||||
)
|
||||
expect(wsTab).toBeDefined()
|
||||
await wsTab!.trigger('click')
|
||||
await nextTick()
|
||||
|
||||
const codeBlocks = wrapper.findAll('pre code').map((code) => code.text())
|
||||
const configToml = codeBlocks.find((content) => content.includes('supports_websockets = true'))
|
||||
|
||||
expect(wrapper.get('[data-testid="codex-auth-mode-api-key"]').attributes('aria-checked')).toBe('true')
|
||||
expect(configToml).toBeDefined()
|
||||
expect(configToml).toContain('requires_openai_auth = false')
|
||||
expect(configToml).toContain('http_headers = { "x-openai-actor-authorization" = "local-image-extension" }')
|
||||
expect(configToml).not.toContain('env_key')
|
||||
@@ -162,7 +244,43 @@ describe('UseKeyModal', () => {
|
||||
expect(configToml).toContain('supports_websockets = true')
|
||||
expect(configToml).toContain('[features]\nresponses_websockets_v2 = true\ngoals = true')
|
||||
expect(codeBlocks).toContain('{\n "OPENAI_API_KEY": "sk-test"\n}')
|
||||
expect(wrapper.text()).toContain('auth.json')
|
||||
})
|
||||
|
||||
it('resets Codex authentication mode when the modal reopens or platform changes', async () => {
|
||||
const wrapper = mount(UseKeyModal, {
|
||||
props: {
|
||||
show: true,
|
||||
apiKey: 'sk-test',
|
||||
baseUrl: 'https://example.com/v1',
|
||||
platform: 'openai'
|
||||
},
|
||||
global: {
|
||||
stubs: {
|
||||
BaseDialog: {
|
||||
template: '<div><slot /><slot name="footer" /></div>'
|
||||
},
|
||||
Icon: {
|
||||
template: '<span />'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
await wrapper.get('[data-testid="codex-auth-mode-api-key"]').trigger('click')
|
||||
await wrapper.setProps({ show: false })
|
||||
await wrapper.setProps({ show: true })
|
||||
await nextTick()
|
||||
|
||||
expect(wrapper.get('[data-testid="codex-auth-mode-legacy"]').attributes('aria-checked')).toBe('true')
|
||||
expect(wrapper.findAll('pre code').map((code) => code.text()).join('\n')).toContain('requires_openai_auth = true')
|
||||
|
||||
await wrapper.get('[data-testid="codex-auth-mode-api-key"]').trigger('click')
|
||||
await wrapper.setProps({ platform: 'gemini' })
|
||||
await wrapper.setProps({ platform: 'openai' })
|
||||
await nextTick()
|
||||
|
||||
expect(wrapper.get('[data-testid="codex-auth-mode-legacy"]').attributes('aria-checked')).toBe('true')
|
||||
expect(wrapper.findAll('pre code').map((code) => code.text()).join('\n')).not.toContain('x-openai-actor-authorization')
|
||||
})
|
||||
|
||||
it('renders GPT-5.4 mini entry in OpenCode config', async () => {
|
||||
|
||||
Reference in new issue
Block a user