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 secret key delete action (#40297)

yyh509ea9afc4fb
diff --git a/web/app/components/develop/secret-key/__tests__/secret-key-modal.spec.tsx b/web/app/components/develop/secret-key/__tests__/secret-key-modal.spec.tsx
index b7b75c7722e..3a64bf3ed04 100644
--- a/web/app/components/develop/secret-key/__tests__/secret-key-modal.spec.tsx
+++ b/web/app/components/develop/secret-key/__tests__/secret-key-modal.spec.tsx
@@ -75,11 +75,10 @@ async function renderModal(appId?: string) {
return { ...result, onClose }
}
-async function confirmFirstKeyDeletion() {
+async function confirmKeyDeletion(accessibleName: string) {
const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime })
- const deleteButton = document.body.querySelectorAll('button.action-btn')[1]
- expect(deleteButton).toBeInTheDocument()
- await user.click(deleteButton!)
+ const deleteButton = screen.getByRole('button', { name: accessibleName })
+ await user.click(deleteButton)
await act(async () => {
vi.runAllTimers()
})
@@ -165,6 +164,12 @@ describe('SecretKeyModal', () => {
it('deletes an app API key through the generated mutation input', async () => {
appApiKeys = {
data: [
+ {
+ id: 'app-key-0',
+ token: 'other-app-secret-token-987654321',
+ type: 'app',
+ created_at: 1,
+ },
{
id: 'app-key-1',
token: 'app-secret-token-123456789',
@@ -175,7 +180,7 @@ describe('SecretKeyModal', () => {
}
await renderModal('app-123')
- await confirmFirstKeyDeletion()
+ await confirmKeyDeletion('common.operation.delete app...cret-token-123456789')
await waitFor(() => {
expect(deleteAppApiKey).toHaveBeenCalledWith({
@@ -187,6 +192,12 @@ describe('SecretKeyModal', () => {
it('deletes a dataset API key through the generated mutation input', async () => {
datasetApiKeys = {
data: [
+ {
+ id: 'dataset-key-0',
+ token: 'other-dataset-secret-token-987654321',
+ type: 'dataset',
+ created_at: 1,
+ },
{
id: 'dataset-key-1',
token: 'dataset-secret-token-123456789',
@@ -197,7 +208,7 @@ describe('SecretKeyModal', () => {
}
await renderModal()
- await confirmFirstKeyDeletion()
+ await confirmKeyDeletion('common.operation.delete dat...cret-token-123456789')
await waitFor(() => {
expect(deleteDatasetApiKey).toHaveBeenCalledWith({
diff --git a/web/app/components/develop/secret-key/secret-key-modal.tsx b/web/app/components/develop/secret-key/secret-key-modal.tsx
index 2fdc88570c2..31430978539 100644
--- a/web/app/components/develop/secret-key/secret-key-modal.tsx
+++ b/web/app/components/develop/secret-key/secret-key-modal.tsx
@@ -206,12 +206,13 @@ const SecretKeyModal = ({ isShow = false, appId, canManage, onClose }: ISecretKe
<CopyFeedback content={api.token} />
{canManage && (
<ActionButton
+ aria-label={`${t(($) => $['operation.delete'], { ns: 'common' })} ${generateToken(api.token)}`}
onClick={() => {
setDelKeyId(api.id)
setShowConfirmDelete(true)
}}
>
- <span className="i-ri-delete-bin-line size-4" />
+ <span aria-hidden className="i-ri-delete-bin-line size-4" />
</ActionButton>
)}
</div>