From 1b55fe6f87bd96e1f3ddbc3233ba6de4fd64b6d1 Mon Sep 17 00:00:00 2001 From: yyh Date: Sun, 9 Aug 2026 14:39:00 +0800 Subject: [PATCH] fix(web): name saved item actions --- .../saved-items/__tests__/index.spec.tsx | 19 +++++++------------ .../app/text-generate/saved-items/index.tsx | 6 ++++-- 2 files changed, 11 insertions(+), 14 deletions(-) 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 48fea0cfafb350..c878d6aa5337c5 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() + render() - 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 794c20a83a1cd3..dae87686b242c1 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 = ({
{isShowTextToSpeech && } $['operation.copy'], { ns: 'common' })} onClick={() => { copy(answer) toast.success(t(($) => $['actionMsg.copySuccessfully'], { ns: 'common' })) }} > - + $['operation.delete'], { ns: 'common' })} onClick={() => { onRemove(id) }} > - +