diff --git a/web/app/components/datasets/documents/components/document-list/hooks/use-document-actions.ts b/web/app/components/datasets/documents/components/document-list/hooks/use-document-actions.ts index 5496ba326f..56553faa9e 100644 --- a/web/app/components/datasets/documents/components/document-list/hooks/use-document-actions.ts +++ b/web/app/components/datasets/documents/components/document-list/hooks/use-document-actions.ts @@ -73,7 +73,7 @@ export const useDocumentActions = ({ return const [e] = await asyncRunSafe( - opApi({ datasetId, documentIds: selectedIds }) as Promise, + opApi({ datasetId, documentIds: selectedIds }), ) if (!e) { diff --git a/web/app/components/datasets/documents/detail/metadata/hooks/use-metadata-editor.ts b/web/app/components/datasets/documents/detail/metadata/hooks/use-metadata-editor.ts index df471cc949..d379b1aa55 100644 --- a/web/app/components/datasets/documents/detail/metadata/hooks/use-metadata-editor.ts +++ b/web/app/components/datasets/documents/detail/metadata/hooks/use-metadata-editor.ts @@ -37,7 +37,7 @@ export function useMetadataEditor({ docDetail }: UseMetadataEditorOptions) { metadata: (docDetail?.doc_metadata || {}) as Record, }) } - }, [docDetail?.doc_type, docDetail?.doc_metadata, doc_type]) + }, [docDetail, doc_type]) const confirmDocType = useCallback(() => { if (!tempDocType) diff --git a/web/app/components/datasets/documents/detail/metadata/index.tsx b/web/app/components/datasets/documents/detail/metadata/index.tsx index d329a5a33c..7a0c7f8723 100644 --- a/web/app/components/datasets/documents/detail/metadata/index.tsx +++ b/web/app/components/datasets/documents/detail/metadata/index.tsx @@ -73,17 +73,15 @@ const Metadata: FC = ({ docDetail, loading, onUpdate }) => { <> {metadataMap[metadataParams.documentType || 'book'].text} - {editStatus && ( -
- · -
- {t('operation.change', { ns: 'common' })} -
+
+ · +
+ {t('operation.change', { ns: 'common' })}
- )} +
)}
diff --git a/web/app/components/rag-pipeline/hooks/use-DSL.spec.ts b/web/app/components/rag-pipeline/hooks/use-DSL.spec.ts index 0f235516e0..d57c9e2a6f 100644 --- a/web/app/components/rag-pipeline/hooks/use-DSL.spec.ts +++ b/web/app/components/rag-pipeline/hooks/use-DSL.spec.ts @@ -77,19 +77,22 @@ vi.mock('@/app/components/workflow/constants', () => ({ // ============================================================================ describe('useDSL', () => { - let mockLink: { href: string, download: string, click: ReturnType } + let mockLink: { href: string, download: string, click: ReturnType, style: { display: string }, remove: ReturnType } let originalCreateElement: typeof document.createElement + let originalAppendChild: typeof document.body.appendChild let mockCreateObjectURL: ReturnType let mockRevokeObjectURL: ReturnType beforeEach(() => { vi.clearAllMocks() - // Create a proper mock link element + // Create a proper mock link element with all required properties for downloadBlob mockLink = { href: '', download: '', click: vi.fn(), + style: { display: '' }, + remove: vi.fn(), } // Save original and mock selectively - only intercept 'a' elements @@ -101,8 +104,13 @@ describe('useDSL', () => { return originalCreateElement(tagName) }) as typeof document.createElement - mockCreateObjectURL = vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:test-url') - mockRevokeObjectURL = vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => {}) + // Mock document.body.appendChild for downloadBlob + originalAppendChild = document.body.appendChild.bind(document.body) + document.body.appendChild = vi.fn((node: T): T => node) as typeof document.body.appendChild + + // downloadBlob uses window.URL, not URL + mockCreateObjectURL = vi.spyOn(window.URL, 'createObjectURL').mockReturnValue('blob:test-url') + mockRevokeObjectURL = vi.spyOn(window.URL, 'revokeObjectURL').mockImplementation(() => {}) // Default store state mockWorkflowStoreGetState.mockReturnValue({ @@ -119,6 +127,7 @@ describe('useDSL', () => { afterEach(() => { document.createElement = originalCreateElement + document.body.appendChild = originalAppendChild mockCreateObjectURL.mockRestore() mockRevokeObjectURL.mockRestore() vi.clearAllMocks()