Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(web): name saved item actions (#40256)

yyh2067836851dc
diff --git a/web/app/components/app/text-generate/saved-items/__tests__/index.spec.tsx b/web/app/components/app/text-generate/saved-items/__tests__/index.spec.tsx
index 48fea0cfafb..c878d6aa533 100644
--- a/web/app/components/app/text-generate/saved-items/__tests__/index.spec.tsx
+++ b/web/app/components/app/text-generate/saved-items/__tests__/index.spec.tsx
@@ -37,27 +37,22 @@ describe('SavedItems', () => {
expect(markdownElement)!.toBeInTheDocument()
expect(screen.getByText('11 common.unit.char'))!.toBeInTheDocument()
- const actionArea = container.querySelector('[class*="bg-components-actionbar-bg"]')
- const actionButtons = actionArea?.querySelectorAll('button') ?? []
- expect(actionButtons.length).toBeGreaterThanOrEqual(3)
+ expect(screen.getByRole('button', { name: 'common.operation.copy' })).toBeInTheDocument()
+ expect(screen.getByRole('button', { name: 'common.operation.delete' })).toBeInTheDocument()
})
it('copies content and notifies, and triggers remove callback', () => {
const handleRemove = vi.fn()
- const { container } = render(<SavedItems {...baseProps} onRemove={handleRemove} />)
+ render(<SavedItems {...baseProps} onRemove={handleRemove} />)
- const actionArea = container.querySelector('[class*="bg-components-actionbar-bg"]')
- const actionButtons = actionArea?.querySelectorAll('button') ?? []
- expect(actionButtons.length).toBeGreaterThanOrEqual(3)
+ const copyButton = screen.getByRole('button', { name: 'common.operation.copy' })
+ const deleteButton = screen.getByRole('button', { name: 'common.operation.delete' })
- const copyButton = actionButtons[1]
- const deleteButton = actionButtons[2]
-
- fireEvent.click(copyButton!)
+ fireEvent.click(copyButton)
expect(mockCopy).toHaveBeenCalledWith('hello world')
expect(toastSuccessSpy).toHaveBeenCalledWith('common.actionMsg.copySuccessfully')
- fireEvent.click(deleteButton!)
+ fireEvent.click(deleteButton)
expect(handleRemove).toHaveBeenCalledWith('1')
})
})
diff --git a/web/app/components/app/text-generate/saved-items/index.tsx b/web/app/components/app/text-generate/saved-items/index.tsx
index 794c20a83a1..dae87686b24 100644
--- a/web/app/components/app/text-generate/saved-items/index.tsx
+++ b/web/app/components/app/text-generate/saved-items/index.tsx
@@ -49,19 +49,21 @@ const SavedItems: FC<ISavedItemsProps> = ({
<div className="ml-1 flex items-center gap-0.5 rounded-[10px] border-[0.5px] border-components-actionbar-border bg-components-actionbar-bg p-0.5 shadow-md backdrop-blur-xs">
{isShowTextToSpeech && <NewAudioButton value={answer} />}
<ActionButton
+ aria-label={t(($) => $['operation.copy'], { ns: 'common' })}
onClick={() => {
copy(answer)
toast.success(t(($) => $['actionMsg.copySuccessfully'], { ns: 'common' }))
}}
>
- <RiClipboardLine className="size-4" />
+ <RiClipboardLine aria-hidden="true" className="size-4" />
</ActionButton>
<ActionButton
+ aria-label={t(($) => $['operation.delete'], { ns: 'common' })}
onClick={() => {
onRemove(id)
}}
>
- <RiDeleteBinLine className="size-4" />
+ <RiDeleteBinLine aria-hidden="true" className="size-4" />
</ActionButton>
</div>
</div>