fix: handle null plugin badges (#36767)

This commit is contained in:
Crazywoola 2026-05-28 15:00:32 +08:00 committed by GitHub
parent 57b02e341c
commit 91c1d3ad81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 3 deletions

View File

@ -465,6 +465,14 @@ describe('Card', () => {
expect(screen.queryByTestId('partner-badge')).not.toBeInTheDocument()
})
it('should handle null badges from the marketplace API', () => {
const plugin = createMockPlugin({ badges: null })
render(<Card payload={plugin} />)
expect(screen.queryByTestId('partner-badge')).not.toBeInTheDocument()
})
})
// ================================

View File

@ -53,7 +53,8 @@ const Card = ({
const { t } = useTranslation()
const { categoriesMap } = useCategories(true)
const currentWorkspaceId = useSelector(s => s.currentWorkspace.id)
const { category, type, name, org, label, brief, icon, icon_dark, verified, badges = [], from } = payload
const { category, type, name, org, label, brief, icon, icon_dark, verified, from } = payload
const badges = payload.badges ?? []
const { theme } = useTheme()
const iconSrc = getPluginCardIconUrl(
{ from, name, org, type },

View File

@ -190,7 +190,7 @@ export type PluginManifestInMarket = {
introduction: string
verified: boolean
install_count: number
badges: string[]
badges: string[] | null
verification: {
authorized_category: 'langgenius' | 'partner' | 'community'
}
@ -255,7 +255,7 @@ export type Plugin = {
settings: CredentialFormSchemaBase[]
}
tags: { name: string }[]
badges: string[]
badges: string[] | null
verification: {
authorized_category: 'langgenius' | 'partner' | 'community'
}