fix(models): keep manual creation available on catalog failure

This commit is contained in:
elky
2026-09-04 23:11:23 +08:00
parent c6718754d3
commit 29a9d608d9
2 changed files with 33 additions and 0 deletions
@@ -63,6 +63,16 @@
<RefreshCw class="h-3.5 w-3.5" />
重试
</Button>
<Button
type="button"
variant="ghost"
size="sm"
class="h-8"
data-testid="models-catalog-manual-entry"
@click="enterManualEntryMode"
>
直接手动填写
</Button>
</div>
<template v-else>
<!-- 提供商 Logo 横向选择 -->
@@ -279,6 +279,29 @@ describe('GlobalModelFormDialog preset replacement', () => {
expect(document.body.textContent).toContain('Fresh Model')
})
it('keeps manual model creation available when the external catalog is unavailable', async () => {
modelsDevMocks.getModelsDevList.mockRejectedValueOnce({
response: {
status: 503,
data: { detail: 'External models catalog unavailable' },
},
})
mountDialog()
await settle()
const manualEntryButton = document.body.querySelector<HTMLButtonElement>(
'[data-testid="models-catalog-manual-entry"]',
)
if (!manualEntryButton) throw new Error('Missing catalog manual-entry button')
manualEntryButton.click()
await settle()
expect(document.body.querySelector('[data-testid="models-catalog-load-error"]')).toBeNull()
expect(document.body.textContent).toContain('手动填写模式')
expect(document.body.querySelector('#model-name')).not.toBeNull()
})
it('drops the previous draft and submits only the newly selected model preset', async () => {
mountDialog()
await settle()