From f0c94957fda7c60da9d3a354875cfdf4e7a45e6a Mon Sep 17 00:00:00 2001 From: Seefs <40468931+seefs001@users.noreply.github.com> Date: Wed, 2 Dec 2026 13:52:23 +0800 Subject: [PATCH] fix(channels): enable VolcEngine upstream model discovery (#8306) --- .../__tests__/channel-configuration.test.tsx | 49 +++++++++++++++++++ web/src/features/channels/constants.ts | 1 + 2 files changed, 50 insertions(+) diff --git a/web/src/features/channels/components/__tests__/channel-configuration.test.tsx b/web/src/features/channels/components/__tests__/channel-configuration.test.tsx index ad1ad15961..aa20fd1061 100644 --- a/web/src/features/channels/components/__tests__/channel-configuration.test.tsx +++ b/web/src/features/channels/components/__tests__/channel-configuration.test.tsx @@ -1103,6 +1103,55 @@ test('a failed creation keeps its draft and prevents duplicate submission while expect(screen.getByLabelText('Name *')).toHaveValue('Video A') }) +test.each(['create', 'edit'] as const)( + 'VolcEngine %s exposes upstream discovery and lets users select fetched models', + async (mode) => { + editingChannel.type = 45 + const post = vi.spyOn(api, 'post').mockResolvedValue({ + data: { success: true, data: ['upstream-model'] }, + }) + const user = userEvent.setup() + render( + + ) + if (mode === 'create') { + await user.click(screen.getByRole('option', { name: /^VolcEngine / })) + fireEvent.change(screen.getByLabelText('API Key *'), { + target: { value: 'test-key' }, + }) + } else { + await screen.findByDisplayValue('Existing channel') + } + + const fetch = screen.getByRole('button', { name: 'Fetch from Upstream' }) + expect(fetch).toBeEnabled() + await user.click(fetch) + await user.click( + await screen.findByRole('checkbox', { name: 'upstream-model' }) + ) + expect(screen.getByRole('button', { name: 'upstream-model' })).toBeVisible() + if (mode === 'create') { + expect(post).toHaveBeenCalledWith( + '/api/channel/fetch_models', + expect.objectContaining({ + type: 45, + key: 'test-key', + base_url: 'https://ark.cn-beijing.volces.com', + }), + expect.anything() + ) + } else { + expect(api.get).toHaveBeenCalledWith( + '/api/channel/fetch_models/42', + expect.anything() + ) + expect(post).not.toHaveBeenCalled() + } + } +) + test('model discovery discards a response for old credentials and retains manually selected models', async () => { const oldReply = deferredResponse<{ data: { success: boolean; data: string[] } diff --git a/web/src/features/channels/constants.ts b/web/src/features/channels/constants.ts index a5d1874388..c89dac42f5 100644 --- a/web/src/features/channels/constants.ts +++ b/web/src/features/channels/constants.ts @@ -519,6 +519,7 @@ export const MODEL_FETCHABLE_TYPES = new Set([ 40, 42, 43, + 45, 47, 48, 57,