From 10af8f88314b2a2e728956d59d99c12b7fd26cac Mon Sep 17 00:00:00 2001 From: yyh Date: Sun, 9 Aug 2026 15:02:55 +0800 Subject: [PATCH] fix(web): name plugin credential actions --- .../authorized/__tests__/item.spec.tsx | 24 ++++++------------- .../plugins/plugin-auth/authorized/item.tsx | 15 +++++++++--- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/web/app/components/plugins/plugin-auth/authorized/__tests__/item.spec.tsx b/web/app/components/plugins/plugin-auth/authorized/__tests__/item.spec.tsx index 26cf90178a0c77..3f306363a3062f 100644 --- a/web/app/components/plugins/plugin-auth/authorized/__tests__/item.spec.tsx +++ b/web/app/components/plugins/plugin-auth/authorized/__tests__/item.spec.tsx @@ -191,8 +191,7 @@ describe('Item Component', () => { ) const enterRenameMode = () => { - const firstButton = result.container.querySelectorAll('button')[0] as HTMLElement - fireEvent.click(firstButton) + fireEvent.click(screen.getByRole('button', { name: 'common.operation.rename' })) } return { ...result, onRename, enterRenameMode } @@ -337,7 +336,7 @@ describe('Item Component', () => { credentials: { api_key: 'secret' }, }) - const { container } = render( + render( { />, ) - const editButton = container - .querySelector('.i-ri-equalizer-2-line') - ?.closest('button') as HTMLElement - fireEvent.click(editButton) + fireEvent.click(screen.getByRole('button', { name: 'common.operation.edit' })) expect(onEdit).toHaveBeenCalledWith('edit-test-id', { api_key: 'secret', __name__: 'Edit Test', @@ -403,7 +399,7 @@ describe('Item Component', () => { const onDelete = vi.fn() const credential = createCredential({ id: 'delete-test-id' }) - const { container } = render( + render( { />, ) - const deleteButton = container - .querySelector('.i-ri-delete-bin-line') - ?.closest('button') as HTMLElement - fireEvent.click(deleteButton) + fireEvent.click(screen.getByRole('button', { name: 'common.operation.delete' })) expect(onDelete).toHaveBeenCalledWith('delete-test-id') }) @@ -521,7 +514,7 @@ describe('Item Component', () => { const onDelete = vi.fn() const credential = createCredential() - const { container } = render( + render( { />, ) - const deleteButton = container - .querySelector('.i-ri-delete-bin-line') - ?.closest('button') as HTMLElement - fireEvent.click(deleteButton) + fireEvent.click(screen.getByRole('button', { name: 'common.operation.delete' })) expect(onDelete).toHaveBeenCalled() }) }) diff --git a/web/app/components/plugins/plugin-auth/authorized/item.tsx b/web/app/components/plugins/plugin-auth/authorized/item.tsx index f36119c14fa5f6..313aed886c6a1e 100644 --- a/web/app/components/plugins/plugin-auth/authorized/item.tsx +++ b/web/app/components/plugins/plugin-auth/authorized/item.tsx @@ -177,6 +177,7 @@ const Item = ({ $['operation.rename'], { ns: 'common' })} disabled={disabled || !canManageCredential} onClick={(e) => { e.stopPropagation() @@ -184,7 +185,7 @@ const Item = ({ setRenameValue(credential.name) }} > - + } /> @@ -200,6 +201,7 @@ const Item = ({ $['operation.edit'], { ns: 'common' })} disabled={disabled || !canManageCredential} onClick={(e) => { e.stopPropagation() @@ -210,7 +212,10 @@ const Item = ({ }) }} > - + } /> @@ -222,6 +227,7 @@ const Item = ({ $['operation.delete'], { ns: 'common' })} className="hover:bg-transparent" disabled={disabled || !canManageCredential} onClick={(e) => { @@ -229,7 +235,10 @@ const Item = ({ onDelete?.(credential.id) }} > - + } />