Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions web/app/components/plugins/plugin-item/__tests__/action.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ const createActionProps = (overrides: Partial<ActionProps> = {}): ActionProps =>
const getDeleteConfirmButton = () =>
screen.getByRole('button', { name: /common\.operation\.confirm/ })
const getDeleteCancelButton = () => screen.getByRole('button', { name: 'common.operation.cancel' })
const getCheckForUpdatesButton = () =>
screen.getByRole('button', { name: 'plugin.action.checkForUpdates' })
const getPluginInfoButton = () => screen.getByRole('button', { name: 'plugin.action.pluginInfo' })
const getDeleteButton = () => screen.getByRole('button', { name: 'plugin.action.delete' })

// ==================== Tests ====================

Expand Down Expand Up @@ -165,7 +169,7 @@ describe('Action Component', () => {
render(<Action {...props} />)

// Assert
expect(getActionButtons()).toHaveLength(1)
expect(getDeleteButton()).toBeInTheDocument()
})

it('should render fetch new version button when isShowFetchNewVersion is true', () => {
Expand All @@ -180,7 +184,7 @@ describe('Action Component', () => {
render(<Action {...props} />)

// Assert
expect(getActionButtons()).toHaveLength(1)
expect(getCheckForUpdatesButton()).toBeInTheDocument()
})

it('should render info button when isShowInfo is true', () => {
Expand All @@ -195,7 +199,7 @@ describe('Action Component', () => {
render(<Action {...props} />)

// Assert
expect(getActionButtons()).toHaveLength(1)
expect(getPluginInfoButton()).toBeInTheDocument()
})

it('should render all buttons when all flags are true', () => {
Expand All @@ -210,7 +214,9 @@ describe('Action Component', () => {
render(<Action {...props} />)

// Assert
expect(getActionButtons()).toHaveLength(3)
expect(getCheckForUpdatesButton()).toBeInTheDocument()
expect(getPluginInfoButton()).toBeInTheDocument()
expect(getDeleteButton()).toBeInTheDocument()
})

it('should render no buttons when all flags are false', () => {
Expand Down Expand Up @@ -241,16 +247,15 @@ describe('Action Component', () => {
render(<Action {...props} />)

// Assert
const buttons = getActionButtons()
await user.hover(buttons[0]!)
await user.hover(getCheckForUpdatesButton())
expect(await screen.findByText('plugin.action.checkForUpdates'))!.toBeInTheDocument()
await user.unhover(buttons[0]!)
await user.unhover(getCheckForUpdatesButton())

await user.hover(buttons[1]!)
await user.hover(getPluginInfoButton())
expect(await screen.findByText('plugin.action.pluginInfo'))!.toBeInTheDocument()
await user.unhover(buttons[1]!)
await user.unhover(getPluginInfoButton())

await user.hover(buttons[2]!)
await user.hover(getDeleteButton())
expect(await screen.findByText('plugin.action.delete'))!.toBeInTheDocument()
})
})
Expand Down
17 changes: 12 additions & 5 deletions web/app/components/plugins/plugin-item/action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@ const Action: FC<Props> = ({
<Tooltip>
<TooltipTrigger
render={
<ActionButton onClick={handleFetchNewVersion}>
<span className="i-ri-loop-left-line size-4 text-text-tertiary" />
<ActionButton
aria-label={t(($) => $[`${i18nPrefix}.checkForUpdates`], { ns: 'plugin' })}
onClick={handleFetchNewVersion}
>
<span aria-hidden className="i-ri-loop-left-line size-4 text-text-tertiary" />
</ActionButton>
}
/>
Expand All @@ -134,8 +137,11 @@ const Action: FC<Props> = ({
<Tooltip>
<TooltipTrigger
render={
<ActionButton onClick={showPluginInfo}>
<span className="i-ri-information-2-line size-4 text-text-tertiary" />
<ActionButton
aria-label={t(($) => $[`${i18nPrefix}.pluginInfo`], { ns: 'plugin' })}
onClick={showPluginInfo}
>
<span aria-hidden className="i-ri-information-2-line size-4 text-text-tertiary" />
</ActionButton>
}
/>
Expand All @@ -149,10 +155,11 @@ const Action: FC<Props> = ({
<TooltipTrigger
render={
<ActionButton
aria-label={t(($) => $[`${i18nPrefix}.delete`], { ns: 'plugin' })}
className="text-text-tertiary hover:bg-state-destructive-hover hover:text-text-destructive"
onClick={showDeleteConfirm}
>
<span className="i-ri-delete-bin-line size-4" />
<span aria-hidden className="i-ri-delete-bin-line size-4" />
</ActionButton>
}
/>
Expand Down