fix: tests

This commit is contained in:
yyh
2026-03-11 20:42:40 +08:00
parent 715a0fabfc
commit c08b9a289b
2 changed files with 14 additions and 4 deletions

View File

@ -170,9 +170,13 @@ vi.mock('@/service/use-plugins', () => ({
}))
// Mock config
vi.mock('@/config', () => ({
MARKETPLACE_API_PREFIX: 'https://marketplace.example.com',
}))
vi.mock('@/config', async () => {
const actual = await vi.importActual<typeof import('@/config')>('@/config')
return {
...actual,
MARKETPLACE_API_PREFIX: 'https://marketplace.example.com',
}
})
// Mock mitt context
vi.mock('@/context/mitt-context', () => ({

View File

@ -99,6 +99,12 @@ const UpdatePluginModal: FC<Props> = ({
}) as Awaited<ReturnType<typeof updateFromMarketPlace>> & FailedUpgradeResponse
if (response.task?.status === TaskStatus.failed) {
const failedPlugin = response.task.plugins?.find(plugin => plugin.plugin_unique_identifier === targetPackageInfo.id)
?? response.task.plugins?.[0]
Toast.notify({
type: 'error',
message: failedPlugin?.message || t('error', { ns: 'common' }),
})
setUploadStep(UploadStep.notStarted)
return
}
@ -132,7 +138,7 @@ const UpdatePluginModal: FC<Props> = ({
}
if (uploadStep === UploadStep.installed)
onSave()
}, [onSave, uploadStep, check, originalPackageInfo.id, handleRefetch, targetPackageInfo.id])
}, [onSave, uploadStep, check, originalPackageInfo.id, handleRefetch, t, targetPackageInfo.id])
const { mutateAsync } = useRemoveAutoUpgrade()
const invalidateReferenceSettings = useInvalidateReferenceSettings()