e.stopPropagation()}>
diff --git a/web/app/components/datasets/documents/components/operations.tsx b/web/app/components/datasets/documents/components/operations.tsx
index e2bd6f7c92..8692da927d 100644
--- a/web/app/components/datasets/documents/components/operations.tsx
+++ b/web/app/components/datasets/documents/components/operations.tsx
@@ -1,18 +1,6 @@
import type { OperationName } from '../types'
import type { CommonResponse } from '@/models/common'
import type { DocumentDownloadResponse } from '@/service/datasets'
-import { cn } from '@langgenius/dify-ui/cn'
-import { RiArchive2Line, RiDeleteBinLine, RiDownload2Line, RiEditLine, RiEqualizer2Line, RiLoopLeftLine, RiMoreFill, RiPauseCircleLine, RiPlayCircleLine } from '@remixicon/react'
-import { useBoolean, useDebounceFn } from 'ahooks'
-import { noop } from 'es-toolkit/function'
-import * as React from 'react'
-import { useCallback, useState } from 'react'
-import { useTranslation } from 'react-i18next'
-import Divider from '@/app/components/base/divider'
-import { SearchLinesSparkle } from '@/app/components/base/icons/src/vender/knowledge'
-import CustomPopover from '@/app/components/base/popover'
-import Switch from '@/app/components/base/switch'
-import Tooltip from '@/app/components/base/tooltip'
import {
AlertDialog,
AlertDialogActions,
@@ -21,8 +9,22 @@ import {
AlertDialogContent,
AlertDialogDescription,
AlertDialogTitle,
-} from '@/app/components/base/ui/alert-dialog'
-import { toast } from '@/app/components/base/ui/toast'
+} from '@langgenius/dify-ui/alert-dialog'
+import { cn } from '@langgenius/dify-ui/cn'
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuTrigger,
+} from '@langgenius/dify-ui/dropdown-menu'
+import { Switch } from '@langgenius/dify-ui/switch'
+import { toast } from '@langgenius/dify-ui/toast'
+import { useBoolean, useDebounceFn } from 'ahooks'
+import { noop } from 'es-toolkit/function'
+import * as React from 'react'
+import { useCallback, useState } from 'react'
+import { useTranslation } from 'react-i18next'
+import Divider from '@/app/components/base/divider'
+import Tooltip from '@/app/components/base/tooltip'
import { IS_CE_EDITION } from '@/config'
import { DataSourceType, DocumentActionType } from '@/models/datasets'
import { useRouter } from '@/next/navigation'
@@ -53,6 +55,7 @@ type OperationsProps = {
const Operations = ({ embeddingAvailable, datasetId, detail, selectedIds, onSelectedIdChange, onUpdate, scene = 'list', className = '' }: OperationsProps) => {
const { id, name, enabled = false, archived = false, data_source_type, display_status } = detail || {}
const [showModal, setShowModal] = useState(false)
+ const [isOperationsMenuOpen, setIsOperationsMenuOpen] = useState(false)
const [deleting, setDeleting] = useState(false)
const { t } = useTranslation()
const router = useRouter()
@@ -68,7 +71,7 @@ const Operations = ({ embeddingAvailable, datasetId, detail, selectedIds, onSele
const { mutateAsync: pauseDocument } = useDocumentPause()
const { mutateAsync: resumeDocument } = useDocumentResume()
const isListScene = scene === 'list'
- const onOperate = async (operationName: OperationName) => {
+ const onOperate = useCallback(async (operationName: OperationName) => {
let opApi
switch (operationName) {
case 'archive':
@@ -116,7 +119,25 @@ const Operations = ({ embeddingAvailable, datasetId, detail, selectedIds, onSele
}
if (operationName === DocumentActionType.delete)
setDeleting(false)
- }
+ }, [
+ archiveDocument,
+ data_source_type,
+ datasetId,
+ deleteDocument,
+ disableDocument,
+ enableDocument,
+ generateSummary,
+ id,
+ onSelectedIdChange,
+ onUpdate,
+ pauseDocument,
+ resumeDocument,
+ selectedIds,
+ syncDocument,
+ syncWebsite,
+ t,
+ unArchiveDocument,
+ ])
const { run: handleSwitch } = useDebounceFn((operationName: OperationName) => {
if (operationName === DocumentActionType.enable && enabled)
return
@@ -139,6 +160,9 @@ const Operations = ({ embeddingAvailable, datasetId, detail, selectedIds, onSele
const handleRenamed = useCallback(() => {
onUpdate()
}, [onUpdate])
+ const closeOperationsMenu = useCallback(() => {
+ setIsOperationsMenuOpen(false)
+ }, [])
const handleDownload = useCallback(async () => {
// Avoid repeated clicks while the signed URL request is in-flight.
if (isDownloading)
@@ -152,6 +176,28 @@ const Operations = ({ embeddingAvailable, datasetId, detail, selectedIds, onSele
// Trigger download without navigating away (helps avoid duplicate downloads in some browsers).
downloadUrl({ url: res.url, fileName: name })
}, [datasetId, downloadDocument, id, isDownloading, name, t])
+ const handleShowRename = useCallback(() => {
+ closeOperationsMenu()
+ handleShowRenameModal({
+ id: detail.id,
+ name: detail.name,
+ })
+ }, [closeOperationsMenu, detail.id, detail.name, handleShowRenameModal])
+ const handleMenuOperation = useCallback((operationName: OperationName) => {
+ closeOperationsMenu()
+ void onOperate(operationName)
+ }, [closeOperationsMenu, onOperate])
+ const handleDeleteClick = useCallback(() => {
+ closeOperationsMenu()
+ setShowModal(true)
+ }, [closeOperationsMenu])
+ const handleDownloadClick = useCallback((evt: React.MouseEvent ) => {
+ evt.preventDefault()
+ evt.stopPropagation()
+ evt.nativeEvent.stopImmediatePropagation?.()
+ closeOperationsMenu()
+ void handleDownload()
+ }, [closeOperationsMenu, handleDownload])
return (
e.stopPropagation()}>
{isListScene && !embeddingAvailable && ( )}
@@ -179,49 +225,56 @@ const Operations = ({ embeddingAvailable, datasetId, detail, selectedIds, onSele
: 'p-0.5 hover:bg-state-base-hover')}
onClick={() => router.push(`/datasets/${datasetId}/documents/${detail.id}/settings`)}
>
-
+
-
+ {
+ e.stopPropagation()
+ e.preventDefault()
+ }}
+ >
+
+
+
+
+
{!archived && (
<>
- {
- handleShowRenameModal({
- id: detail.id,
- name: detail.name,
- })
- }}
- >
-
+
+
{t('list.table.rename', { ns: 'datasetDocuments' })}
{data_source_type === DataSourceType.FILE && (
- {
- evt.preventDefault()
- evt.stopPropagation()
- evt.nativeEvent.stopImmediatePropagation?.()
- handleDownload()
- }}
- >
-
+
+
{t('list.action.download', { ns: 'datasetDocuments' })}
)}
{['notion_import', DataSourceType.WEB].includes(data_source_type) && (
- onOperate('sync')}>
-
+ handleMenuOperation('sync')}>
+
{t('list.action.sync', { ns: 'datasetDocuments' })}
)}
{IS_CE_EDITION && (
- onOperate('summary')}>
-
+ handleMenuOperation('summary')}>
+
{t('list.action.summary', { ns: 'datasetDocuments' })}
)}
@@ -230,62 +283,44 @@ const Operations = ({ embeddingAvailable, datasetId, detail, selectedIds, onSele
)}
{archived && data_source_type === DataSourceType.FILE && (
<>
- {
- evt.preventDefault()
- evt.stopPropagation()
- evt.nativeEvent.stopImmediatePropagation?.()
- handleDownload()
- }}
- >
-
+
+
{t('list.action.download', { ns: 'datasetDocuments' })}
>
)}
{!archived && display_status?.toLowerCase() === 'indexing' && (
- onOperate('pause')}>
-
+ handleMenuOperation('pause')}>
+
{t('list.action.pause', { ns: 'datasetDocuments' })}
)}
{!archived && display_status?.toLowerCase() === 'paused' && (
- onOperate('resume')}>
-
+ handleMenuOperation('resume')}>
+
{t('list.action.resume', { ns: 'datasetDocuments' })}
)}
{!archived && (
- onOperate('archive')}>
-
+ handleMenuOperation('archive')}>
+
{t('list.action.archive', { ns: 'datasetDocuments' })}
)}
{archived && (
- onOperate('un_archive')}>
-
+ handleMenuOperation('un_archive')}>
+
{t('list.action.unarchive', { ns: 'datasetDocuments' })}
)}
- setShowModal(true)}>
-
+
+
{t('list.action.delete', { ns: 'datasetDocuments' })}
- )}
- trigger="click"
- position="br"
- btnElement={(
-
-
-
- )}
- btnClassName={open => cn(isListScene ? s.actionIconWrapperList : s.actionIconWrapperDetail, open ? '!hover:bg-state-base-hover !shadow-none' : '!bg-transparent')}
- popupClassName="!w-full"
- className={`!z-20 flex h-fit !w-[200px] justify-end ${className}`}
- />
+
+
>
)}
!open && setShowModal(false)}>
diff --git a/web/app/components/datasets/documents/components/rename-modal.tsx b/web/app/components/datasets/documents/components/rename-modal.tsx
index c6f393f1ce..fc4626676b 100644
--- a/web/app/components/datasets/documents/components/rename-modal.tsx
+++ b/web/app/components/datasets/documents/components/rename-modal.tsx
@@ -1,13 +1,13 @@
'use client'
import type { FC } from 'react'
+import { Button } from '@langgenius/dify-ui/button'
+import { toast } from '@langgenius/dify-ui/toast'
import { useBoolean } from 'ahooks'
import * as React from 'react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import Input from '@/app/components/base/input'
import Modal from '@/app/components/base/modal'
-import { Button } from '@/app/components/base/ui/button'
-import { toast } from '@/app/components/base/ui/toast'
import { renameDocumentName } from '@/service/datasets'
type Props = {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/__tests__/index.spec.tsx
index 8a2e251770..7daff43a8b 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/__tests__/index.spec.tsx
@@ -569,7 +569,7 @@ describe('StepOneContent', () => {
it('should render VectorSpaceFull when isShowVectorSpaceFull is true', () => {
render()
- expect(screen.getByTestId('vector-space-full')).toBeInTheDocument()
+ expect(screen.getByTestId('vector-space-full'))!.toBeInTheDocument()
})
it('should not render VectorSpaceFull when isShowVectorSpaceFull is false', () => {
@@ -587,7 +587,7 @@ describe('StepOneContent', () => {
localFileListLength={2}
/>,
)
- expect(screen.getByTestId('upgrade-card')).toBeInTheDocument()
+ expect(screen.getByTestId('upgrade-card'))!.toBeInTheDocument()
})
it('should not render UpgradeCard when supportBatchUpload is true', () => {
@@ -618,7 +618,7 @@ describe('StepOneContent', () => {
render()
const nextButton = screen.getByRole('button', { name: /datasetCreation.stepOne.button/i })
- expect(nextButton).toBeDisabled()
+ expect(nextButton)!.toBeDisabled()
})
})
@@ -664,17 +664,17 @@ describe('StepTwoContent', () => {
it('should render ProcessDocuments component', () => {
render()
- expect(screen.getByTestId('process-documents')).toBeInTheDocument()
+ expect(screen.getByTestId('process-documents'))!.toBeInTheDocument()
})
it('should pass dataSourceNodeId to ProcessDocuments', () => {
render()
- expect(screen.getByTestId('datasource-node-id')).toHaveTextContent('custom-node')
+ expect(screen.getByTestId('datasource-node-id'))!.toHaveTextContent('custom-node')
})
it('should pass isRunning to ProcessDocuments', () => {
render()
- expect(screen.getByTestId('is-running')).toHaveTextContent('true')
+ expect(screen.getByTestId('is-running'))!.toHaveTextContent('true')
})
it('should call onProcess when process button is clicked', () => {
@@ -709,18 +709,18 @@ describe('StepThreeContent', () => {
it('should render Processing component', () => {
render()
- expect(screen.getByTestId('processing')).toBeInTheDocument()
+ expect(screen.getByTestId('processing'))!.toBeInTheDocument()
})
it('should pass batchId to Processing', () => {
render()
- expect(screen.getByTestId('batch-id')).toHaveTextContent('batch-123')
+ expect(screen.getByTestId('batch-id'))!.toHaveTextContent('batch-123')
})
it('should pass documents count to Processing', () => {
const documents = [{ id: '1' }, { id: '2' }]
render()
- expect(screen.getByTestId('documents-count')).toHaveTextContent('2')
+ expect(screen.getByTestId('documents-count'))!.toHaveTextContent('2')
})
})
@@ -787,8 +787,8 @@ describe('StepOnePreview', () => {
currentLocalFile={createMockFile()}
/>,
)
- expect(screen.getByTestId('file-preview')).toBeInTheDocument()
- expect(screen.getByTestId('file-name')).toHaveTextContent('test.txt')
+ expect(screen.getByTestId('file-preview'))!.toBeInTheDocument()
+ expect(screen.getByTestId('file-name'))!.toHaveTextContent('test.txt')
})
it('should render OnlineDocumentPreview when currentDocument is set', () => {
@@ -799,7 +799,7 @@ describe('StepOnePreview', () => {
currentDocument={createMockNotionPage()}
/>,
)
- expect(screen.getByTestId('online-document-preview')).toBeInTheDocument()
+ expect(screen.getByTestId('online-document-preview'))!.toBeInTheDocument()
})
it('should render WebsitePreview when currentWebsite is set', () => {
@@ -809,7 +809,7 @@ describe('StepOnePreview', () => {
currentWebsite={createMockCrawlResult()}
/>,
)
- expect(screen.getByTestId('web-preview')).toBeInTheDocument()
+ expect(screen.getByTestId('web-preview'))!.toBeInTheDocument()
})
it('should call hidePreviewLocalFile when hide button is clicked', () => {
@@ -868,22 +868,22 @@ describe('StepTwoPreview', () => {
it('should render ChunkPreview component', () => {
render()
- expect(screen.getByTestId('chunk-preview')).toBeInTheDocument()
+ expect(screen.getByTestId('chunk-preview'))!.toBeInTheDocument()
})
it('should pass datasourceType to ChunkPreview', () => {
render()
- expect(screen.getByTestId('datasource-type')).toHaveTextContent(DatasourceType.onlineDocument)
+ expect(screen.getByTestId('datasource-type'))!.toHaveTextContent(DatasourceType.onlineDocument)
})
it('should pass isIdle to ChunkPreview', () => {
render()
- expect(screen.getByTestId('is-idle')).toHaveTextContent('false')
+ expect(screen.getByTestId('is-idle'))!.toHaveTextContent('false')
})
it('should pass isPendingPreview to ChunkPreview', () => {
render()
- expect(screen.getByTestId('is-pending')).toHaveTextContent('true')
+ expect(screen.getByTestId('is-pending'))!.toHaveTextContent('true')
})
it('should call onPreview when preview button is clicked', () => {
@@ -1092,7 +1092,7 @@ describe('Store Hooks', () => {
mockStoreState.selectedFileIds = ['file-1']
const { result } = renderHook(() => useOnlineDrive())
expect(result.current.selectedOnlineDriveFileList).toHaveLength(1)
- expect(result.current.selectedOnlineDriveFileList[0].id).toBe('file-1')
+ expect(result.current.selectedOnlineDriveFileList[0]!.id).toBe('file-1')
})
})
})
@@ -1166,8 +1166,8 @@ describe('useDatasourceOptions', () => {
const { result } = renderHook(() => useDatasourceOptions(mockNodes))
expect(result.current).toHaveLength(1)
- expect(result.current[0].label).toBe('Local File Source')
- expect(result.current[0].value).toBe('node-1')
+ expect(result.current[0]!.label).toBe('Local File Source')
+ expect(result.current[0]!.value).toBe('node-1')
})
it('should return multiple options for multiple data source nodes', () => {
@@ -1616,7 +1616,7 @@ describe('StepOneContent - All Datasource Types', () => {
datasourceType={DatasourceType.onlineDocument}
/>,
)
- expect(screen.getByTestId('online-documents-component')).toBeInTheDocument()
+ expect(screen.getByTestId('online-documents-component'))!.toBeInTheDocument()
})
it('should render WebsiteCrawl when datasourceType is websiteCrawl', () => {
@@ -1632,7 +1632,7 @@ describe('StepOneContent - All Datasource Types', () => {
datasourceType={DatasourceType.websiteCrawl}
/>,
)
- expect(screen.getByTestId('website-crawl-component')).toBeInTheDocument()
+ expect(screen.getByTestId('website-crawl-component'))!.toBeInTheDocument()
})
it('should render OnlineDrive when datasourceType is onlineDrive', () => {
@@ -1648,7 +1648,7 @@ describe('StepOneContent - All Datasource Types', () => {
datasourceType={DatasourceType.onlineDrive}
/>,
)
- expect(screen.getByTestId('online-drive-component')).toBeInTheDocument()
+ expect(screen.getByTestId('online-drive-component'))!.toBeInTheDocument()
})
it('should render LocalFile when datasourceType is localFile', () => {
@@ -1659,7 +1659,7 @@ describe('StepOneContent - All Datasource Types', () => {
datasourceType={DatasourceType.localFile}
/>,
)
- expect(screen.getByTestId('local-file-component')).toBeInTheDocument()
+ expect(screen.getByTestId('local-file-component'))!.toBeInTheDocument()
})
})
@@ -1690,7 +1690,8 @@ describe('StepTwoPreview - File List Mapping', () => {
)
// ChunkPreview should be rendered
- expect(screen.getByTestId('chunk-preview')).toBeInTheDocument()
+ // ChunkPreview should be rendered
+ expect(screen.getByTestId('chunk-preview'))!.toBeInTheDocument()
})
})
diff --git a/web/app/components/datasets/documents/create-from-pipeline/__tests__/step-indicator.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/__tests__/step-indicator.spec.tsx
index 7103dced26..7bffe3577e 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/__tests__/step-indicator.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/__tests__/step-indicator.spec.tsx
@@ -19,14 +19,14 @@ describe('StepIndicator', () => {
const { container } = render()
const dots = container.querySelectorAll('.rounded-lg')
// Second step (index 1) should be active
- expect(dots[1].className).toContain('bg-state-accent-solid')
- expect(dots[1].className).toContain('w-2')
+ expect(dots[1]!.className).toContain('bg-state-accent-solid')
+ expect(dots[1]!.className).toContain('w-2')
})
it('should not apply active style to non-current steps', () => {
const { container } = render()
const dots = container.querySelectorAll('.rounded-lg')
- expect(dots[1].className).toContain('bg-divider-solid')
- expect(dots[2].className).toContain('bg-divider-solid')
+ expect(dots[1]!.className).toContain('bg-divider-solid')
+ expect(dots[2]!.className).toContain('bg-divider-solid')
})
})
diff --git a/web/app/components/datasets/documents/create-from-pipeline/actions/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/actions/index.tsx
index 64c5faac33..caffed6500 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/actions/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/actions/index.tsx
@@ -1,9 +1,9 @@
+import { Button } from '@langgenius/dify-ui/button'
import { RiArrowRightLine } from '@remixicon/react'
import * as React from 'react'
import { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import Checkbox from '@/app/components/base/checkbox'
-import { Button } from '@/app/components/base/ui/button'
import Link from '@/next/link'
import { useParams } from '@/next/navigation'
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source-options/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source-options/__tests__/index.spec.tsx
index 0ac2dfce20..78542ad522 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source-options/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source-options/__tests__/index.spec.tsx
@@ -129,7 +129,7 @@ describe('DatasourceIcon', () => {
it('should render without crashing', () => {
const { container } = render()
- expect(container.firstChild).toBeInTheDocument()
+ expect(container.firstChild)!.toBeInTheDocument()
})
it('should render icon with background image', () => {
@@ -138,15 +138,16 @@ describe('DatasourceIcon', () => {
const { container } = render()
const iconDiv = container.querySelector('[style*="background-image"]')
- expect(iconDiv).toHaveStyle({ backgroundImage: `url(${iconUrl})` })
+ expect(iconDiv)!.toHaveStyle({ backgroundImage: `url(${iconUrl})` })
})
it('should render with default size (sm)', () => {
const { container } = render()
// Assert - Default size is 'sm' which maps to 'w-5 h-5'
- expect(container.firstChild).toHaveClass('w-5')
- expect(container.firstChild).toHaveClass('h-5')
+ // Assert - Default size is 'sm' which maps to 'w-5 h-5'
+ expect(container.firstChild)!.toHaveClass('w-5')
+ expect(container.firstChild)!.toHaveClass('h-5')
})
})
@@ -157,9 +158,9 @@ describe('DatasourceIcon', () => {
,
)
- expect(container.firstChild).toHaveClass('w-4')
- expect(container.firstChild).toHaveClass('h-4')
- expect(container.firstChild).toHaveClass('rounded-[5px]')
+ expect(container.firstChild)!.toHaveClass('w-4')
+ expect(container.firstChild)!.toHaveClass('h-4')
+ expect(container.firstChild)!.toHaveClass('rounded-[5px]')
})
it('should render with sm size', () => {
@@ -167,9 +168,9 @@ describe('DatasourceIcon', () => {
,
)
- expect(container.firstChild).toHaveClass('w-5')
- expect(container.firstChild).toHaveClass('h-5')
- expect(container.firstChild).toHaveClass('rounded-md')
+ expect(container.firstChild)!.toHaveClass('w-5')
+ expect(container.firstChild)!.toHaveClass('h-5')
+ expect(container.firstChild)!.toHaveClass('rounded-md')
})
it('should render with md size', () => {
@@ -177,9 +178,9 @@ describe('DatasourceIcon', () => {
,
)
- expect(container.firstChild).toHaveClass('w-6')
- expect(container.firstChild).toHaveClass('h-6')
- expect(container.firstChild).toHaveClass('rounded-lg')
+ expect(container.firstChild)!.toHaveClass('w-6')
+ expect(container.firstChild)!.toHaveClass('h-6')
+ expect(container.firstChild)!.toHaveClass('rounded-lg')
})
})
@@ -189,7 +190,7 @@ describe('DatasourceIcon', () => {
,
)
- expect(container.firstChild).toHaveClass('custom-class')
+ expect(container.firstChild)!.toHaveClass('custom-class')
})
it('should merge custom className with default classes', () => {
@@ -197,9 +198,9 @@ describe('DatasourceIcon', () => {
,
)
- expect(container.firstChild).toHaveClass('custom-class')
- expect(container.firstChild).toHaveClass('w-5')
- expect(container.firstChild).toHaveClass('h-5')
+ expect(container.firstChild)!.toHaveClass('custom-class')
+ expect(container.firstChild)!.toHaveClass('w-5')
+ expect(container.firstChild)!.toHaveClass('h-5')
})
})
@@ -208,7 +209,7 @@ describe('DatasourceIcon', () => {
const { container } = render()
const iconDiv = container.querySelector('[style*="background-image"]')
- expect(iconDiv).toHaveStyle({ backgroundImage: 'url()' })
+ expect(iconDiv)!.toHaveStyle({ backgroundImage: 'url()' })
})
it('should handle special characters in iconUrl', () => {
@@ -217,7 +218,7 @@ describe('DatasourceIcon', () => {
const { container } = render()
const iconDiv = container.querySelector('[style*="background-image"]')
- expect(iconDiv).toHaveStyle({ backgroundImage: `url(${iconUrl})` })
+ expect(iconDiv)!.toHaveStyle({ backgroundImage: `url(${iconUrl})` })
})
it('should handle data URL as iconUrl', () => {
@@ -226,7 +227,7 @@ describe('DatasourceIcon', () => {
const { container } = render()
const iconDiv = container.querySelector('[style*="background-image"]')
- expect(iconDiv).toBeInTheDocument()
+ expect(iconDiv)!.toBeInTheDocument()
})
})
})
@@ -235,25 +236,26 @@ describe('DatasourceIcon', () => {
it('should have flex container classes', () => {
const { container } = render()
- expect(container.firstChild).toHaveClass('flex')
- expect(container.firstChild).toHaveClass('items-center')
- expect(container.firstChild).toHaveClass('justify-center')
+ expect(container.firstChild)!.toHaveClass('flex')
+ expect(container.firstChild)!.toHaveClass('items-center')
+ expect(container.firstChild)!.toHaveClass('justify-center')
})
it('should have shadow-xs class from size map', () => {
const { container } = render()
// Assert - Default size 'sm' has shadow-xs
- expect(container.firstChild).toHaveClass('shadow-xs')
+ // Assert - Default size 'sm' has shadow-xs
+ expect(container.firstChild)!.toHaveClass('shadow-xs')
})
it('should have inner div with bg-cover class', () => {
const { container } = render()
const innerDiv = container.querySelector('.bg-cover')
- expect(innerDiv).toBeInTheDocument()
- expect(innerDiv).toHaveClass('bg-center')
- expect(innerDiv).toHaveClass('rounded-md')
+ expect(innerDiv)!.toBeInTheDocument()
+ expect(innerDiv)!.toHaveClass('bg-center')
+ expect(innerDiv)!.toHaveClass('rounded-md')
})
})
})
@@ -519,13 +521,13 @@ describe('OptionCard', () => {
it('should render without crashing', () => {
renderWithProviders()
- expect(screen.getByText('Test Option')).toBeInTheDocument()
+ expect(screen.getByText('Test Option'))!.toBeInTheDocument()
})
it('should render label text', () => {
renderWithProviders()
- expect(screen.getByText('Custom Label')).toBeInTheDocument()
+ expect(screen.getByText('Custom Label'))!.toBeInTheDocument()
})
it('should render DatasourceIcon component', () => {
@@ -533,7 +535,7 @@ describe('OptionCard', () => {
// Assert - DatasourceIcon container should exist
const iconContainer = container.querySelector('.size-8')
- expect(iconContainer).toBeInTheDocument()
+ expect(iconContainer)!.toBeInTheDocument()
})
it('should set title attribute for label truncation', () => {
@@ -542,7 +544,7 @@ describe('OptionCard', () => {
renderWithProviders()
const labelElement = screen.getByText(longLabel)
- expect(labelElement).toHaveAttribute('title', longLabel)
+ expect(labelElement)!.toHaveAttribute('title', longLabel)
})
})
@@ -554,8 +556,8 @@ describe('OptionCard', () => {
)
const card = container.firstChild
- expect(card).toHaveClass('border-components-option-card-option-selected-border')
- expect(card).toHaveClass('bg-components-option-card-option-selected-bg')
+ expect(card)!.toHaveClass('border-components-option-card-option-selected-border')
+ expect(card)!.toHaveClass('bg-components-option-card-option-selected-bg')
})
it('should apply unselected styles when selected is false', () => {
@@ -564,22 +566,22 @@ describe('OptionCard', () => {
)
const card = container.firstChild
- expect(card).toHaveClass('border-components-option-card-option-border')
- expect(card).toHaveClass('bg-components-option-card-option-bg')
+ expect(card)!.toHaveClass('border-components-option-card-option-border')
+ expect(card)!.toHaveClass('bg-components-option-card-option-bg')
})
it('should apply text-text-primary to label when selected', () => {
renderWithProviders()
const label = screen.getByText('Test Option')
- expect(label).toHaveClass('text-text-primary')
+ expect(label)!.toHaveClass('text-text-primary')
})
it('should apply text-text-secondary to label when not selected', () => {
renderWithProviders()
const label = screen.getByText('Test Option')
- expect(label).toHaveClass('text-text-secondary')
+ expect(label)!.toHaveClass('text-text-secondary')
})
})
@@ -593,7 +595,7 @@ describe('OptionCard', () => {
// Act - Click on the label text's parent card
const labelElement = screen.getByText('Test Option')
const card = labelElement.closest('[class*="cursor-pointer"]')
- expect(card).toBeInTheDocument()
+ expect(card)!.toBeInTheDocument()
fireEvent.click(card!)
expect(mockOnClick).toHaveBeenCalledTimes(1)
@@ -607,11 +609,12 @@ describe('OptionCard', () => {
// Act - Click on the label text's parent card should not throw
const labelElement = screen.getByText('Test Option')
const card = labelElement.closest('[class*="cursor-pointer"]')
- expect(card).toBeInTheDocument()
+ expect(card)!.toBeInTheDocument()
fireEvent.click(card!)
// Assert - Component should still be rendered
- expect(screen.getByText('Test Option')).toBeInTheDocument()
+ // Assert - Component should still be rendered
+ expect(screen.getByText('Test Option'))!.toBeInTheDocument()
})
})
@@ -631,35 +634,35 @@ describe('OptionCard', () => {
it('should have cursor-pointer class', () => {
const { container } = renderWithProviders()
- expect(container.firstChild).toHaveClass('cursor-pointer')
+ expect(container.firstChild)!.toHaveClass('cursor-pointer')
})
it('should have flex layout classes', () => {
const { container } = renderWithProviders()
- expect(container.firstChild).toHaveClass('flex')
- expect(container.firstChild).toHaveClass('items-center')
- expect(container.firstChild).toHaveClass('gap-2')
+ expect(container.firstChild)!.toHaveClass('flex')
+ expect(container.firstChild)!.toHaveClass('items-center')
+ expect(container.firstChild)!.toHaveClass('gap-2')
})
it('should have rounded-xl border', () => {
const { container } = renderWithProviders()
- expect(container.firstChild).toHaveClass('rounded-xl')
- expect(container.firstChild).toHaveClass('border')
+ expect(container.firstChild)!.toHaveClass('rounded-xl')
+ expect(container.firstChild)!.toHaveClass('border')
})
it('should have padding p-3', () => {
const { container } = renderWithProviders()
- expect(container.firstChild).toHaveClass('p-3')
+ expect(container.firstChild)!.toHaveClass('p-3')
})
it('should have line-clamp-2 for label truncation', () => {
renderWithProviders()
const label = screen.getByText('Test Option')
- expect(label).toHaveClass('line-clamp-2')
+ expect(label)!.toHaveClass('line-clamp-2')
})
})
@@ -669,7 +672,7 @@ describe('OptionCard', () => {
expect(OptionCard).toBeDefined()
// React.memo wraps the component, so we check it renders correctly
const { container } = renderWithProviders()
- expect(container.firstChild).toBeInTheDocument()
+ expect(container.firstChild)!.toBeInTheDocument()
})
})
})
@@ -698,27 +701,27 @@ describe('DataSourceOptions', () => {
it('should render without crashing', () => {
renderWithProviders()
- expect(screen.getByText('Data Source 1')).toBeInTheDocument()
- expect(screen.getByText('Data Source 2')).toBeInTheDocument()
- expect(screen.getByText('Data Source 3')).toBeInTheDocument()
+ expect(screen.getByText('Data Source 1'))!.toBeInTheDocument()
+ expect(screen.getByText('Data Source 2'))!.toBeInTheDocument()
+ expect(screen.getByText('Data Source 3'))!.toBeInTheDocument()
})
it('should render correct number of option cards', () => {
renderWithProviders()
- expect(screen.getByText('Data Source 1')).toBeInTheDocument()
- expect(screen.getByText('Data Source 2')).toBeInTheDocument()
- expect(screen.getByText('Data Source 3')).toBeInTheDocument()
+ expect(screen.getByText('Data Source 1'))!.toBeInTheDocument()
+ expect(screen.getByText('Data Source 2'))!.toBeInTheDocument()
+ expect(screen.getByText('Data Source 3'))!.toBeInTheDocument()
})
it('should render with grid layout', () => {
const { container } = renderWithProviders()
const gridContainer = container.firstChild
- expect(gridContainer).toHaveClass('grid')
- expect(gridContainer).toHaveClass('w-full')
- expect(gridContainer).toHaveClass('grid-cols-4')
- expect(gridContainer).toHaveClass('gap-1')
+ expect(gridContainer)!.toHaveClass('grid')
+ expect(gridContainer)!.toHaveClass('w-full')
+ expect(gridContainer)!.toHaveClass('grid-cols-4')
+ expect(gridContainer)!.toHaveClass('gap-1')
})
it('should render no option cards when options is empty', () => {
@@ -728,16 +731,17 @@ describe('DataSourceOptions', () => {
expect(screen.queryByText('Data Source')).not.toBeInTheDocument()
// Grid container should still exist
- expect(container.firstChild).toHaveClass('grid')
+ // Grid container should still exist
+ expect(container.firstChild)!.toHaveClass('grid')
})
it('should render single option card when only one option exists', () => {
- const singleOption = [createMockDatasourceOption(defaultNodes[0])]
+ const singleOption = [createMockDatasourceOption(defaultNodes[0]!)]
mockUseDatasourceOptions.mockReturnValue(singleOption)
renderWithProviders()
- expect(screen.getByText('Data Source 1')).toBeInTheDocument()
+ expect(screen.getByText('Data Source 1'))!.toBeInTheDocument()
expect(screen.queryByText('Data Source 2')).not.toBeInTheDocument()
})
})
@@ -778,7 +782,7 @@ describe('DataSourceOptions', () => {
// Assert - Check for selected styling on second card
const cards = container.querySelectorAll('.rounded-xl.border')
- expect(cards[1]).toHaveClass('border-components-option-card-option-selected-border')
+ expect(cards[1])!.toHaveClass('border-components-option-card-option-selected-border')
})
it('should show no selection when datasourceNodeId is empty', () => {
@@ -816,7 +820,7 @@ describe('DataSourceOptions', () => {
// Assert initial selection
let cards = container.querySelectorAll('.rounded-xl.border')
- expect(cards[0]).toHaveClass('border-components-option-card-option-selected-border')
+ expect(cards[0])!.toHaveClass('border-components-option-card-option-selected-border')
// Act - Change selection
rerender(
@@ -831,7 +835,7 @@ describe('DataSourceOptions', () => {
// Assert new selection
cards = container.querySelectorAll('.rounded-xl.border')
expect(cards[0]).not.toHaveClass('border-components-option-card-option-selected-border')
- expect(cards[1]).toHaveClass('border-components-option-card-option-selected-border')
+ expect(cards[1])!.toHaveClass('border-components-option-card-option-selected-border')
})
})
@@ -847,7 +851,8 @@ describe('DataSourceOptions', () => {
)
// Assert - Component renders without error
- expect(screen.getByText('Data Source 1')).toBeInTheDocument()
+ // Assert - Component renders without error
+ expect(screen.getByText('Data Source 1'))!.toBeInTheDocument()
})
})
})
@@ -870,7 +875,7 @@ describe('DataSourceOptions', () => {
expect(mockOnSelect).toHaveBeenCalledTimes(1)
expect(mockOnSelect).toHaveBeenCalledWith({
nodeId: 'node-1',
- nodeData: defaultOptions[0].data,
+ nodeData: defaultOptions[0]!.data,
} satisfies Datasource)
})
@@ -948,7 +953,8 @@ describe('DataSourceOptions', () => {
)
// Get initial click handlers
- expect(screen.getByText('Data Source 1')).toBeInTheDocument()
+ // Get initial click handlers
+ expect(screen.getByText('Data Source 1'))!.toBeInTheDocument()
// Trigger clicks to test handlers work
fireEvent.click(screen.getByText('Data Source 1'))
@@ -1003,7 +1009,7 @@ describe('DataSourceOptions', () => {
expect(mockOnSelect2).toHaveBeenCalledTimes(1)
expect(mockOnSelect2).toHaveBeenCalledWith({
nodeId: 'node-3',
- nodeData: defaultOptions[2].data,
+ nodeData: defaultOptions[2]!.data,
})
})
@@ -1022,7 +1028,7 @@ describe('DataSourceOptions', () => {
fireEvent.click(screen.getByText('Data Source 1'))
expect(mockOnSelect).toHaveBeenCalledWith({
nodeId: 'node-1',
- nodeData: defaultOptions[0].data,
+ nodeData: defaultOptions[0]!.data,
})
// Act - Change options
@@ -1045,8 +1051,8 @@ describe('DataSourceOptions', () => {
// Assert - Callback receives new option data
expect(mockOnSelect).toHaveBeenLastCalledWith({
- nodeId: newOptions[0].value,
- nodeData: newOptions[0].data,
+ nodeId: newOptions[0]!.value,
+ nodeData: newOptions[0]!.data,
})
})
})
@@ -1070,7 +1076,7 @@ describe('DataSourceOptions', () => {
expect(mockOnSelect).toHaveBeenCalledTimes(1)
expect(mockOnSelect).toHaveBeenCalledWith({
nodeId: 'node-2',
- nodeData: defaultOptions[1].data,
+ nodeData: defaultOptions[1]!.data,
} satisfies Datasource)
})
@@ -1090,7 +1096,7 @@ describe('DataSourceOptions', () => {
expect(mockOnSelect).toHaveBeenCalledTimes(1)
expect(mockOnSelect).toHaveBeenCalledWith({
nodeId: 'node-1',
- nodeData: defaultOptions[0].data,
+ nodeData: defaultOptions[0]!.data,
})
})
@@ -1112,15 +1118,15 @@ describe('DataSourceOptions', () => {
expect(mockOnSelect).toHaveBeenCalledTimes(3)
expect(mockOnSelect).toHaveBeenNthCalledWith(1, {
nodeId: 'node-1',
- nodeData: defaultOptions[0].data,
+ nodeData: defaultOptions[0]!.data,
})
expect(mockOnSelect).toHaveBeenNthCalledWith(2, {
nodeId: 'node-2',
- nodeData: defaultOptions[1].data,
+ nodeData: defaultOptions[1]!.data,
})
expect(mockOnSelect).toHaveBeenNthCalledWith(3, {
nodeId: 'node-3',
- nodeData: defaultOptions[2].data,
+ nodeData: defaultOptions[2]!.data,
})
})
})
@@ -1164,7 +1170,7 @@ describe('DataSourceOptions', () => {
/>,
)
- expect(container.firstChild).toBeInTheDocument()
+ expect(container.firstChild)!.toBeInTheDocument()
})
it('should not crash when datasourceNodeId is undefined', () => {
@@ -1176,7 +1182,7 @@ describe('DataSourceOptions', () => {
/>,
)
- expect(screen.getByText('Data Source 1')).toBeInTheDocument()
+ expect(screen.getByText('Data Source 1'))!.toBeInTheDocument()
})
})
@@ -1202,7 +1208,7 @@ describe('DataSourceOptions', () => {
renderWithProviders()
- expect(screen.getByText('Minimal Option')).toBeInTheDocument()
+ expect(screen.getByText('Minimal Option'))!.toBeInTheDocument()
})
})
@@ -1219,8 +1225,8 @@ describe('DataSourceOptions', () => {
/>,
)
- expect(screen.getByText('Data Source 1')).toBeInTheDocument()
- expect(screen.getByText('Data Source 50')).toBeInTheDocument()
+ expect(screen.getByText('Data Source 1'))!.toBeInTheDocument()
+ expect(screen.getByText('Data Source 50'))!.toBeInTheDocument()
})
})
@@ -1243,7 +1249,8 @@ describe('DataSourceOptions', () => {
)
// Assert - Special characters should be escaped/rendered safely
- expect(screen.getByText('Data Source ')).toBeInTheDocument()
+ // Assert - Special characters should be escaped/rendered safely
+ expect(screen.getByText('Data Source '))!.toBeInTheDocument()
})
it('should handle unicode characters in option labels', () => {
@@ -1263,7 +1270,7 @@ describe('DataSourceOptions', () => {
/>,
)
- expect(screen.getByText('数据源 📁 Source émoji')).toBeInTheDocument()
+ expect(screen.getByText('数据源 📁 Source émoji'))!.toBeInTheDocument()
})
it('should handle empty string as option value', () => {
@@ -1276,13 +1283,13 @@ describe('DataSourceOptions', () => {
renderWithProviders()
- expect(screen.getByText('Empty Value Option')).toBeInTheDocument()
+ expect(screen.getByText('Empty Value Option'))!.toBeInTheDocument()
})
})
describe('Boundary Conditions', () => {
it('should handle single option selection correctly', () => {
- const singleOption = [createMockDatasourceOption(defaultNodes[0])]
+ const singleOption = [createMockDatasourceOption(defaultNodes[0]!)]
mockUseDatasourceOptions.mockReturnValue(singleOption)
const mockOnSelect = vi.fn()
@@ -1327,7 +1334,7 @@ describe('DataSourceOptions', () => {
const labels = screen.getAllByText('Duplicate Label')
expect(labels).toHaveLength(2)
- fireEvent.click(labels[1])
+ fireEvent.click(labels[1]!)
expect(mockOnSelect).toHaveBeenCalledWith({
nodeId: 'node-b',
nodeData: expect.objectContaining({ plugin_id: 'plugin-b' }),
@@ -1347,6 +1354,37 @@ describe('DataSourceOptions', () => {
unmount()
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
+ // Assert - No errors thrown, component cleanly unmounted
// Assert - No errors thrown, component cleanly unmounted
expect(screen.queryByText('Data Source 1')).not.toBeInTheDocument()
})
@@ -1367,6 +1405,37 @@ describe('DataSourceOptions', () => {
// Unmount during/after interaction
unmount()
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
+ // Assert - Should not throw
// Assert - Should not throw
expect(screen.queryByText('Data Source 1')).not.toBeInTheDocument()
})
@@ -1392,7 +1461,7 @@ describe('DataSourceOptions', () => {
const cards = container.querySelectorAll('.rounded-xl.border')
expect(cards[0]).not.toHaveClass('border-components-option-card-option-selected-border')
- expect(cards[1]).toHaveClass('border-components-option-card-option-selected-border')
+ expect(cards[1])!.toHaveClass('border-components-option-card-option-selected-border')
expect(cards[2]).not.toHaveClass('border-components-option-card-option-selected-border')
})
@@ -1427,7 +1496,7 @@ describe('DataSourceOptions', () => {
/>,
)
- expect(screen.getByText('Data Source 1')).toBeInTheDocument()
+ expect(screen.getByText('Data Source 1'))!.toBeInTheDocument()
})
it.each([
@@ -1449,7 +1518,7 @@ describe('DataSourceOptions', () => {
)
if (count > 0)
- expect(screen.getByText('Data Source 1')).toBeInTheDocument()
+ expect(screen.getByText('Data Source 1'))!.toBeInTheDocument()
else
expect(screen.queryByText('Data Source 1')).not.toBeInTheDocument()
})
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source-options/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source-options/index.tsx
index 8e3a29cfe5..51cf34d273 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source-options/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source-options/index.tsx
@@ -31,7 +31,7 @@ const DataSourceOptions = ({
useEffect(() => {
if (options.length > 0 && !datasourceNodeId)
- handelSelect(options[0].value)
+ handelSelect(options[0]!.value)
}, [])
return (
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/__tests__/header.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/__tests__/header.spec.tsx
index b736935cc8..a6abad358e 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/__tests__/header.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/__tests__/header.spec.tsx
@@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react'
import { describe, expect, it, vi } from 'vitest'
import Header from '../header'
-vi.mock('@/app/components/base/ui/button', () => ({
+vi.mock('@langgenius/dify-ui/button', () => ({
Button: ({ children }: { children: React.ReactNode }) => ,
}))
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/index.spec.tsx
index d595a50fe1..49b0cb0789 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/index.spec.tsx
@@ -97,8 +97,8 @@ describe('CredentialSelector', () => {
render()
- expect(screen.getByTestId('portal-root')).toBeInTheDocument()
- expect(screen.getByTestId('portal-trigger')).toBeInTheDocument()
+ expect(screen.getByTestId('portal-root'))!.toBeInTheDocument()
+ expect(screen.getByTestId('portal-trigger'))!.toBeInTheDocument()
})
it('should render current credential name in trigger', () => {
@@ -106,7 +106,7 @@ describe('CredentialSelector', () => {
render()
- expect(screen.getByText('Credential 1')).toBeInTheDocument()
+ expect(screen.getByText('Credential 1'))!.toBeInTheDocument()
})
it('should render credential icon with correct props', () => {
@@ -116,8 +116,8 @@ describe('CredentialSelector', () => {
// Assert - CredentialIcon renders an img when avatarUrl is provided
const iconImg = container.querySelector('img')
- expect(iconImg).toBeInTheDocument()
- expect(iconImg).toHaveAttribute('src', 'https://example.com/avatar-1.png')
+ expect(iconImg)!.toBeInTheDocument()
+ expect(iconImg)!.toHaveAttribute('src', 'https://example.com/avatar-1.png')
})
it('should render dropdown arrow icon', () => {
@@ -126,7 +126,7 @@ describe('CredentialSelector', () => {
const { container } = render()
const svgIcon = container.querySelector('svg')
- expect(svgIcon).toBeInTheDocument()
+ expect(svgIcon)!.toBeInTheDocument()
})
it('should not render dropdown content initially', () => {
@@ -146,7 +146,8 @@ describe('CredentialSelector', () => {
fireEvent.click(trigger)
// Assert - All credentials should be visible (current credential appears in both trigger and list)
- expect(screen.getByTestId('portal-content')).toBeInTheDocument()
+ // Assert - All credentials should be visible (current credential appears in both trigger and list)
+ expect(screen.getByTestId('portal-content'))!.toBeInTheDocument()
// 3 in dropdown list + 1 in trigger (current) = 4 total
expect(screen.getAllByText(/Credential \d/)).toHaveLength(4)
})
@@ -160,7 +161,7 @@ describe('CredentialSelector', () => {
render()
- expect(screen.getByText('Credential 1')).toBeInTheDocument()
+ expect(screen.getByText('Credential 1'))!.toBeInTheDocument()
})
it('should display second credential when currentCredentialId matches second', () => {
@@ -168,7 +169,7 @@ describe('CredentialSelector', () => {
render()
- expect(screen.getByText('Credential 2')).toBeInTheDocument()
+ expect(screen.getByText('Credential 2'))!.toBeInTheDocument()
})
it('should display third credential when currentCredentialId matches third', () => {
@@ -176,7 +177,7 @@ describe('CredentialSelector', () => {
render()
- expect(screen.getByText('Credential 3')).toBeInTheDocument()
+ expect(screen.getByText('Credential 3'))!.toBeInTheDocument()
})
it.each([
@@ -188,7 +189,7 @@ describe('CredentialSelector', () => {
render()
- expect(screen.getByText(expectedName)).toBeInTheDocument()
+ expect(screen.getByText(expectedName))!.toBeInTheDocument()
})
})
@@ -201,7 +202,7 @@ describe('CredentialSelector', () => {
render()
- expect(screen.getByText('Test Credential')).toBeInTheDocument()
+ expect(screen.getByText('Test Credential'))!.toBeInTheDocument()
})
it('should render multiple credentials in dropdown', () => {
@@ -226,7 +227,7 @@ describe('CredentialSelector', () => {
render()
- expect(screen.getByText('Test & Credential ')).toBeInTheDocument()
+ expect(screen.getByText('Test & Credential '))!.toBeInTheDocument()
})
})
@@ -293,6 +294,37 @@ describe('CredentialSelector', () => {
const props = createDefaultProps()
render()
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
+ // Assert - Initially closed
// Assert - Initially closed
expect(screen.queryByTestId('portal-content')).not.toBeInTheDocument()
@@ -301,7 +333,8 @@ describe('CredentialSelector', () => {
fireEvent.click(trigger)
// Assert - Now open
- expect(screen.getByTestId('portal-content')).toBeInTheDocument()
+ // Assert - Now open
+ expect(screen.getByTestId('portal-content'))!.toBeInTheDocument()
})
it('should call onCredentialChange when clicking a credential item', () => {
@@ -327,7 +360,7 @@ describe('CredentialSelector', () => {
const trigger = screen.getByTestId('portal-trigger')
fireEvent.click(trigger)
- expect(screen.getByTestId('portal-content')).toBeInTheDocument()
+ expect(screen.getByTestId('portal-content'))!.toBeInTheDocument()
const credential2 = screen.getByText('Credential 2')
fireEvent.click(credential2)
@@ -347,7 +380,8 @@ describe('CredentialSelector', () => {
fireEvent.click(trigger)
// Assert - Should not crash
- expect(trigger).toBeInTheDocument()
+ // Assert - Should not crash
+ expect(trigger)!.toBeInTheDocument()
})
it('should allow selecting credentials multiple times', () => {
@@ -504,7 +538,8 @@ describe('CredentialSelector', () => {
render()
// Assert - Should display credential 2
- expect(screen.getByText('Credential 2')).toBeInTheDocument()
+ // Assert - Should display credential 2
+ expect(screen.getByText('Credential 2'))!.toBeInTheDocument()
})
it('should update currentCredential when currentCredentialId changes', () => {
@@ -512,13 +547,15 @@ describe('CredentialSelector', () => {
const { rerender } = render()
// Assert initial
- expect(screen.getByText('Credential 1')).toBeInTheDocument()
+ // Assert initial
+ expect(screen.getByText('Credential 1'))!.toBeInTheDocument()
// Act - Change currentCredentialId
rerender()
// Assert - Should now display credential 3
- expect(screen.getByText('Credential 3')).toBeInTheDocument()
+ // Assert - Should now display credential 3
+ expect(screen.getByText('Credential 3'))!.toBeInTheDocument()
})
it('should update currentCredential when credentials array changes', () => {
@@ -526,7 +563,8 @@ describe('CredentialSelector', () => {
const { rerender } = render()
// Assert initial
- expect(screen.getByText('Credential 1')).toBeInTheDocument()
+ // Assert initial
+ expect(screen.getByText('Credential 1'))!.toBeInTheDocument()
// Act - Change credentials
const newCredentials = [
@@ -535,7 +573,8 @@ describe('CredentialSelector', () => {
rerender()
// Assert - Should display updated name
- expect(screen.getByText('Updated Credential 1')).toBeInTheDocument()
+ // Assert - Should display updated name
+ expect(screen.getByText('Updated Credential 1'))!.toBeInTheDocument()
})
it('should return undefined currentCredential when id not found', () => {
@@ -581,11 +620,12 @@ describe('CredentialSelector', () => {
const { rerender } = render()
// Assert initial
- expect(screen.getByText('Credential 1')).toBeInTheDocument()
+ // Assert initial
+ expect(screen.getByText('Credential 1'))!.toBeInTheDocument()
rerender()
- expect(screen.getByText('Credential 2')).toBeInTheDocument()
+ expect(screen.getByText('Credential 2'))!.toBeInTheDocument()
})
it('should re-render when credentials array reference changes', () => {
@@ -598,7 +638,7 @@ describe('CredentialSelector', () => {
]
rerender()
- expect(screen.getByText('New Name 1')).toBeInTheDocument()
+ expect(screen.getByText('New Name 1'))!.toBeInTheDocument()
})
it('should re-render when onCredentialChange reference changes', () => {
@@ -631,7 +671,8 @@ describe('CredentialSelector', () => {
render()
// Assert - Should render without crashing
- expect(screen.getByTestId('portal-root')).toBeInTheDocument()
+ // Assert - Should render without crashing
+ expect(screen.getByTestId('portal-root'))!.toBeInTheDocument()
})
it('should handle undefined avatar_url in credential', () => {
@@ -648,12 +689,14 @@ describe('CredentialSelector', () => {
const { container } = render()
// Assert - Should render without crashing and show first letter fallback
- expect(screen.getByText('No Avatar Credential')).toBeInTheDocument()
+ // Assert - Should render without crashing and show first letter fallback
+ expect(screen.getByText('No Avatar Credential'))!.toBeInTheDocument()
// When avatar_url is undefined, CredentialIcon shows first letter instead of img
const iconImg = container.querySelector('img')
expect(iconImg).not.toBeInTheDocument()
// First letter 'N' should be displayed
- expect(screen.getByText('N')).toBeInTheDocument()
+ // First letter 'N' should be displayed
+ expect(screen.getByText('N'))!.toBeInTheDocument()
})
it('should handle empty string name in credential', () => {
@@ -669,7 +712,8 @@ describe('CredentialSelector', () => {
render()
// Assert - Should render without crashing
- expect(screen.getByTestId('portal-trigger')).toBeInTheDocument()
+ // Assert - Should render without crashing
+ expect(screen.getByTestId('portal-trigger'))!.toBeInTheDocument()
})
it('should handle very long credential name', () => {
@@ -685,7 +729,7 @@ describe('CredentialSelector', () => {
render()
- expect(screen.getByText(longName)).toBeInTheDocument()
+ expect(screen.getByText(longName))!.toBeInTheDocument()
})
it('should handle special characters in credential name', () => {
@@ -701,7 +745,7 @@ describe('CredentialSelector', () => {
render()
- expect(screen.getByText(specialName)).toBeInTheDocument()
+ expect(screen.getByText(specialName))!.toBeInTheDocument()
})
it('should handle numeric id as string', () => {
@@ -716,7 +760,7 @@ describe('CredentialSelector', () => {
render()
- expect(screen.getByText('Numeric ID Credential')).toBeInTheDocument()
+ expect(screen.getByText('Numeric ID Credential'))!.toBeInTheDocument()
})
it('should handle large number of credentials', () => {
@@ -728,7 +772,7 @@ describe('CredentialSelector', () => {
render()
- expect(screen.getByText('Credential 50')).toBeInTheDocument()
+ expect(screen.getByText('Credential 50'))!.toBeInTheDocument()
})
it('should handle credential selection with duplicate names', () => {
@@ -752,7 +796,7 @@ describe('CredentialSelector', () => {
const sameNameElements = screen.getAllByText('Same Name')
expect(sameNameElements.length).toBe(3)
- fireEvent.click(sameNameElements[2])
+ fireEvent.click(sameNameElements[2]!)
// Assert - Should call with the correct id even with duplicate names
expect(mockOnChange).toHaveBeenCalledWith('cred-2')
@@ -787,7 +831,8 @@ describe('CredentialSelector', () => {
render()
// Assert - Should render without crashing
- expect(screen.getByTestId('portal-trigger')).toBeInTheDocument()
+ // Assert - Should render without crashing
+ expect(screen.getByTestId('portal-trigger'))!.toBeInTheDocument()
})
})
@@ -799,7 +844,7 @@ describe('CredentialSelector', () => {
render()
const trigger = screen.getByTestId('portal-trigger')
- expect(trigger).toHaveClass('overflow-hidden')
+ expect(trigger)!.toHaveClass('overflow-hidden')
})
it('should apply grow class to trigger', () => {
@@ -808,7 +853,7 @@ describe('CredentialSelector', () => {
render()
const trigger = screen.getByTestId('portal-trigger')
- expect(trigger).toHaveClass('grow')
+ expect(trigger)!.toHaveClass('grow')
})
it('should apply z-10 class to dropdown content', () => {
@@ -819,7 +864,7 @@ describe('CredentialSelector', () => {
fireEvent.click(trigger)
const content = screen.getByTestId('portal-content')
- expect(content).toHaveClass('z-10')
+ expect(content)!.toHaveClass('z-10')
})
})
@@ -831,7 +876,8 @@ describe('CredentialSelector', () => {
render()
// Assert - Trigger should display the correct credential
- expect(screen.getByText('Credential 2')).toBeInTheDocument()
+ // Assert - Trigger should display the correct credential
+ expect(screen.getByText('Credential 2'))!.toBeInTheDocument()
})
it('should pass isOpen state to Trigger component', () => {
@@ -840,14 +886,15 @@ describe('CredentialSelector', () => {
// Assert - Initially closed
const portalRoot = screen.getByTestId('portal-root')
- expect(portalRoot).toHaveAttribute('data-open', 'false')
+ expect(portalRoot)!.toHaveAttribute('data-open', 'false')
// Act - Open
const trigger = screen.getByTestId('portal-trigger')
fireEvent.click(trigger)
// Assert - Now open
- expect(portalRoot).toHaveAttribute('data-open', 'true')
+ // Assert - Now open
+ expect(portalRoot)!.toHaveAttribute('data-open', 'true')
})
it('should pass credentials to List component', () => {
@@ -899,7 +946,7 @@ describe('CredentialSelector', () => {
const props = createDefaultProps()
render()
- expect(screen.getByTestId('portal-root')).toBeInTheDocument()
+ expect(screen.getByTestId('portal-root'))!.toBeInTheDocument()
})
it('should configure PortalToFollowElem with offset mainAxis 4', () => {
@@ -907,7 +954,7 @@ describe('CredentialSelector', () => {
const props = createDefaultProps()
render()
- expect(screen.getByTestId('portal-root')).toBeInTheDocument()
+ expect(screen.getByTestId('portal-root'))!.toBeInTheDocument()
})
})
})
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/index.tsx
index 2f14b0f3b8..116b762277 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/index.tsx
@@ -29,7 +29,7 @@ const CredentialSelector = ({
useEffect(() => {
if (!currentCredential && credentials.length)
- onCredentialChange(credentials[0].id)
+ onCredentialChange(credentials[0]!.id)
}, [currentCredential, credentials])
const handleCredentialChange = useCallback((credentialId: string) => {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/item.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/item.tsx
index 4d54a04d1f..b162411f6c 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/item.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/item.tsx
@@ -31,7 +31,7 @@ const Item = ({
name={name}
size={20}
/>
-
+
{name}
{
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/header.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/header.tsx
index 034556d96f..a285946272 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/header.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/header.tsx
@@ -1,10 +1,10 @@
import type { CredentialSelectorProps } from './credential-selector'
+import { Button } from '@langgenius/dify-ui/button'
import { RiBookOpenLine, RiEqualizer2Line } from '@remixicon/react'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import Divider from '@/app/components/base/divider'
import Tooltip from '@/app/components/base/tooltip'
-import { Button } from '@/app/components/base/ui/button'
import CredentialSelector from './credential-selector'
type HeaderProps = {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/hooks/__tests__/use-local-file-upload.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/hooks/__tests__/use-local-file-upload.spec.tsx
index cc531aad8f..dc20688e9e 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/hooks/__tests__/use-local-file-upload.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/hooks/__tests__/use-local-file-upload.spec.tsx
@@ -18,7 +18,7 @@ const { mockNotify, mockToast } = vi.hoisted(() => {
return { mockNotify, mockToast }
})
-vi.mock('@/app/components/base/ui/toast', () => ({
+vi.mock('@langgenius/dify-ui/toast', () => ({
toast: mockToast,
}))
@@ -404,7 +404,7 @@ describe('useLocalFileUpload', () => {
// Should only process first 5 files (batch_count_limit)
const firstCall = mockSetLocalFileList.mock.calls[0]
- expect(firstCall[0].length).toBeLessThanOrEqual(5)
+ expect(firstCall![0].length).toBeLessThanOrEqual(5)
})
})
@@ -591,7 +591,8 @@ describe('useLocalFileUpload', () => {
})
// dragover should not throw
- expect(dropzone).toBeInTheDocument()
+ // dragover should not throw
+ expect(dropzone)!.toBeInTheDocument()
})
it('should set dragging false on dragleave from drag overlay', async () => {
@@ -715,7 +716,7 @@ describe('useLocalFileUpload', () => {
await waitFor(() => {
expect(mockSetLocalFileList).toHaveBeenCalled()
// Should only have 1 file (limited by supportBatchUpload: false)
- const callArgs = mockSetLocalFileList.mock.calls[0][0]
+ const callArgs = mockSetLocalFileList.mock.calls[0]![0]
expect(callArgs.length).toBe(1)
})
})
@@ -873,7 +874,7 @@ describe('useLocalFileUpload', () => {
})
await waitFor(() => {
- const callArgs = mockSetLocalFileList.mock.calls[0][0]
+ const callArgs = mockSetLocalFileList.mock.calls[0]![0]
expect(callArgs[0].progress).toBe(PROGRESS_NOT_STARTED)
})
})
@@ -899,7 +900,7 @@ describe('useLocalFileUpload', () => {
await waitFor(() => {
const calls = mockSetLocalFileList.mock.calls
- const lastCall = calls[calls.length - 1][0]
+ const lastCall = calls[calls.length - 1]![0]
expect(lastCall.some((f: FileItem) => f.progress === PROGRESS_ERROR)).toBe(true)
})
})
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/__tests__/index.spec.tsx
index 6be0e28d31..c193638a6a 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/__tests__/index.spec.tsx
@@ -37,8 +37,8 @@ const { mockToastError } = vi.hoisted(() => ({
mockToastError: vi.fn(),
}))
-vi.mock('@/app/components/base/ui/toast', async (importOriginal) => {
- const actual = await importOriginal()
+vi.mock('@langgenius/dify-ui/toast', async (importOriginal) => {
+ const actual = await importOriginal()
return {
...actual,
toast: {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/index.tsx
index 5051d343cb..22bc8a65e0 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/index.tsx
@@ -1,11 +1,11 @@
import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types'
import type { DataSourceNotionPageMap, DataSourceNotionWorkspace } from '@/models/common'
import type { DataSourceNodeCompletedResponse, DataSourceNodeErrorResponse } from '@/types/pipeline'
+import { toast } from '@langgenius/dify-ui/toast'
import { useCallback, useEffect, useMemo } from 'react'
import { useShallow } from 'zustand/react/shallow'
import Loading from '@/app/components/base/loading'
import SearchInput from '@/app/components/base/notion-page-selector/search-input'
-import { toast } from '@/app/components/base/ui/toast'
import { ACCOUNT_SETTING_TAB } from '@/app/components/header/account-setting/constants'
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
import { useDocLink } from '@/context/i18n'
@@ -115,7 +115,7 @@ const OnlineDocuments = ({
const handleSelectPages = useCallback((newSelectedPagesId: Set) => {
const { setSelectedPagesId, setOnlineDocuments } = dataSourceStore.getState()
- const selectedPages = Array.from(newSelectedPagesId).map(pageId => PagesMapAndSelectedPagesId[pageId])
+ const selectedPages = Array.from(newSelectedPagesId).map(pageId => PagesMapAndSelectedPagesId[pageId]!)
setSelectedPagesId(new Set(Array.from(newSelectedPagesId)))
setOnlineDocuments(selectedPages)
}, [dataSourceStore, PagesMapAndSelectedPagesId])
@@ -160,7 +160,7 @@ const OnlineDocuments = ({
checkedIds={selectedPagesId}
disabledValue={new Set()}
searchValue={searchValue}
- list={documentsData[0].pages || []}
+ list={documentsData[0]!.pages || []}
pagesMap={PagesMapAndSelectedPagesId}
onSelect={handleSelectPages}
canPreview={!isInPipeline}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/page-selector/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/page-selector/__tests__/index.spec.tsx
index a6d5738e2d..04676156e6 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/page-selector/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/page-selector/__tests__/index.spec.tsx
@@ -83,7 +83,7 @@ describe('PageSelector', () => {
render()
- expect(screen.getByTestId('virtual-list')).toBeInTheDocument()
+ expect(screen.getByTestId('virtual-list'))!.toBeInTheDocument()
})
it('should render empty state when list is empty', () => {
@@ -94,7 +94,7 @@ describe('PageSelector', () => {
render()
- expect(screen.getByText('common.dataSource.notion.selector.noSearchResult')).toBeInTheDocument()
+ expect(screen.getByText('common.dataSource.notion.selector.noSearchResult'))!.toBeInTheDocument()
expect(screen.queryByTestId('virtual-list')).not.toBeInTheDocument()
})
@@ -110,8 +110,8 @@ describe('PageSelector', () => {
render()
- expect(screen.getByText('Page 1')).toBeInTheDocument()
- expect(screen.getByText('Page 2')).toBeInTheDocument()
+ expect(screen.getByText('Page 1'))!.toBeInTheDocument()
+ expect(screen.getByText('Page 2'))!.toBeInTheDocument()
})
it('should render checkboxes when isMultipleChoice is true', () => {
@@ -119,7 +119,7 @@ describe('PageSelector', () => {
render()
- expect(getCheckbox()).toBeInTheDocument()
+ expect(getCheckbox())!.toBeInTheDocument()
})
it('should render radio buttons when isMultipleChoice is false', () => {
@@ -127,7 +127,7 @@ describe('PageSelector', () => {
render()
- expect(getRadio()).toBeInTheDocument()
+ expect(getRadio())!.toBeInTheDocument()
})
it('should render preview button when canPreview is true', () => {
@@ -135,7 +135,7 @@ describe('PageSelector', () => {
render()
- expect(screen.getByText('common.dataSource.notion.selector.preview')).toBeInTheDocument()
+ expect(screen.getByText('common.dataSource.notion.selector.preview'))!.toBeInTheDocument()
})
it('should not render preview button when canPreview is false', () => {
@@ -153,7 +153,7 @@ describe('PageSelector', () => {
// Assert - NotionIcon renders svg when page_icon is null
const notionIcon = document.querySelector('.h-5.w-5')
- expect(notionIcon).toBeInTheDocument()
+ expect(notionIcon)!.toBeInTheDocument()
})
it('should render page name', () => {
@@ -164,7 +164,7 @@ describe('PageSelector', () => {
render()
- expect(screen.getByText('My Custom Page')).toBeInTheDocument()
+ expect(screen.getByText('My Custom Page'))!.toBeInTheDocument()
})
})
@@ -181,7 +181,7 @@ describe('PageSelector', () => {
render()
const checkbox = getCheckbox()
- expect(checkbox).toBeInTheDocument()
+ expect(checkbox)!.toBeInTheDocument()
expect(isCheckboxChecked(checkbox)).toBe(true)
})
@@ -196,7 +196,7 @@ describe('PageSelector', () => {
render()
const checkbox = getCheckbox()
- expect(checkbox).toBeInTheDocument()
+ expect(checkbox)!.toBeInTheDocument()
expect(isCheckboxChecked(checkbox)).toBe(false)
})
@@ -206,7 +206,7 @@ describe('PageSelector', () => {
render()
const checkbox = getCheckbox()
- expect(checkbox).toBeInTheDocument()
+ expect(checkbox)!.toBeInTheDocument()
expect(isCheckboxChecked(checkbox)).toBe(false)
})
@@ -225,9 +225,9 @@ describe('PageSelector', () => {
render()
const checkboxes = getAllCheckboxes()
- expect(isCheckboxChecked(checkboxes[0])).toBe(true)
- expect(isCheckboxChecked(checkboxes[1])).toBe(false)
- expect(isCheckboxChecked(checkboxes[2])).toBe(true)
+ expect(isCheckboxChecked(checkboxes[0]!)).toBe(true)
+ expect(isCheckboxChecked(checkboxes[1]!)).toBe(false)
+ expect(isCheckboxChecked(checkboxes[2]!)).toBe(true)
})
})
@@ -243,7 +243,7 @@ describe('PageSelector', () => {
render()
const checkbox = getCheckbox()
- expect(checkbox).toBeInTheDocument()
+ expect(checkbox)!.toBeInTheDocument()
expect(isCheckboxDisabled(checkbox)).toBe(true)
})
@@ -258,7 +258,7 @@ describe('PageSelector', () => {
render()
const checkbox = getCheckbox()
- expect(checkbox).toBeInTheDocument()
+ expect(checkbox)!.toBeInTheDocument()
expect(isCheckboxDisabled(checkbox)).toBe(false)
})
@@ -276,8 +276,8 @@ describe('PageSelector', () => {
render()
const checkboxes = getAllCheckboxes()
- expect(isCheckboxDisabled(checkboxes[0])).toBe(true)
- expect(isCheckboxDisabled(checkboxes[1])).toBe(false)
+ expect(isCheckboxDisabled(checkboxes[0]!)).toBe(true)
+ expect(isCheckboxDisabled(checkboxes[1]!)).toBe(false)
})
})
@@ -301,6 +301,37 @@ describe('PageSelector', () => {
expect(screen.getAllByText('Apple Page').length).toBeGreaterThan(0)
expect(screen.getAllByText('Apple Pie').length).toBeGreaterThan(0)
// Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
+ // Banana Page is filtered out because it doesn't contain "Apple"
expect(screen.queryByText('Banana Page')).not.toBeInTheDocument()
})
@@ -314,7 +345,7 @@ describe('PageSelector', () => {
render()
- expect(screen.getByText('common.dataSource.notion.selector.noSearchResult')).toBeInTheDocument()
+ expect(screen.getByText('common.dataSource.notion.selector.noSearchResult'))!.toBeInTheDocument()
})
it('should show all pages when searchValue is empty', () => {
@@ -330,8 +361,8 @@ describe('PageSelector', () => {
render()
- expect(screen.getByText('Page 1')).toBeInTheDocument()
- expect(screen.getByText('Page 2')).toBeInTheDocument()
+ expect(screen.getByText('Page 1'))!.toBeInTheDocument()
+ expect(screen.getByText('Page 2'))!.toBeInTheDocument()
})
it('should show breadcrumbs when searchValue is present', () => {
@@ -345,7 +376,8 @@ describe('PageSelector', () => {
render()
// Assert - page name should be visible
- expect(screen.getByText('Grandchild 1')).toBeInTheDocument()
+ // Assert - page name should be visible
+ expect(screen.getByText('Grandchild 1'))!.toBeInTheDocument()
})
it('should perform case-sensitive search', () => {
@@ -374,7 +406,7 @@ describe('PageSelector', () => {
render()
- expect(screen.getByText('common.dataSource.notion.selector.preview')).toBeInTheDocument()
+ expect(screen.getByText('common.dataSource.notion.selector.preview'))!.toBeInTheDocument()
})
it('should hide preview button when canPreview is false', () => {
@@ -391,7 +423,7 @@ describe('PageSelector', () => {
render()
- expect(screen.getByText('common.dataSource.notion.selector.preview')).toBeInTheDocument()
+ expect(screen.getByText('common.dataSource.notion.selector.preview'))!.toBeInTheDocument()
})
})
@@ -401,7 +433,7 @@ describe('PageSelector', () => {
render()
- expect(getCheckbox()).toBeInTheDocument()
+ expect(getCheckbox())!.toBeInTheDocument()
expect(getRadio()).not.toBeInTheDocument()
})
@@ -410,7 +442,7 @@ describe('PageSelector', () => {
render()
- expect(getRadio()).toBeInTheDocument()
+ expect(getRadio())!.toBeInTheDocument()
expect(getCheckbox()).not.toBeInTheDocument()
})
@@ -420,7 +452,7 @@ describe('PageSelector', () => {
render()
- expect(getCheckbox()).toBeInTheDocument()
+ expect(getCheckbox())!.toBeInTheDocument()
})
})
@@ -449,7 +481,7 @@ describe('PageSelector', () => {
render()
fireEvent.click(getCheckbox())
- const calledSet = mockOnSelect.mock.calls[0][0] as Set
+ const calledSet = mockOnSelect.mock.calls[0]![0] as Set
expect(calledSet.has('page-1')).toBe(true)
})
})
@@ -498,13 +530,15 @@ describe('PageSelector', () => {
const { rerender } = render()
// Assert - Initial render
- expect(screen.getByText('Page 1')).toBeInTheDocument()
+ // Assert - Initial render
+ expect(screen.getByText('Page 1'))!.toBeInTheDocument()
// Rerender with new credential
rerender()
// Assert - Should still show pages (reset and rebuild)
- expect(screen.getByText('Page 1')).toBeInTheDocument()
+ // Assert - Should still show pages (reset and rebuild)
+ expect(screen.getByText('Page 1'))!.toBeInTheDocument()
})
})
})
@@ -521,7 +555,39 @@ describe('PageSelector', () => {
render()
// Assert - Only root level page should be visible initially
- expect(screen.getByText(rootPage.page_name)).toBeInTheDocument()
+ // Assert - Only root level page should be visible initially
+ expect(screen.getByText(rootPage.page_name))!.toBeInTheDocument()
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
+ // Child pages should not be visible until expanded
// Child pages should not be visible until expanded
expect(screen.queryByText(childPage1.page_name)).not.toBeInTheDocument()
})
@@ -540,9 +606,9 @@ describe('PageSelector', () => {
if (arrowButton)
fireEvent.click(arrowButton)
- expect(screen.getByText(rootPage.page_name)).toBeInTheDocument()
- expect(screen.getByText(childPage1.page_name)).toBeInTheDocument()
- expect(screen.getByText(childPage2.page_name)).toBeInTheDocument()
+ expect(screen.getByText(rootPage.page_name))!.toBeInTheDocument()
+ expect(screen.getByText(childPage1.page_name))!.toBeInTheDocument()
+ expect(screen.getByText(childPage2.page_name))!.toBeInTheDocument()
})
it('should maintain currentPreviewPageId state', () => {
@@ -560,7 +626,7 @@ describe('PageSelector', () => {
render()
const previewButtons = screen.getAllByText('common.dataSource.notion.selector.preview')
- fireEvent.click(previewButtons[0])
+ fireEvent.click(previewButtons[0]!)
expect(mockOnPreview).toHaveBeenCalledWith('page-1')
})
@@ -596,13 +662,14 @@ describe('PageSelector', () => {
})
const { rerender } = render()
- expect(screen.getByText('Page 1')).toBeInTheDocument()
+ expect(screen.getByText('Page 1'))!.toBeInTheDocument()
// Change credential
rerender()
// Assert - Component should still render correctly
- expect(screen.getByText('Page 1')).toBeInTheDocument()
+ // Assert - Component should still render correctly
+ expect(screen.getByText('Page 1'))!.toBeInTheDocument()
})
it('should filter root pages correctly on initialization', () => {
@@ -615,7 +682,8 @@ describe('PageSelector', () => {
render()
// Assert - Only root level pages visible
- expect(screen.getByText(rootPage.page_name)).toBeInTheDocument()
+ // Assert - Only root level pages visible
+ expect(screen.getByText(rootPage.page_name))!.toBeInTheDocument()
expect(screen.queryByText(childPage1.page_name)).not.toBeInTheDocument()
})
@@ -633,7 +701,8 @@ describe('PageSelector', () => {
render()
// Assert - Orphan page should be visible at root level
- expect(screen.getByText('Orphan Page')).toBeInTheDocument()
+ // Assert - Orphan page should be visible at root level
+ expect(screen.getByText('Orphan Page'))!.toBeInTheDocument()
})
})
@@ -654,8 +723,9 @@ describe('PageSelector', () => {
fireEvent.click(expandArrow)
// Assert - Children should be visible
- expect(screen.getByText(childPage1.page_name)).toBeInTheDocument()
- expect(screen.getByText(childPage2.page_name)).toBeInTheDocument()
+ // Assert - Children should be visible
+ expect(screen.getByText(childPage1.page_name))!.toBeInTheDocument()
+ expect(screen.getByText(childPage2.page_name))!.toBeInTheDocument()
})
it('should have stable handleToggle that collapses descendants', () => {
@@ -675,6 +745,37 @@ describe('PageSelector', () => {
fireEvent.click(expandArrow)
}
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
+ // Assert - Children should be hidden again
// Assert - Children should be hidden again
expect(screen.queryByText(childPage1.page_name)).not.toBeInTheDocument()
expect(screen.queryByText(childPage2.page_name)).not.toBeInTheDocument()
@@ -698,7 +799,7 @@ describe('PageSelector', () => {
// Assert - onSelect should be called with the page and its descendants
expect(mockOnSelect).toHaveBeenCalled()
- const selectedSet = mockOnSelect.mock.calls[0][0] as Set
+ const selectedSet = mockOnSelect.mock.calls[0]![0] as Set
expect(selectedSet.has('root-page')).toBe(true)
})
@@ -752,7 +853,7 @@ describe('PageSelector', () => {
// Assert - Tree structure should be built (verified by expand functionality)
const expandArrow = document.querySelector('[class*="hover:bg-components-button-ghost-bg-hover"]')
- expect(expandArrow).toBeInTheDocument() // Root page has children
+ expect(expandArrow)!.toBeInTheDocument() // Root page has children
})
it('should recompute listMapWithChildrenAndDescendants when list changes', () => {
@@ -763,7 +864,7 @@ describe('PageSelector', () => {
})
const { rerender } = render()
- expect(screen.getByText('Page 1')).toBeInTheDocument()
+ expect(screen.getByText('Page 1'))!.toBeInTheDocument()
// Update with new list
const newList = [
@@ -772,7 +873,7 @@ describe('PageSelector', () => {
]
rerender()
- expect(screen.getByText('Page 1')).toBeInTheDocument()
+ expect(screen.getByText('Page 1'))!.toBeInTheDocument()
// Page 2 won't show because dataList state hasn't updated (only resets on credentialId change)
})
@@ -793,7 +894,8 @@ describe('PageSelector', () => {
rerender()
// Assert - Should not throw
- expect(screen.getByText('Page 1')).toBeInTheDocument()
+ // Assert - Should not throw
+ expect(screen.getByText('Page 1'))!.toBeInTheDocument()
})
it('should handle empty list in memoization', () => {
@@ -804,7 +906,7 @@ describe('PageSelector', () => {
render()
- expect(screen.getByText('common.dataSource.notion.selector.noSearchResult')).toBeInTheDocument()
+ expect(screen.getByText('common.dataSource.notion.selector.noSearchResult'))!.toBeInTheDocument()
})
})
@@ -819,6 +921,37 @@ describe('PageSelector', () => {
render()
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
+ // Initially children are hidden
// Initially children are hidden
expect(screen.queryByText(childPage1.page_name)).not.toBeInTheDocument()
@@ -827,7 +960,8 @@ describe('PageSelector', () => {
fireEvent.click(expandArrow)
// Children become visible
- expect(screen.getByText(childPage1.page_name)).toBeInTheDocument()
+ // Children become visible
+ expect(screen.getByText(childPage1.page_name))!.toBeInTheDocument()
})
it('should check/uncheck page when clicking checkbox', () => {
@@ -873,11 +1007,11 @@ describe('PageSelector', () => {
render()
const radios = getAllRadios()
- fireEvent.click(radios[1]) // Click on page-2
+ fireEvent.click(radios[1]!) // Click on page-2
// Assert - Should clear page-1 and select page-2
expect(mockOnSelect).toHaveBeenCalled()
- const selectedSet = mockOnSelect.mock.calls[0][0] as Set
+ const selectedSet = mockOnSelect.mock.calls[0]![0] as Set
expect(selectedSet.has('page-2')).toBe(true)
expect(selectedSet.has('page-1')).toBe(false)
})
@@ -912,7 +1046,7 @@ describe('PageSelector', () => {
// Assert - Only the clicked page should be selected (no descendants)
expect(mockOnSelect).toHaveBeenCalled()
- const selectedSet = mockOnSelect.mock.calls[0][0] as Set
+ const selectedSet = mockOnSelect.mock.calls[0]![0] as Set
expect(selectedSet.size).toBe(1)
expect(selectedSet.has('root-page')).toBe(true)
})
@@ -927,7 +1061,7 @@ describe('PageSelector', () => {
render()
- expect(screen.getByText('common.dataSource.notion.selector.noSearchResult')).toBeInTheDocument()
+ expect(screen.getByText('common.dataSource.notion.selector.noSearchResult'))!.toBeInTheDocument()
})
it('should handle null page_icon', () => {
@@ -941,7 +1075,7 @@ describe('PageSelector', () => {
// Assert - NotionIcon renders svg (RiFileTextLine) when page_icon is null
const notionIcon = document.querySelector('.h-5.w-5')
- expect(notionIcon).toBeInTheDocument()
+ expect(notionIcon)!.toBeInTheDocument()
})
it('should handle page_icon with all properties', () => {
@@ -956,7 +1090,8 @@ describe('PageSelector', () => {
render()
// Assert - NotionIcon renders the emoji
- expect(screen.getByText('📄')).toBeInTheDocument()
+ // Assert - NotionIcon renders the emoji
+ expect(screen.getByText('📄'))!.toBeInTheDocument()
})
it('should handle empty searchValue correctly', () => {
@@ -964,7 +1099,7 @@ describe('PageSelector', () => {
render()
- expect(screen.getByTestId('virtual-list')).toBeInTheDocument()
+ expect(screen.getByTestId('virtual-list'))!.toBeInTheDocument()
})
it('should handle special characters in page name', () => {
@@ -976,7 +1111,7 @@ describe('PageSelector', () => {
render()
- expect(screen.getByText('Test ')).toBeInTheDocument()
+ expect(screen.getByText('Test '))!.toBeInTheDocument()
})
it('should handle unicode characters in page name', () => {
@@ -988,7 +1123,7 @@ describe('PageSelector', () => {
render()
- expect(screen.getByText('测试页面 🔍 привет')).toBeInTheDocument()
+ expect(screen.getByText('测试页面 🔍 привет'))!.toBeInTheDocument()
})
it('should handle very long page names', () => {
@@ -1001,7 +1136,7 @@ describe('PageSelector', () => {
render()
- expect(screen.getByText(longName)).toBeInTheDocument()
+ expect(screen.getByText(longName))!.toBeInTheDocument()
})
it('should handle deeply nested hierarchy', () => {
@@ -1027,7 +1162,8 @@ describe('PageSelector', () => {
render()
// Assert - Only root level visible
- expect(screen.getByText('Level 0')).toBeInTheDocument()
+ // Assert - Only root level visible
+ expect(screen.getByText('Level 0'))!.toBeInTheDocument()
expect(screen.queryByText('Level 1')).not.toBeInTheDocument()
})
@@ -1048,7 +1184,8 @@ describe('PageSelector', () => {
render()
// Assert - Should render the orphan page at root level
- expect(screen.getByText('Orphan Page')).toBeInTheDocument()
+ // Assert - Should render the orphan page at root level
+ expect(screen.getByText('Orphan Page'))!.toBeInTheDocument()
})
it('should handle empty checkedIds Set', () => {
@@ -1057,7 +1194,7 @@ describe('PageSelector', () => {
render()
const checkbox = getCheckbox()
- expect(checkbox).toBeInTheDocument()
+ expect(checkbox)!.toBeInTheDocument()
expect(isCheckboxChecked(checkbox)).toBe(false)
})
@@ -1067,7 +1204,7 @@ describe('PageSelector', () => {
render()
const checkbox = getCheckbox()
- expect(checkbox).toBeInTheDocument()
+ expect(checkbox)!.toBeInTheDocument()
expect(isCheckboxDisabled(checkbox)).toBe(false)
})
@@ -1112,16 +1249,16 @@ describe('PageSelector', () => {
render()
- expect(screen.getByTestId('virtual-list')).toBeInTheDocument()
+ expect(screen.getByTestId('virtual-list'))!.toBeInTheDocument()
if (propVariation.canPreview)
- expect(screen.getByText('common.dataSource.notion.selector.preview')).toBeInTheDocument()
+ expect(screen.getByText('common.dataSource.notion.selector.preview'))!.toBeInTheDocument()
else
expect(screen.queryByText('common.dataSource.notion.selector.preview')).not.toBeInTheDocument()
if (propVariation.isMultipleChoice)
- expect(getCheckbox()).toBeInTheDocument()
+ expect(getCheckbox())!.toBeInTheDocument()
else
- expect(getRadio()).toBeInTheDocument()
+ expect(getRadio())!.toBeInTheDocument()
})
it('should handle all default prop values', () => {
@@ -1140,8 +1277,9 @@ describe('PageSelector', () => {
render()
// Assert - Defaults should be applied
- expect(getCheckbox()).toBeInTheDocument()
- expect(screen.getByText('common.dataSource.notion.selector.preview')).toBeInTheDocument()
+ // Assert - Defaults should be applied
+ expect(getCheckbox())!.toBeInTheDocument()
+ expect(screen.getByText('common.dataSource.notion.selector.preview'))!.toBeInTheDocument()
})
})
@@ -1166,8 +1304,8 @@ describe('PageSelector', () => {
recursivePushInParentDescendants(pagesMap, listTreeMap, childEntry, childEntry)
expect(listTreeMap.parent).toBeDefined()
- expect(listTreeMap.parent.children.has('child')).toBe(true)
- expect(listTreeMap.parent.descendants.has('child')).toBe(true)
+ expect(listTreeMap.parent!.children.has('child')).toBe(true)
+ expect(listTreeMap.parent!.descendants.has('child')).toBe(true)
expect(childEntry.depth).toBe(1)
expect(childEntry.ancestors).toContain('Parent')
})
@@ -1274,8 +1412,8 @@ describe('PageSelector', () => {
expect(l2Entry.depth).toBe(2)
expect(l2Entry.ancestors).toEqual(['Level 0', 'Level 1'])
- expect(listTreeMap.l1.children.has('l2')).toBe(true)
- expect(listTreeMap.l0.descendants.has('l2')).toBe(true)
+ expect(listTreeMap.l1!.children.has('l2')).toBe(true)
+ expect(listTreeMap.l0!.descendants.has('l2')).toBe(true)
})
it('should update existing parent entry', () => {
@@ -1329,7 +1467,7 @@ describe('PageSelector', () => {
// Assert - Item should have preview styling class
const itemContainer = screen.getByText('Test Page').closest('[class*="group"]')
- expect(itemContainer).toHaveClass('bg-state-base-hover')
+ expect(itemContainer)!.toHaveClass('bg-state-base-hover')
})
it('should show arrow for pages with children', () => {
@@ -1343,7 +1481,7 @@ describe('PageSelector', () => {
// Assert - Root page should have expand arrow
const arrowContainer = document.querySelector('[class*="hover:bg-components-button-ghost-bg-hover"]')
- expect(arrowContainer).toBeInTheDocument()
+ expect(arrowContainer)!.toBeInTheDocument()
})
it('should not show arrow for leaf pages', () => {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/page-selector/__tests__/utils.spec.ts b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/page-selector/__tests__/utils.spec.ts
index 2a081ef418..a7175a47de 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/page-selector/__tests__/utils.spec.ts
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/page-selector/__tests__/utils.spec.ts
@@ -28,11 +28,11 @@ describe('recursivePushInParentDescendants', () => {
child1: makePageEntry({ page_id: 'child1', parent_id: 'parent1', page_name: 'Child' }),
}
- recursivePushInParentDescendants(pagesMap, listTreeMap, listTreeMap.child1, listTreeMap.child1)
+ recursivePushInParentDescendants(pagesMap, listTreeMap, listTreeMap.child1!, listTreeMap.child1!)
expect(listTreeMap.parent1).toBeDefined()
- expect(listTreeMap.parent1.children.has('child1')).toBe(true)
- expect(listTreeMap.parent1.descendants.has('child1')).toBe(true)
+ expect(listTreeMap.parent1!.children.has('child1')).toBe(true)
+ expect(listTreeMap.parent1!.descendants.has('child1')).toBe(true)
})
it('should recursively populate ancestors for deeply nested items', () => {
@@ -47,11 +47,11 @@ describe('recursivePushInParentDescendants', () => {
child: makePageEntry({ page_id: 'child', parent_id: 'parent', page_name: 'Child' }),
}
- recursivePushInParentDescendants(pagesMap, listTreeMap, listTreeMap.child, listTreeMap.child)
+ recursivePushInParentDescendants(pagesMap, listTreeMap, listTreeMap.child!, listTreeMap.child!)
- expect(listTreeMap.child.depth).toBe(2)
- expect(listTreeMap.child.ancestors).toContain('Grandparent')
- expect(listTreeMap.child.ancestors).toContain('Parent')
+ expect(listTreeMap.child!.depth).toBe(2)
+ expect(listTreeMap.child!.ancestors).toContain('Grandparent')
+ expect(listTreeMap.child!.ancestors).toContain('Parent')
})
it('should do nothing for root parent', () => {
@@ -63,7 +63,7 @@ describe('recursivePushInParentDescendants', () => {
root_child: makePageEntry({ page_id: 'root_child', parent_id: 'root', page_name: 'Root Child' }),
}
- recursivePushInParentDescendants(pagesMap, listTreeMap, listTreeMap.root_child, listTreeMap.root_child)
+ recursivePushInParentDescendants(pagesMap, listTreeMap, listTreeMap.root_child!, listTreeMap.root_child!)
// No new entries should be added since parent is root
expect(Object.keys(listTreeMap)).toEqual(['root_child'])
@@ -76,7 +76,7 @@ describe('recursivePushInParentDescendants', () => {
// Should not throw
recursivePushInParentDescendants(pagesMap, listTreeMap, current, current)
- expect(listTreeMap.orphan.depth).toBe(0)
+ expect(listTreeMap.orphan!.depth).toBe(0)
})
it('should add to existing parent entry when parent already in tree', () => {
@@ -91,10 +91,10 @@ describe('recursivePushInParentDescendants', () => {
child2: makePageEntry({ page_id: 'child2', parent_id: 'parent', page_name: 'Child2' }),
}
- recursivePushInParentDescendants(pagesMap, listTreeMap, listTreeMap.child2, listTreeMap.child2)
+ recursivePushInParentDescendants(pagesMap, listTreeMap, listTreeMap.child2!, listTreeMap.child2!)
- expect(listTreeMap.parent.children.has('child2')).toBe(true)
- expect(listTreeMap.parent.descendants.has('child2')).toBe(true)
- expect(listTreeMap.parent.children.has('child1')).toBe(true)
+ expect(listTreeMap.parent!.children.has('child2')).toBe(true)
+ expect(listTreeMap.parent!.descendants.has('child2')).toBe(true)
+ expect(listTreeMap.parent!.children.has('child1')).toBe(true)
})
})
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/title.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/title.tsx
index 4f555f3e1f..2d4eb81212 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/title.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/title.tsx
@@ -11,7 +11,7 @@ const Title = ({
const { t } = useTranslation()
return (
-
+
{t('onlineDocument.pageSelectorTitle', { ns: 'datasetPipeline', name })}
)
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/__tests__/index.spec.tsx
index 7c1941afd9..c8fdf49fd1 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/__tests__/index.spec.tsx
@@ -49,8 +49,8 @@ const { mockToastError } = vi.hoisted(() => ({
mockToastError: vi.fn(),
}))
-vi.mock('@/app/components/base/ui/toast', async (importOriginal) => {
- const actual = await importOriginal ()
+vi.mock('@langgenius/dify-ui/toast', async (importOriginal) => {
+ const actual = await importOriginal()
return {
...actual,
toast: {
@@ -259,8 +259,8 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('header')).toBeInTheDocument()
- expect(screen.getByTestId('file-list')).toBeInTheDocument()
+ expect(screen.getByTestId('header'))!.toBeInTheDocument()
+ expect(screen.getByTestId('file-list'))!.toBeInTheDocument()
})
it('should render Header with correct props', () => {
@@ -271,9 +271,9 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('header-doc-title')).toHaveTextContent('Docs')
- expect(screen.getByTestId('header-plugin-name')).toHaveTextContent('My Online Drive')
- expect(screen.getByTestId('header-credential-id')).toHaveTextContent('cred-123')
+ expect(screen.getByTestId('header-doc-title'))!.toHaveTextContent('Docs')
+ expect(screen.getByTestId('header-plugin-name'))!.toHaveTextContent('My Online Drive')
+ expect(screen.getByTestId('header-credential-id'))!.toHaveTextContent('cred-123')
})
it('should render FileList with correct props', () => {
@@ -290,11 +290,11 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('file-list')).toBeInTheDocument()
- expect(screen.getByTestId('file-list-keywords')).toHaveTextContent('search-term')
- expect(screen.getByTestId('file-list-breadcrumbs')).toHaveTextContent('folder1/folder2')
- expect(screen.getByTestId('file-list-bucket')).toHaveTextContent('my-bucket')
- expect(screen.getByTestId('file-list-selected-count')).toHaveTextContent('2')
+ expect(screen.getByTestId('file-list'))!.toBeInTheDocument()
+ expect(screen.getByTestId('file-list-keywords'))!.toHaveTextContent('search-term')
+ expect(screen.getByTestId('file-list-breadcrumbs'))!.toHaveTextContent('folder1/folder2')
+ expect(screen.getByTestId('file-list-bucket'))!.toHaveTextContent('my-bucket')
+ expect(screen.getByTestId('file-list-selected-count'))!.toHaveTextContent('2')
})
it('should pass docLink with correct path to Header', () => {
@@ -371,7 +371,7 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('header-plugin-name')).toHaveTextContent('Custom Online Drive')
+ expect(screen.getByTestId('header-plugin-name'))!.toHaveTextContent('Custom Online Drive')
})
})
@@ -411,7 +411,7 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('file-list-is-in-pipeline')).toHaveTextContent('true')
+ expect(screen.getByTestId('file-list-is-in-pipeline'))!.toHaveTextContent('true')
})
})
@@ -421,7 +421,7 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('file-list-support-batch')).toHaveTextContent('true')
+ expect(screen.getByTestId('file-list-support-batch'))!.toHaveTextContent('true')
})
it('should pass supportBatchUpload false to FileList when supportBatchUpload is false', () => {
@@ -429,7 +429,7 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('file-list-support-batch')).toHaveTextContent('false')
+ expect(screen.getByTestId('file-list-support-batch'))!.toHaveTextContent('false')
})
it.each([
@@ -441,7 +441,7 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('file-list-support-batch')).toHaveTextContent(expected)
+ expect(screen.getByTestId('file-list-support-batch'))!.toHaveTextContent(expected)
})
})
@@ -504,7 +504,7 @@ describe('OnlineDrive', () => {
render()
await waitFor(() => {
- expect(screen.getByTestId('file-list-loading')).toHaveTextContent('true')
+ expect(screen.getByTestId('file-list-loading'))!.toHaveTextContent('true')
})
})
@@ -566,7 +566,8 @@ describe('OnlineDrive', () => {
render()
// Assert - filteredOnlineDriveFileList should have 2 items matching 'test'
- expect(screen.getByTestId('file-list-count')).toHaveTextContent('2')
+ // Assert - filteredOnlineDriveFileList should have 2 items matching 'test'
+ expect(screen.getByTestId('file-list-count'))!.toHaveTextContent('2')
})
it('should return all files when keywords is empty', () => {
@@ -580,7 +581,7 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('file-list-count')).toHaveTextContent('3')
+ expect(screen.getByTestId('file-list-count'))!.toHaveTextContent('3')
})
it('should filter files case-insensitively', () => {
@@ -594,7 +595,7 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('file-list-count')).toHaveTextContent('2')
+ expect(screen.getByTestId('file-list-count'))!.toHaveTextContent('2')
})
})
@@ -932,7 +933,7 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('header-credentials-count')).toHaveTextContent('0')
+ expect(screen.getByTestId('header-credentials-count'))!.toHaveTextContent('0')
})
it('should handle undefined credentials data', () => {
@@ -943,7 +944,7 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('header-credentials-count')).toHaveTextContent('0')
+ expect(screen.getByTestId('header-credentials-count'))!.toHaveTextContent('0')
})
it('should handle undefined pipelineId', async () => {
@@ -969,7 +970,7 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('file-list-count')).toHaveTextContent('0')
+ expect(screen.getByTestId('file-list-count'))!.toHaveTextContent('0')
})
it('should handle empty breadcrumbs', () => {
@@ -978,7 +979,7 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('file-list-breadcrumbs')).toHaveTextContent('')
+ expect(screen.getByTestId('file-list-breadcrumbs'))!.toHaveTextContent('')
})
it('should handle empty bucket', () => {
@@ -987,7 +988,7 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('file-list-bucket')).toHaveTextContent('')
+ expect(screen.getByTestId('file-list-bucket'))!.toHaveTextContent('')
})
it('should handle special characters in keywords', () => {
@@ -1001,7 +1002,8 @@ describe('OnlineDrive', () => {
render()
// Assert - Should find file with special characters
- expect(screen.getByTestId('file-list-count')).toHaveTextContent('1')
+ // Assert - Should find file with special characters
+ expect(screen.getByTestId('file-list-count'))!.toHaveTextContent('1')
})
it('should handle very long file names', () => {
@@ -1013,7 +1015,7 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('file-list-count')).toHaveTextContent('1')
+ expect(screen.getByTestId('file-list-count'))!.toHaveTextContent('1')
})
it('should handle bucket list initiation response', async () => {
@@ -1051,10 +1053,10 @@ describe('OnlineDrive', () => {
render()
- expect(screen.getByTestId('header')).toBeInTheDocument()
- expect(screen.getByTestId('file-list')).toBeInTheDocument()
- expect(screen.getByTestId('file-list-is-in-pipeline')).toHaveTextContent(String(propVariation.isInPipeline))
- expect(screen.getByTestId('file-list-support-batch')).toHaveTextContent(String(propVariation.supportBatchUpload))
+ expect(screen.getByTestId('header'))!.toBeInTheDocument()
+ expect(screen.getByTestId('file-list'))!.toBeInTheDocument()
+ expect(screen.getByTestId('file-list-is-in-pipeline'))!.toHaveTextContent(String(propVariation.isInPipeline))
+ expect(screen.getByTestId('file-list-support-batch'))!.toHaveTextContent(String(propVariation.supportBatchUpload))
})
it.each([
@@ -1117,7 +1119,7 @@ describe('Header', () => {
render()
- expect(screen.getByText('Documentation')).toBeInTheDocument()
+ expect(screen.getByText('Documentation'))!.toBeInTheDocument()
})
it('should render doc link with correct href', () => {
@@ -1129,9 +1131,9 @@ describe('Header', () => {
render()
const link = screen.getByRole('link')
- expect(link).toHaveAttribute('href', 'https://custom-docs.com/path')
- expect(link).toHaveAttribute('target', '_blank')
- expect(link).toHaveAttribute('rel', 'noopener noreferrer')
+ expect(link)!.toHaveAttribute('href', 'https://custom-docs.com/path')
+ expect(link)!.toHaveAttribute('target', '_blank')
+ expect(link)!.toHaveAttribute('rel', 'noopener noreferrer')
})
it('should render doc title text', () => {
@@ -1139,7 +1141,7 @@ describe('Header', () => {
render()
- expect(screen.getByText('My Documentation Title')).toBeInTheDocument()
+ expect(screen.getByText('My Documentation Title'))!.toBeInTheDocument()
})
it('should render configuration button', () => {
@@ -1147,7 +1149,7 @@ describe('Header', () => {
render()
- expect(screen.getByRole('button')).toBeInTheDocument()
+ expect(screen.getByRole('button'))!.toBeInTheDocument()
})
})
@@ -1164,7 +1166,7 @@ describe('Header', () => {
render()
if (docTitle)
- expect(screen.getByText(docTitle)).toBeInTheDocument()
+ expect(screen.getByText(docTitle))!.toBeInTheDocument()
})
})
@@ -1178,7 +1180,7 @@ describe('Header', () => {
render()
- expect(screen.getByRole('link')).toHaveAttribute('href', docLink)
+ expect(screen.getByRole('link'))!.toHaveAttribute('href', docLink)
})
})
@@ -1209,7 +1211,7 @@ describe('Header', () => {
render()
const titleSpan = screen.getByTitle('Accessible Title')
- expect(titleSpan).toBeInTheDocument()
+ expect(titleSpan)!.toBeInTheDocument()
})
})
})
@@ -1437,10 +1439,10 @@ describe('utils', () => {
const result = convertOnlineDriveData(data, [], 'my-bucket')
expect(result.fileList).toHaveLength(4)
- expect(result.fileList[0].type).toBe(OnlineDriveFileType.folder)
- expect(result.fileList[1].type).toBe(OnlineDriveFileType.file)
- expect(result.fileList[2].type).toBe(OnlineDriveFileType.folder)
- expect(result.fileList[3].type).toBe(OnlineDriveFileType.file)
+ expect(result.fileList[0]!.type).toBe(OnlineDriveFileType.folder)
+ expect(result.fileList[1]!.type).toBe(OnlineDriveFileType.file)
+ expect(result.fileList[2]!.type).toBe(OnlineDriveFileType.folder)
+ expect(result.fileList[3]!.type).toBe(OnlineDriveFileType.file)
})
})
@@ -1539,7 +1541,7 @@ describe('utils', () => {
const result = convertOnlineDriveData(data, [], 'my-bucket')
- expect(result.fileList[0].size).toBe(0)
+ expect(result.fileList[0]!.size).toBe(0)
})
it('should handle files with very large size', () => {
@@ -1555,7 +1557,7 @@ describe('utils', () => {
const result = convertOnlineDriveData(data, [], 'my-bucket')
- expect(result.fileList[0].size).toBe(largeSize)
+ expect(result.fileList[0]!.size).toBe(largeSize)
})
it('should handle files with special characters in name', () => {
@@ -1574,9 +1576,9 @@ describe('utils', () => {
const result = convertOnlineDriveData(data, [], 'my-bucket')
- expect(result.fileList[0].name).toBe('file[1] (copy).txt')
- expect(result.fileList[1].name).toBe('doc-with-dash_and_underscore.pdf')
- expect(result.fileList[2].name).toBe('file with spaces.txt')
+ expect(result.fileList[0]!.name).toBe('file[1] (copy).txt')
+ expect(result.fileList[1]!.name).toBe('doc-with-dash_and_underscore.pdf')
+ expect(result.fileList[2]!.name).toBe('file with spaces.txt')
})
it('should handle complex next_page_parameters', () => {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/__tests__/utils.spec.ts b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/__tests__/utils.spec.ts
index 7c5761be8a..9ac2ef9f89 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/__tests__/utils.spec.ts
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/__tests__/utils.spec.ts
@@ -93,10 +93,10 @@ describe('online-drive utils', () => {
const result = convertOnlineDriveData(data, [], 'bucket-1')
expect(result.fileList).toHaveLength(2)
- expect(result.fileList[0].type).toBe(OnlineDriveFileType.file)
- expect(result.fileList[0].size).toBe(100)
- expect(result.fileList[1].type).toBe(OnlineDriveFileType.folder)
- expect(result.fileList[1].size).toBeUndefined()
+ expect(result.fileList[0]!.type).toBe(OnlineDriveFileType.file)
+ expect(result.fileList[0]!.size).toBe(100)
+ expect(result.fileList[1]!.type).toBe(OnlineDriveFileType.folder)
+ expect(result.fileList[1]!.size).toBeUndefined()
expect(result.isTruncated).toBe(true)
expect(result.nextPageParameters).toEqual({ token: 'next' })
expect(result.hasBucket).toBe(true)
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/connect/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/connect/index.tsx
index 5b1b0a6b1a..6a7190161d 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/connect/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/connect/index.tsx
@@ -1,7 +1,7 @@
import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types'
+import { Button } from '@langgenius/dify-ui/button'
import { useTranslation } from 'react-i18next'
import { Icon3Dots } from '@/app/components/base/icons/src/vender/line/others'
-import { Button } from '@/app/components/base/ui/button'
import BlockIcon from '@/app/components/workflow/block-icon'
import { useToolIcon } from '@/app/components/workflow/hooks'
import { BlockEnum } from '@/app/components/workflow/types'
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/__tests__/index.spec.tsx
index 07308361ad..dcb1922fe9 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/__tests__/index.spec.tsx
@@ -60,7 +60,8 @@ describe('Header', () => {
render()
// Assert - search input should be visible
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ // Assert - search input should be visible
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it('should render with correct container styles', () => {
@@ -70,12 +71,12 @@ describe('Header', () => {
// Assert - container should have correct class names
const wrapper = container.firstChild as HTMLElement
- expect(wrapper).toHaveClass('flex')
- expect(wrapper).toHaveClass('items-center')
- expect(wrapper).toHaveClass('gap-x-2')
- expect(wrapper).toHaveClass('bg-components-panel-bg')
- expect(wrapper).toHaveClass('p-1')
- expect(wrapper).toHaveClass('pl-3')
+ expect(wrapper)!.toHaveClass('flex')
+ expect(wrapper)!.toHaveClass('items-center')
+ expect(wrapper)!.toHaveClass('gap-x-2')
+ expect(wrapper)!.toHaveClass('bg-components-panel-bg')
+ expect(wrapper)!.toHaveClass('p-1')
+ expect(wrapper)!.toHaveClass('pl-3')
})
it('should render Input component with correct props', () => {
@@ -84,8 +85,8 @@ describe('Header', () => {
render()
const input = screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')
- expect(input).toBeInTheDocument()
- expect(input).toHaveValue('test-value')
+ expect(input)!.toBeInTheDocument()
+ expect(input)!.toHaveValue('test-value')
})
it('should render Input with search icon', () => {
@@ -95,7 +96,7 @@ describe('Header', () => {
// Assert - Input should have search icon class
const searchIcon = container.querySelector('.i-ri-search-line.h-4.w-4')
- expect(searchIcon).toBeInTheDocument()
+ expect(searchIcon)!.toBeInTheDocument()
})
it('should render Input with correct wrapper width', () => {
@@ -105,7 +106,7 @@ describe('Header', () => {
// Assert - Input wrapper should have w-[200px] class
const inputWrapper = container.querySelector('.w-\\[200px\\]')
- expect(inputWrapper).toBeInTheDocument()
+ expect(inputWrapper)!.toBeInTheDocument()
})
})
@@ -117,7 +118,7 @@ describe('Header', () => {
render()
const input = screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')
- expect(input).toHaveValue('')
+ expect(input)!.toHaveValue('')
})
it('should display input value correctly', () => {
@@ -126,7 +127,7 @@ describe('Header', () => {
render()
const input = screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')
- expect(input).toHaveValue('search-query')
+ expect(input)!.toHaveValue('search-query')
})
it('should handle special characters in inputValue', () => {
@@ -136,7 +137,7 @@ describe('Header', () => {
render()
const input = screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')
- expect(input).toHaveValue(specialChars)
+ expect(input)!.toHaveValue(specialChars)
})
it('should handle unicode characters in inputValue', () => {
@@ -146,7 +147,7 @@ describe('Header', () => {
render()
const input = screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')
- expect(input).toHaveValue(unicodeValue)
+ expect(input)!.toHaveValue(unicodeValue)
})
})
@@ -157,7 +158,8 @@ describe('Header', () => {
render()
// Assert - Component should render without errors
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ // Assert - Component should render without errors
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it('should render with single breadcrumb', () => {
@@ -165,7 +167,7 @@ describe('Header', () => {
render()
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it('should render with multiple breadcrumbs', () => {
@@ -173,7 +175,7 @@ describe('Header', () => {
render()
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
})
@@ -184,7 +186,8 @@ describe('Header', () => {
render()
// Assert - keywords are passed through, component renders
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ // Assert - keywords are passed through, component renders
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
})
@@ -194,7 +197,7 @@ describe('Header', () => {
render()
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it('should render with bucket value', () => {
@@ -202,7 +205,7 @@ describe('Header', () => {
render()
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
})
@@ -212,7 +215,7 @@ describe('Header', () => {
render()
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it('should handle positive search results', () => {
@@ -221,7 +224,8 @@ describe('Header', () => {
render()
// Assert - Breadcrumbs will show search results text when keywords exist and results > 0
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ // Assert - Breadcrumbs will show search results text when keywords exist and results > 0
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it('should handle large search results count', () => {
@@ -229,7 +233,7 @@ describe('Header', () => {
render()
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
})
@@ -239,7 +243,7 @@ describe('Header', () => {
render()
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it('should render correctly when isInPipeline is true', () => {
@@ -247,7 +251,7 @@ describe('Header', () => {
render()
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
})
})
@@ -265,7 +269,7 @@ describe('Header', () => {
expect(mockHandleInputChange).toHaveBeenCalledTimes(1)
// Verify that onChange event was triggered (React's synthetic event structure)
- expect(mockHandleInputChange.mock.calls[0][0]).toHaveProperty('type', 'change')
+ expect(mockHandleInputChange.mock.calls[0]![0]).toHaveProperty('type', 'change')
})
it('should call handleInputChange on each keystroke', () => {
@@ -290,7 +294,7 @@ describe('Header', () => {
fireEvent.change(input, { target: { value: '' } })
expect(mockHandleInputChange).toHaveBeenCalledTimes(1)
- expect(mockHandleInputChange.mock.calls[0][0]).toHaveProperty('type', 'change')
+ expect(mockHandleInputChange.mock.calls[0]![0]).toHaveProperty('type', 'change')
})
it('should handle whitespace-only input', () => {
@@ -302,7 +306,7 @@ describe('Header', () => {
fireEvent.change(input, { target: { value: ' ' } })
expect(mockHandleInputChange).toHaveBeenCalledTimes(1)
- expect(mockHandleInputChange.mock.calls[0][0]).toHaveProperty('type', 'change')
+ expect(mockHandleInputChange.mock.calls[0]![0]).toHaveProperty('type', 'change')
})
})
@@ -317,7 +321,7 @@ describe('Header', () => {
// Act - Find and click the clear icon container
const clearButton = screen.getByTestId('input-clear')
- expect(clearButton).toBeInTheDocument()
+ expect(clearButton)!.toBeInTheDocument()
fireEvent.click(clearButton!)
expect(mockHandleResetKeywords).toHaveBeenCalledTimes(1)
@@ -338,7 +342,7 @@ describe('Header', () => {
// Act & Assert - Clear icon should be visible
const clearIcon = screen.getByTestId('input-clear')
- expect(clearIcon).toBeInTheDocument()
+ expect(clearIcon)!.toBeInTheDocument()
})
})
})
@@ -365,21 +369,23 @@ describe('Header', () => {
rerender()
// Assert - Component renders without errors
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ // Assert - Component renders without errors
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it('should re-render when inputValue changes', () => {
const props = createDefaultProps({ inputValue: 'initial' })
const { rerender } = render()
const input = screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')
- expect(input).toHaveValue('initial')
+ expect(input)!.toHaveValue('initial')
// Act - Rerender with different inputValue
const newProps = createDefaultProps({ inputValue: 'changed' })
rerender()
// Assert - Input value should be updated
- expect(input).toHaveValue('changed')
+ // Assert - Input value should be updated
+ expect(input)!.toHaveValue('changed')
})
it('should re-render when breadcrumbs change', () => {
@@ -391,7 +397,8 @@ describe('Header', () => {
rerender()
// Assert - Component renders without errors
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ // Assert - Component renders without errors
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it('should re-render when keywords change', () => {
@@ -403,7 +410,8 @@ describe('Header', () => {
rerender()
// Assert - Component renders without errors
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ // Assert - Component renders without errors
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
})
@@ -415,7 +423,7 @@ describe('Header', () => {
render()
const input = screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')
- expect(input).toHaveValue(longValue)
+ expect(input)!.toHaveValue(longValue)
})
it('should handle very long breadcrumb paths', () => {
@@ -424,7 +432,7 @@ describe('Header', () => {
render()
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it('should handle breadcrumbs with special characters', () => {
@@ -433,7 +441,7 @@ describe('Header', () => {
render()
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it('should handle breadcrumbs with unicode names', () => {
@@ -442,7 +450,7 @@ describe('Header', () => {
render()
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it('should handle bucket with special characters', () => {
@@ -450,7 +458,7 @@ describe('Header', () => {
render()
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it('should pass the event object to handleInputChange callback', () => {
@@ -463,7 +471,7 @@ describe('Header', () => {
// Assert - Verify the event object is passed correctly
expect(mockHandleInputChange).toHaveBeenCalledTimes(1)
- const eventArg = mockHandleInputChange.mock.calls[0][0]
+ const eventArg = mockHandleInputChange.mock.calls[0]![0]
expect(eventArg).toHaveProperty('type', 'change')
expect(eventArg).toHaveProperty('target')
})
@@ -480,7 +488,7 @@ describe('Header', () => {
render()
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it.each([
@@ -493,7 +501,7 @@ describe('Header', () => {
render()
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it.each([
@@ -507,7 +515,7 @@ describe('Header', () => {
render()
const input = screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')
- expect(input).toHaveValue(inputValue)
+ expect(input)!.toHaveValue(inputValue)
})
})
@@ -525,7 +533,8 @@ describe('Header', () => {
render()
// Assert - Component should render successfully, meaning props are passed correctly
- expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')).toBeInTheDocument()
+ // Assert - Component should render successfully, meaning props are passed correctly
+ expect(screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder'))!.toBeInTheDocument()
})
it('should pass correct props to Input component', () => {
@@ -540,7 +549,7 @@ describe('Header', () => {
render()
const input = screen.getByPlaceholderText('datasetPipeline.onlineDrive.breadcrumbs.searchPlaceholder')
- expect(input).toHaveValue('test-input')
+ expect(input)!.toHaveValue('test-input')
// Test onChange handler
fireEvent.change(input, { target: { value: 'new-value' } })
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/__tests__/bucket.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/__tests__/bucket.spec.tsx
index c407be51ac..83e17e6e04 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/__tests__/bucket.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/__tests__/bucket.spec.tsx
@@ -22,18 +22,18 @@ describe('Bucket', () => {
it('should render bucket name', () => {
render()
- expect(screen.getByText('my-bucket')).toBeInTheDocument()
+ expect(screen.getByText('my-bucket'))!.toBeInTheDocument()
})
it('should render bucket icon', () => {
render()
- expect(screen.getByTestId('buckets-gray')).toBeInTheDocument()
+ expect(screen.getByTestId('buckets-gray'))!.toBeInTheDocument()
})
it('should call handleBackToBucketList on icon button click', () => {
render()
const buttons = screen.getAllByRole('button')
- fireEvent.click(buttons[0])
+ fireEvent.click(buttons[0]!)
expect(defaultProps.handleBackToBucketList).toHaveBeenCalledOnce()
})
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/__tests__/index.spec.tsx
index a6aaf3a50b..906a9e01e0 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/__tests__/index.spec.tsx
@@ -1,4 +1,4 @@
-import { fireEvent, render, screen, waitFor } from '@testing-library/react'
+import { fireEvent, render, screen } from '@testing-library/react'
import * as React from 'react'
import Breadcrumbs from '../index'
@@ -44,6 +44,16 @@ const resetMockStoreState = () => {
mockStoreState.setBucket = vi.fn()
}
+const getDropdownTrigger = () => {
+ return document.querySelector('[aria-haspopup="menu"]') as HTMLElement | null
+}
+
+const openCollapsedBreadcrumbDropdown = () => {
+ const dropdownTrigger = getDropdownTrigger()
+ expect(dropdownTrigger).toBeInTheDocument()
+ fireEvent.click(dropdownTrigger as HTMLElement)
+}
+
describe('Breadcrumbs', () => {
beforeEach(() => {
vi.clearAllMocks()
@@ -58,7 +68,7 @@ describe('Breadcrumbs', () => {
// Assert - Container should be in the document
const container = document.querySelector('.flex.grow')
- expect(container).toBeInTheDocument()
+ expect(container)!.toBeInTheDocument()
})
it('should render with correct container styles', () => {
@@ -67,10 +77,10 @@ describe('Breadcrumbs', () => {
const { container } = render()
const wrapper = container.firstChild as HTMLElement
- expect(wrapper).toHaveClass('flex')
- expect(wrapper).toHaveClass('grow')
- expect(wrapper).toHaveClass('items-center')
- expect(wrapper).toHaveClass('overflow-hidden')
+ expect(wrapper)!.toHaveClass('flex')
+ expect(wrapper)!.toHaveClass('grow')
+ expect(wrapper)!.toHaveClass('items-center')
+ expect(wrapper)!.toHaveClass('overflow-hidden')
})
describe('Search Results Display', () => {
@@ -84,7 +94,8 @@ describe('Breadcrumbs', () => {
render()
// Assert - Search result text should be displayed
- expect(screen.getByText(/datasetPipeline\.onlineDrive\.breadcrumbs\.searchResult/)).toBeInTheDocument()
+ // Assert - Search result text should be displayed
+ expect(screen.getByText(/datasetPipeline\.onlineDrive\.breadcrumbs\.searchResult/))!.toBeInTheDocument()
})
it('should not show search results when keywords is empty', () => {
@@ -121,7 +132,8 @@ describe('Breadcrumbs', () => {
render()
// Assert - Should use bucket name in search result
- expect(screen.getByText(/searchResult.*my-bucket/i)).toBeInTheDocument()
+ // Assert - Should use bucket name in search result
+ expect(screen.getByText(/searchResult.*my-bucket/i))!.toBeInTheDocument()
})
it('should use last breadcrumb as folderName when breadcrumbs exist', () => {
@@ -135,7 +147,8 @@ describe('Breadcrumbs', () => {
render()
// Assert - Should use last breadcrumb in search result
- expect(screen.getByText(/searchResult.*folder2/i)).toBeInTheDocument()
+ // Assert - Should use last breadcrumb in search result
+ expect(screen.getByText(/searchResult.*folder2/i))!.toBeInTheDocument()
})
})
@@ -150,7 +163,7 @@ describe('Breadcrumbs', () => {
render()
- expect(screen.getByText('datasetPipeline.onlineDrive.breadcrumbs.allBuckets')).toBeInTheDocument()
+ expect(screen.getByText('datasetPipeline.onlineDrive.breadcrumbs.allBuckets'))!.toBeInTheDocument()
})
it('should not show all buckets title when breadcrumbs exist', () => {
@@ -174,6 +187,37 @@ describe('Breadcrumbs', () => {
render()
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
+ // Assert - Should show bucket name instead
// Assert - Should show bucket name instead
expect(screen.queryByText('datasetPipeline.onlineDrive.breadcrumbs.allBuckets')).not.toBeInTheDocument()
})
@@ -190,7 +234,8 @@ describe('Breadcrumbs', () => {
render()
// Assert - Bucket name should be displayed
- expect(screen.getByText('test-bucket')).toBeInTheDocument()
+ // Assert - Bucket name should be displayed
+ expect(screen.getByText('test-bucket'))!.toBeInTheDocument()
})
it('should not render Bucket when hasBucket is false', () => {
@@ -202,6 +247,37 @@ describe('Breadcrumbs', () => {
render()
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
+ // Assert - Bucket should not be displayed, Drive should be shown instead
// Assert - Bucket should not be displayed, Drive should be shown instead
expect(screen.queryByText('test-bucket')).not.toBeInTheDocument()
})
@@ -217,7 +293,8 @@ describe('Breadcrumbs', () => {
render()
// Assert - "All Files" should be displayed
- expect(screen.getByText('datasetPipeline.onlineDrive.breadcrumbs.allFiles')).toBeInTheDocument()
+ // Assert - "All Files" should be displayed
+ expect(screen.getByText('datasetPipeline.onlineDrive.breadcrumbs.allFiles'))!.toBeInTheDocument()
})
it('should not render Drive component when hasBucket is true', () => {
@@ -243,8 +320,8 @@ describe('Breadcrumbs', () => {
render()
- expect(screen.getByText('folder1')).toBeInTheDocument()
- expect(screen.getByText('folder2')).toBeInTheDocument()
+ expect(screen.getByText('folder1'))!.toBeInTheDocument()
+ expect(screen.getByText('folder2'))!.toBeInTheDocument()
})
it('should render last breadcrumb as active', () => {
@@ -257,8 +334,8 @@ describe('Breadcrumbs', () => {
// Assert - Last breadcrumb should have active styles
const lastBreadcrumb = screen.getByText('folder2')
- expect(lastBreadcrumb).toHaveClass('system-sm-medium')
- expect(lastBreadcrumb).toHaveClass('text-text-secondary')
+ expect(lastBreadcrumb)!.toHaveClass('system-sm-medium')
+ expect(lastBreadcrumb)!.toHaveClass('text-text-secondary')
})
it('should render non-last breadcrumbs with tertiary styles', () => {
@@ -271,8 +348,8 @@ describe('Breadcrumbs', () => {
// Assert - First breadcrumb should have tertiary styles
const firstBreadcrumb = screen.getByText('folder1')
- expect(firstBreadcrumb).toHaveClass('system-sm-regular')
- expect(firstBreadcrumb).toHaveClass('text-text-tertiary')
+ expect(firstBreadcrumb)!.toHaveClass('system-sm-regular')
+ expect(firstBreadcrumb)!.toHaveClass('text-text-tertiary')
})
})
@@ -287,7 +364,8 @@ describe('Breadcrumbs', () => {
render()
// Assert - Dropdown trigger (more button) should be present
- expect(screen.getByRole('button', { name: '' })).toBeInTheDocument()
+ // Assert - Dropdown trigger (more button) should be present
+ expect(screen.getByRole('button', { name: '' }))!.toBeInTheDocument()
})
it('should not show dropdown when breadcrumbs do not exceed displayBreadcrumbNum', () => {
@@ -301,8 +379,10 @@ describe('Breadcrumbs', () => {
// Assert - Should not have dropdown, just regular breadcrumbs
// All breadcrumbs should be directly visible
- expect(screen.getByText('folder1')).toBeInTheDocument()
- expect(screen.getByText('folder2')).toBeInTheDocument()
+ // Assert - Should not have dropdown, just regular breadcrumbs
+ // All breadcrumbs should be directly visible
+ expect(screen.getByText('folder1'))!.toBeInTheDocument()
+ expect(screen.getByText('folder2'))!.toBeInTheDocument()
// Count buttons - should be 3 (allFiles + folder1 + folder2)
const buttons = container.querySelectorAll('button')
expect(buttons.length).toBe(3)
@@ -318,9 +398,41 @@ describe('Breadcrumbs', () => {
render()
// Assert - First breadcrumb and last breadcrumb should be visible
- expect(screen.getByText('folder1')).toBeInTheDocument()
- expect(screen.getByText('folder2')).toBeInTheDocument()
- expect(screen.getByText('folder5')).toBeInTheDocument()
+ // Assert - First breadcrumb and last breadcrumb should be visible
+ expect(screen.getByText('folder1'))!.toBeInTheDocument()
+ expect(screen.getByText('folder2'))!.toBeInTheDocument()
+ expect(screen.getByText('folder5'))!.toBeInTheDocument()
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
+ // Middle breadcrumbs should be in dropdown
// Middle breadcrumbs should be in dropdown
expect(screen.queryByText('folder3')).not.toBeInTheDocument()
expect(screen.queryByText('folder4')).not.toBeInTheDocument()
@@ -335,15 +447,11 @@ describe('Breadcrumbs', () => {
render()
// Act - Click on dropdown trigger (the ... button)
- const dropdownTrigger = screen.getAllByRole('button').find(btn => btn.querySelector('svg'))
- if (dropdownTrigger)
- fireEvent.click(dropdownTrigger)
+ openCollapsedBreadcrumbDropdown()
// Assert - Collapsed breadcrumbs should be visible
- await waitFor(() => {
- expect(screen.getByText('folder3')).toBeInTheDocument()
- expect(screen.getByText('folder4')).toBeInTheDocument()
- })
+ expect(await screen.findByText('folder3')).toBeInTheDocument()
+ expect(await screen.findByText('folder4')).toBeInTheDocument()
})
})
})
@@ -357,7 +465,8 @@ describe('Breadcrumbs', () => {
render()
// Assert - Only Drive should be visible
- expect(screen.getByText('datasetPipeline.onlineDrive.breadcrumbs.allFiles')).toBeInTheDocument()
+ // Assert - Only Drive should be visible
+ expect(screen.getByText('datasetPipeline.onlineDrive.breadcrumbs.allFiles'))!.toBeInTheDocument()
})
it('should handle single breadcrumb', () => {
@@ -366,7 +475,7 @@ describe('Breadcrumbs', () => {
render()
- expect(screen.getByText('single-folder')).toBeInTheDocument()
+ expect(screen.getByText('single-folder'))!.toBeInTheDocument()
})
it('should handle breadcrumbs with special characters', () => {
@@ -377,8 +486,8 @@ describe('Breadcrumbs', () => {
render()
- expect(screen.getByText('folder [1]')).toBeInTheDocument()
- expect(screen.getByText('folder (copy)')).toBeInTheDocument()
+ expect(screen.getByText('folder [1]'))!.toBeInTheDocument()
+ expect(screen.getByText('folder (copy)'))!.toBeInTheDocument()
})
it('should handle breadcrumbs with unicode characters', () => {
@@ -389,8 +498,8 @@ describe('Breadcrumbs', () => {
render()
- expect(screen.getByText('文件夹')).toBeInTheDocument()
- expect(screen.getByText('フォルダ')).toBeInTheDocument()
+ expect(screen.getByText('文件夹'))!.toBeInTheDocument()
+ expect(screen.getByText('フォルダ'))!.toBeInTheDocument()
})
})
@@ -403,7 +512,7 @@ describe('Breadcrumbs', () => {
render()
- expect(screen.getByText(/searchResult/)).toBeInTheDocument()
+ expect(screen.getByText(/searchResult/))!.toBeInTheDocument()
})
it('should handle whitespace keywords', () => {
@@ -415,7 +524,8 @@ describe('Breadcrumbs', () => {
render()
// Assert - Whitespace is truthy, so should show search results
- expect(screen.getByText(/searchResult/)).toBeInTheDocument()
+ // Assert - Whitespace is truthy, so should show search results
+ expect(screen.getByText(/searchResult/))!.toBeInTheDocument()
})
})
@@ -428,7 +538,7 @@ describe('Breadcrumbs', () => {
render()
- expect(screen.getByText('production-bucket')).toBeInTheDocument()
+ expect(screen.getByText('production-bucket'))!.toBeInTheDocument()
})
it('should handle bucket with special characters', () => {
@@ -439,7 +549,7 @@ describe('Breadcrumbs', () => {
render()
- expect(screen.getByText('bucket-v2.0_backup')).toBeInTheDocument()
+ expect(screen.getByText('bucket-v2.0_backup'))!.toBeInTheDocument()
})
})
@@ -452,6 +562,37 @@ describe('Breadcrumbs', () => {
render()
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
+ // Assert - Should not show search results
// Assert - Should not show search results
expect(screen.queryByText(/searchResult/)).not.toBeInTheDocument()
})
@@ -464,7 +605,7 @@ describe('Breadcrumbs', () => {
render()
- expect(screen.getByText(/searchResult.*10000/)).toBeInTheDocument()
+ expect(screen.getByText(/searchResult.*10000/))!.toBeInTheDocument()
})
})
@@ -480,9 +621,7 @@ describe('Breadcrumbs', () => {
// Assert - Should collapse because 3 > 2
// Dropdown should be present
- const buttons = screen.getAllByRole('button')
- const hasDropdownTrigger = buttons.some(btn => btn.querySelector('svg'))
- expect(hasDropdownTrigger).toBe(true)
+ expect(getDropdownTrigger()).toBeInTheDocument()
})
it('should use displayBreadcrumbNum=3 when isInPipeline is false', () => {
@@ -495,9 +634,10 @@ describe('Breadcrumbs', () => {
render()
// Assert - Should NOT collapse because 3 <= 3
- expect(screen.getByText('folder1')).toBeInTheDocument()
- expect(screen.getByText('folder2')).toBeInTheDocument()
- expect(screen.getByText('folder3')).toBeInTheDocument()
+ // Assert - Should NOT collapse because 3 <= 3
+ expect(screen.getByText('folder1'))!.toBeInTheDocument()
+ expect(screen.getByText('folder2'))!.toBeInTheDocument()
+ expect(screen.getByText('folder3'))!.toBeInTheDocument()
})
it('should reduce displayBreadcrumbNum by 1 when bucket is set', () => {
@@ -511,9 +651,7 @@ describe('Breadcrumbs', () => {
render()
// Assert - Should collapse because 3 > 2
- const buttons = screen.getAllByRole('button')
- const hasDropdownTrigger = buttons.some(btn => btn.querySelector('svg'))
- expect(hasDropdownTrigger).toBe(true)
+ expect(getDropdownTrigger()).toBeInTheDocument()
})
})
})
@@ -533,9 +671,11 @@ describe('Breadcrumbs', () => {
// Assert - displayBreadcrumbNum = 3, so 4 breadcrumbs should collapse
// First 2 visible, dropdown, last 1 visible
- expect(screen.getByText('a')).toBeInTheDocument()
- expect(screen.getByText('b')).toBeInTheDocument()
- expect(screen.getByText('d')).toBeInTheDocument()
+ // Assert - displayBreadcrumbNum = 3, so 4 breadcrumbs should collapse
+ // First 2 visible, dropdown, last 1 visible
+ expect(screen.getByText('a'))!.toBeInTheDocument()
+ expect(screen.getByText('b'))!.toBeInTheDocument()
+ expect(screen.getByText('d'))!.toBeInTheDocument()
expect(screen.queryByText('c')).not.toBeInTheDocument()
})
@@ -550,8 +690,9 @@ describe('Breadcrumbs', () => {
render()
// Assert - displayBreadcrumbNum = 2, so 3 breadcrumbs should collapse
- expect(screen.getByText('a')).toBeInTheDocument()
- expect(screen.getByText('c')).toBeInTheDocument()
+ // Assert - displayBreadcrumbNum = 2, so 3 breadcrumbs should collapse
+ expect(screen.getByText('a'))!.toBeInTheDocument()
+ expect(screen.getByText('c'))!.toBeInTheDocument()
expect(screen.queryByText('b')).not.toBeInTheDocument()
})
@@ -566,8 +707,9 @@ describe('Breadcrumbs', () => {
render()
// Assert - displayBreadcrumbNum = 3 - 1 = 2, so 3 breadcrumbs should collapse
- expect(screen.getByText('a')).toBeInTheDocument()
- expect(screen.getByText('c')).toBeInTheDocument()
+ // Assert - displayBreadcrumbNum = 3 - 1 = 2, so 3 breadcrumbs should collapse
+ expect(screen.getByText('a'))!.toBeInTheDocument()
+ expect(screen.getByText('c'))!.toBeInTheDocument()
expect(screen.queryByText('b')).not.toBeInTheDocument()
})
})
@@ -582,9 +724,7 @@ describe('Breadcrumbs', () => {
render()
// Act - Click dropdown to see collapsed items
- const dropdownTrigger = screen.getAllByRole('button').find(btn => btn.querySelector('svg'))
- if (dropdownTrigger)
- fireEvent.click(dropdownTrigger)
+ openCollapsedBreadcrumbDropdown()
// prefixBreadcrumbs = ['f1', 'f2']
// collapsedBreadcrumbs = ['f3', 'f4']
@@ -592,10 +732,8 @@ describe('Breadcrumbs', () => {
expect(screen.getByText('f1')).toBeInTheDocument()
expect(screen.getByText('f2')).toBeInTheDocument()
expect(screen.getByText('f5')).toBeInTheDocument()
- await waitFor(() => {
- expect(screen.getByText('f3')).toBeInTheDocument()
- expect(screen.getByText('f4')).toBeInTheDocument()
- })
+ expect(await screen.findByText('f3')).toBeInTheDocument()
+ expect(await screen.findByText('f4')).toBeInTheDocument()
})
it('should not collapse when breadcrumbs.length <= displayBreadcrumbNum', () => {
@@ -608,8 +746,9 @@ describe('Breadcrumbs', () => {
render()
// Assert - All breadcrumbs should be visible
- expect(screen.getByText('f1')).toBeInTheDocument()
- expect(screen.getByText('f2')).toBeInTheDocument()
+ // Assert - All breadcrumbs should be visible
+ expect(screen.getByText('f1'))!.toBeInTheDocument()
+ expect(screen.getByText('f2'))!.toBeInTheDocument()
})
})
})
@@ -627,7 +766,7 @@ describe('Breadcrumbs', () => {
// Act - Click bucket icon button (first button in Bucket component)
const buttons = screen.getAllByRole('button')
- fireEvent.click(buttons[0]) // Bucket icon button
+ fireEvent.click(buttons[0]!) // Bucket icon button
expect(mockStoreState.setOnlineDriveFileList).toHaveBeenCalledWith([])
expect(mockStoreState.setSelectedFileIds).toHaveBeenCalledWith([])
@@ -739,15 +878,8 @@ describe('Breadcrumbs', () => {
render()
// Act - Open dropdown and click on collapsed breadcrumb (f3, index=2)
- const dropdownTrigger = screen.getAllByRole('button').find(btn => btn.querySelector('svg'))
- if (dropdownTrigger)
- fireEvent.click(dropdownTrigger)
-
- await waitFor(() => {
- expect(screen.getByText('f3')).toBeInTheDocument()
- })
-
- fireEvent.click(screen.getByText('f3'))
+ openCollapsedBreadcrumbDropdown()
+ fireEvent.click(await screen.findByText('f3'))
// Assert - Should slice to index 2 + 1 = 3
expect(mockStoreState.setBreadcrumbs).toHaveBeenCalledWith(['f1', 'f2', 'f3'])
@@ -771,19 +903,19 @@ describe('Breadcrumbs', () => {
// Assert - Component should render without errors
const container = document.querySelector('.flex.grow')
- expect(container).toBeInTheDocument()
+ expect(container)!.toBeInTheDocument()
})
it('should re-render when breadcrumbs change', () => {
mockStoreState.hasBucket = false
const props = createDefaultProps({ breadcrumbs: ['folder1'] })
const { rerender } = render()
- expect(screen.getByText('folder1')).toBeInTheDocument()
+ expect(screen.getByText('folder1'))!.toBeInTheDocument()
// Act - Rerender with different breadcrumbs
rerender()
- expect(screen.getByText('folder2')).toBeInTheDocument()
+ expect(screen.getByText('folder2'))!.toBeInTheDocument()
})
})
@@ -798,7 +930,7 @@ describe('Breadcrumbs', () => {
render()
- expect(screen.getByText(longName)).toBeInTheDocument()
+ expect(screen.getByText(longName))!.toBeInTheDocument()
})
it('should handle many breadcrumbs', async () => {
@@ -810,17 +942,13 @@ describe('Breadcrumbs', () => {
render()
// Act - Open dropdown
- const dropdownTrigger = screen.getAllByRole('button').find(btn => btn.querySelector('svg'))
- if (dropdownTrigger)
- fireEvent.click(dropdownTrigger)
+ openCollapsedBreadcrumbDropdown()
// Assert - First, last, and collapsed should be accessible
expect(screen.getByText('folder-0')).toBeInTheDocument()
expect(screen.getByText('folder-1')).toBeInTheDocument()
expect(screen.getByText('folder-19')).toBeInTheDocument()
- await waitFor(() => {
- expect(screen.getByText('folder-2')).toBeInTheDocument()
- })
+ expect(await screen.findByText('folder-2')).toBeInTheDocument()
})
it('should handle empty bucket string', () => {
@@ -833,7 +961,8 @@ describe('Breadcrumbs', () => {
render()
// Assert - Should show all buckets title
- expect(screen.getByText('datasetPipeline.onlineDrive.breadcrumbs.allBuckets')).toBeInTheDocument()
+ // Assert - Should show all buckets title
+ expect(screen.getByText('datasetPipeline.onlineDrive.breadcrumbs.allBuckets'))!.toBeInTheDocument()
})
it('should handle breadcrumb with only whitespace', () => {
@@ -845,7 +974,8 @@ describe('Breadcrumbs', () => {
render()
// Assert - Both should be rendered
- expect(screen.getByText('normal-folder')).toBeInTheDocument()
+ // Assert - Both should be rendered
+ expect(screen.getByText('normal-folder'))!.toBeInTheDocument()
})
})
@@ -863,7 +993,7 @@ describe('Breadcrumbs', () => {
// Assert - Component should render without errors
const container = document.querySelector('.flex.grow')
- expect(container).toBeInTheDocument()
+ expect(container)!.toBeInTheDocument()
})
it.each([
@@ -879,9 +1009,7 @@ describe('Breadcrumbs', () => {
render()
// Assert - Should collapse because breadcrumbs.length > expectedNum
- const buttons = screen.getAllByRole('button')
- const hasDropdownTrigger = buttons.some(btn => btn.querySelector('svg'))
- expect(hasDropdownTrigger).toBe(true)
+ expect(getDropdownTrigger()).toBeInTheDocument()
})
})
@@ -916,7 +1044,8 @@ describe('Breadcrumbs', () => {
render()
// Assert - Search result should be shown, navigation elements should be hidden
- expect(screen.getByText(/searchResult/)).toBeInTheDocument()
+ // Assert - Search result should be shown, navigation elements should be hidden
+ expect(screen.getByText(/searchResult/))!.toBeInTheDocument()
expect(screen.queryByText('my-bucket')).not.toBeInTheDocument()
})
})
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/dropdown/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/dropdown/__tests__/index.spec.tsx
index 0157d3cf79..d57e8340e9 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/dropdown/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/dropdown/__tests__/index.spec.tsx
@@ -23,7 +23,8 @@ describe('Dropdown', () => {
render()
// Assert - Trigger button should be visible
- expect(screen.getByRole('button')).toBeInTheDocument()
+ // Assert - Trigger button should be visible
+ expect(screen.getByRole('button'))!.toBeInTheDocument()
})
it('should render trigger button with more icon', () => {
@@ -31,10 +32,10 @@ describe('Dropdown', () => {
const { container } = render()
- // Assert - Button should have RiMoreFill icon (rendered as svg)
+ // Assert - Button should have the more icon
const button = screen.getByRole('button')
expect(button).toBeInTheDocument()
- expect(container.querySelector('svg')).toBeInTheDocument()
+ expect(container.querySelector('.i-ri-more-fill')).toBeInTheDocument()
})
it('should render separator after dropdown', () => {
@@ -43,7 +44,8 @@ describe('Dropdown', () => {
render()
// Assert - Separator "/" should be visible
- expect(screen.getByText('/')).toBeInTheDocument()
+ // Assert - Separator "/" should be visible
+ expect(screen.getByText('/'))!.toBeInTheDocument()
})
it('should render trigger button with correct default styles', () => {
@@ -52,11 +54,11 @@ describe('Dropdown', () => {
render()
const button = screen.getByRole('button')
- expect(button).toHaveClass('flex')
- expect(button).toHaveClass('size-6')
- expect(button).toHaveClass('items-center')
- expect(button).toHaveClass('justify-center')
- expect(button).toHaveClass('rounded-md')
+ expect(button)!.toHaveClass('flex')
+ expect(button)!.toHaveClass('size-6')
+ expect(button)!.toHaveClass('items-center')
+ expect(button)!.toHaveClass('justify-center')
+ expect(button)!.toHaveClass('rounded-md')
})
it('should not render menu content when closed', () => {
@@ -64,6 +66,37 @@ describe('Dropdown', () => {
render()
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
+ // Assert - Menu content should not be visible when dropdown is closed
// Assert - Menu content should not be visible when dropdown is closed
expect(screen.queryByText('visible-folder')).not.toBeInTheDocument()
})
@@ -77,8 +110,8 @@ describe('Dropdown', () => {
// Assert - Menu items should be visible
await waitFor(() => {
- expect(screen.getByText('test-folder1')).toBeInTheDocument()
- expect(screen.getByText('test-folder2')).toBeInTheDocument()
+ expect(screen.getByText('test-folder1'))!.toBeInTheDocument()
+ expect(screen.getByText('test-folder2'))!.toBeInTheDocument()
})
})
})
@@ -98,7 +131,7 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('folder1')).toBeInTheDocument()
+ expect(screen.getByText('folder1'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText('folder1'))
@@ -120,7 +153,7 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('folder2')).toBeInTheDocument()
+ expect(screen.getByText('folder2'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText('folder2'))
@@ -140,9 +173,9 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('folder-a')).toBeInTheDocument()
- expect(screen.getByText('folder-b')).toBeInTheDocument()
- expect(screen.getByText('folder-c')).toBeInTheDocument()
+ expect(screen.getByText('folder-a'))!.toBeInTheDocument()
+ expect(screen.getByText('folder-b'))!.toBeInTheDocument()
+ expect(screen.getByText('folder-c'))!.toBeInTheDocument()
})
})
@@ -155,7 +188,7 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('single-folder')).toBeInTheDocument()
+ expect(screen.getByText('single-folder'))!.toBeInTheDocument()
})
})
@@ -170,7 +203,8 @@ describe('Dropdown', () => {
// Assert - Menu should be rendered but with no items
await waitFor(() => {
// The menu container should exist but be empty
- expect(screen.getByRole('button')).toBeInTheDocument()
+ // The menu container should exist but be empty
+ expect(screen.getByRole('button'))!.toBeInTheDocument()
})
})
@@ -183,9 +217,9 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('folder [1]')).toBeInTheDocument()
- expect(screen.getByText('folder (copy)')).toBeInTheDocument()
- expect(screen.getByText('folder-v2.0')).toBeInTheDocument()
+ expect(screen.getByText('folder [1]'))!.toBeInTheDocument()
+ expect(screen.getByText('folder (copy)'))!.toBeInTheDocument()
+ expect(screen.getByText('folder-v2.0'))!.toBeInTheDocument()
})
})
@@ -198,9 +232,9 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('文件夹')).toBeInTheDocument()
- expect(screen.getByText('フォルダ')).toBeInTheDocument()
- expect(screen.getByText('Папка')).toBeInTheDocument()
+ expect(screen.getByText('文件夹'))!.toBeInTheDocument()
+ expect(screen.getByText('フォルダ'))!.toBeInTheDocument()
+ expect(screen.getByText('Папка'))!.toBeInTheDocument()
})
})
})
@@ -218,7 +252,7 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('folder1')).toBeInTheDocument()
+ expect(screen.getByText('folder1'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText('folder1'))
@@ -236,6 +270,37 @@ describe('Dropdown', () => {
render()
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
+ // Assert - Menu content should not be visible
// Assert - Menu content should not be visible
expect(screen.queryByText('test-folder')).not.toBeInTheDocument()
})
@@ -247,7 +312,7 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('test-folder')).toBeInTheDocument()
+ expect(screen.getByText('test-folder'))!.toBeInTheDocument()
})
})
@@ -258,7 +323,7 @@ describe('Dropdown', () => {
// Act - Open and then close
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('test-folder')).toBeInTheDocument()
+ expect(screen.getByText('test-folder'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByRole('button'))
@@ -280,7 +345,7 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('test-folder')).toBeInTheDocument()
+ expect(screen.getByText('test-folder'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText('test-folder'))
@@ -297,14 +362,15 @@ describe('Dropdown', () => {
const button = screen.getByRole('button')
// Assert - Initial state (closed): should have hover:bg-state-base-hover
- expect(button).toHaveClass('hover:bg-state-base-hover')
+ // Assert - Initial state (closed): should have hover:bg-state-base-hover
+ expect(button)!.toHaveClass('hover:bg-state-base-hover')
// Act - Open dropdown
fireEvent.click(button)
// Assert - Open state: should have bg-state-base-hover
await waitFor(() => {
- expect(button).toHaveClass('bg-state-base-hover')
+ expect(button)!.toHaveClass('bg-state-base-hover')
})
})
})
@@ -317,6 +383,37 @@ describe('Dropdown', () => {
const props = createDefaultProps({ breadcrumbs: ['folder'] })
render()
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
+ // Act & Assert - Initially closed
// Act & Assert - Initially closed
expect(screen.queryByText('folder')).not.toBeInTheDocument()
@@ -325,7 +422,7 @@ describe('Dropdown', () => {
// Assert - Now open
await waitFor(() => {
- expect(screen.getByText('folder')).toBeInTheDocument()
+ expect(screen.getByText('folder'))!.toBeInTheDocument()
})
})
@@ -338,7 +435,7 @@ describe('Dropdown', () => {
// 1st click - open
fireEvent.click(button)
await waitFor(() => {
- expect(screen.getByText('folder')).toBeInTheDocument()
+ expect(screen.getByText('folder'))!.toBeInTheDocument()
})
// 2nd click - close
@@ -350,7 +447,7 @@ describe('Dropdown', () => {
// 3rd click - open again
fireEvent.click(button)
await waitFor(() => {
- expect(screen.getByText('folder')).toBeInTheDocument()
+ expect(screen.getByText('folder'))!.toBeInTheDocument()
})
})
})
@@ -368,7 +465,7 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('folder1')).toBeInTheDocument()
+ expect(screen.getByText('folder1'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText('folder1'))
@@ -394,7 +491,7 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('folder1')).toBeInTheDocument()
+ expect(screen.getByText('folder1'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText('folder1'))
@@ -423,7 +520,7 @@ describe('Dropdown', () => {
// Act - Open and click
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('folder')).toBeInTheDocument()
+ expect(screen.getByText('folder'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText('folder'))
@@ -431,7 +528,7 @@ describe('Dropdown', () => {
rerender()
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('folder')).toBeInTheDocument()
+ expect(screen.getByText('folder'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText('folder'))
@@ -450,7 +547,7 @@ describe('Dropdown', () => {
// Act - Open and click with first callback
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('folder')).toBeInTheDocument()
+ expect(screen.getByText('folder'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText('folder'))
@@ -466,7 +563,7 @@ describe('Dropdown', () => {
// Open and click with second callback
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('folder')).toBeInTheDocument()
+ expect(screen.getByText('folder'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText('folder'))
@@ -482,7 +579,8 @@ describe('Dropdown', () => {
rerender()
// Assert - Component should render without errors
- expect(screen.getByRole('button')).toBeInTheDocument()
+ // Assert - Component should render without errors
+ expect(screen.getByRole('button'))!.toBeInTheDocument()
})
})
@@ -499,7 +597,7 @@ describe('Dropdown', () => {
// Assert - Should handle gracefully (open after odd number of clicks)
await waitFor(() => {
- expect(screen.getByText('folder')).toBeInTheDocument()
+ expect(screen.getByText('folder'))!.toBeInTheDocument()
})
})
@@ -513,7 +611,7 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText(longName)).toBeInTheDocument()
+ expect(screen.getByText(longName))!.toBeInTheDocument()
})
})
@@ -528,8 +626,8 @@ describe('Dropdown', () => {
// Assert - First and last items should be visible
await waitFor(() => {
- expect(screen.getByText('folder-0')).toBeInTheDocument()
- expect(screen.getByText('folder-19')).toBeInTheDocument()
+ expect(screen.getByText('folder-0'))!.toBeInTheDocument()
+ expect(screen.getByText('folder-19'))!.toBeInTheDocument()
})
})
@@ -544,7 +642,7 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('folder')).toBeInTheDocument()
+ expect(screen.getByText('folder'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText('folder'))
@@ -562,7 +660,7 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('folder')).toBeInTheDocument()
+ expect(screen.getByText('folder'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText('folder'))
@@ -578,7 +676,7 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('normal-folder')).toBeInTheDocument()
+ expect(screen.getByText('normal-folder'))!.toBeInTheDocument()
})
})
@@ -591,7 +689,7 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('folder')).toBeInTheDocument()
+ expect(screen.getByText('folder'))!.toBeInTheDocument()
})
})
})
@@ -613,9 +711,9 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText(breadcrumbs[0])).toBeInTheDocument()
+ expect(screen.getByText(breadcrumbs[0]!))!.toBeInTheDocument()
})
- fireEvent.click(screen.getByText(breadcrumbs[0]))
+ fireEvent.click(screen.getByText(breadcrumbs[0]!))
expect(mockOnBreadcrumbClick).toHaveBeenCalledWith(expectedIndex)
})
@@ -634,7 +732,7 @@ describe('Dropdown', () => {
// Assert - Should render without errors
await waitFor(() => {
if (breadcrumbs.length > 0)
- expect(screen.getByText(breadcrumbs[0])).toBeInTheDocument()
+ expect(screen.getByText(breadcrumbs[0]!))!.toBeInTheDocument()
})
})
})
@@ -650,9 +748,9 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('Documents')).toBeInTheDocument()
- expect(screen.getByText('Projects')).toBeInTheDocument()
- expect(screen.getByText('Archive')).toBeInTheDocument()
+ expect(screen.getByText('Documents'))!.toBeInTheDocument()
+ expect(screen.getByText('Projects'))!.toBeInTheDocument()
+ expect(screen.getByText('Archive'))!.toBeInTheDocument()
})
})
@@ -668,7 +766,7 @@ describe('Dropdown', () => {
// Act - Open and click on second item
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('second')).toBeInTheDocument()
+ expect(screen.getByText('second'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText('second'))
@@ -687,7 +785,7 @@ describe('Dropdown', () => {
// Act - Open and click on middle item
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText('item2')).toBeInTheDocument()
+ expect(screen.getByText('item2'))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText('item2'))
@@ -714,7 +812,7 @@ describe('Dropdown', () => {
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
- expect(screen.getByText(`folder-${String.fromCharCode(97 + i)}`)).toBeInTheDocument()
+ expect(screen.getByText(`folder-${String.fromCharCode(97 + i)}`))!.toBeInTheDocument()
})
fireEvent.click(screen.getByText(`folder-${String.fromCharCode(97 + i)}`))
@@ -731,7 +829,7 @@ describe('Dropdown', () => {
render()
const button = screen.getByRole('button')
- expect(button).toBeInTheDocument()
+ expect(button)!.toBeInTheDocument()
expect(button.tagName).toBe('BUTTON')
})
@@ -741,7 +839,7 @@ describe('Dropdown', () => {
render()
const button = screen.getByRole('button')
- expect(button).toHaveAttribute('type', 'button')
+ expect(button)!.toHaveAttribute('type', 'button')
})
})
})
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/dropdown/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/dropdown/index.tsx
index 7178b45b34..43b5fcc71a 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/dropdown/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/dropdown/index.tsx
@@ -1,12 +1,11 @@
import { cn } from '@langgenius/dify-ui/cn'
-import { RiMoreFill } from '@remixicon/react'
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuTrigger,
+} from '@langgenius/dify-ui/dropdown-menu'
import * as React from 'react'
import { useCallback, useState } from 'react'
-import {
- PortalToFollowElem,
- PortalToFollowElemContent,
- PortalToFollowElemTrigger,
-} from '@/app/components/base/portal-to-follow-elem'
import Menu from './menu'
type DropdownProps = {
@@ -22,26 +21,17 @@ const Dropdown = ({
}: DropdownProps) => {
const [open, setOpen] = useState(false)
- const handleTrigger = useCallback(() => {
- setOpen(prev => !prev)
- }, [])
-
const handleBreadCrumbClick = useCallback((index: number) => {
onBreadcrumbClick(index)
setOpen(false)
}, [onBreadcrumbClick])
return (
-
-
+ }>
-
-
+
+
-
+
/
-
+
)
}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/dropdown/item.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/dropdown/item.tsx
index 864cade85c..6f04ede88a 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/dropdown/item.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/dropdown/item.tsx
@@ -18,7 +18,7 @@ const Item = ({
return (
{name}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/index.tsx
index 714b393d03..1dfa0443d0 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/header/breadcrumbs/index.tsx
@@ -83,7 +83,7 @@ const Breadcrumbs = ({
return (
{showSearchResult && (
-
+
{t('onlineDrive.breadcrumbs.searchResult', {
ns: 'datasetPipeline',
searchResultsLength,
@@ -92,7 +92,7 @@ const Breadcrumbs = ({
)}
{!showSearchResult && showBucketListTitle && (
-
+
{t('onlineDrive.breadcrumbs.allBuckets', { ns: 'datasetPipeline' })}
)}
@@ -152,7 +152,7 @@ const Breadcrumbs = ({
void
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/index.tsx
index f0245cc9a4..00386ec135 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/index.tsx
@@ -39,7 +39,7 @@ const List = ({
if (anchorRef.current) {
observerRef.current = new IntersectionObserver((entries) => {
const { setNextPageParameters, currentNextPageParametersRef, isTruncated } = dataSourceStore.getState()
- if (entries[0].isIntersecting && isTruncated.current && !isLoading)
+ if (entries[0]!.isIntersecting && isTruncated.current && !isLoading)
setNextPageParameters(currentNextPageParametersRef.current)
}, {
rootMargin: '100px',
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/utils.ts b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/utils.ts
index 6b367ebe3c..07b23a56ff 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/utils.ts
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/utils.ts
@@ -8,7 +8,7 @@ export const getFileExtension = (fileName: string): string => {
if (parts.length <= 1 || (parts[0] === '' && parts.length === 2))
return ''
- return parts[parts.length - 1].toLowerCase()
+ return parts[parts.length - 1]!.toLowerCase()
}
export const getFileType = (fileName: string) => {
@@ -17,13 +17,13 @@ export const getFileType = (fileName: string) => {
if (extension === 'gif')
return FileAppearanceTypeEnum.gif
- if (FILE_EXTS.image.includes(extension.toUpperCase()))
+ if (FILE_EXTS.image!.includes(extension.toUpperCase()))
return FileAppearanceTypeEnum.image
- if (FILE_EXTS.video.includes(extension.toUpperCase()))
+ if (FILE_EXTS.video!.includes(extension.toUpperCase()))
return FileAppearanceTypeEnum.video
- if (FILE_EXTS.audio.includes(extension.toUpperCase()))
+ if (FILE_EXTS.audio!.includes(extension.toUpperCase()))
return FileAppearanceTypeEnum.audio
if (extension === 'html' || extension === 'htm' || extension === 'xml' || extension === 'json')
@@ -44,7 +44,7 @@ export const getFileType = (fileName: string) => {
if (extension === 'pptx' || extension === 'ppt')
return FileAppearanceTypeEnum.ppt
- if (FILE_EXTS.document.includes(extension.toUpperCase()))
+ if (FILE_EXTS.document!.includes(extension.toUpperCase()))
return FileAppearanceTypeEnum.document
return FileAppearanceTypeEnum.custom
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/header.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/header.tsx
index 5c12aaa68c..bc51751aef 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/header.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/header.tsx
@@ -1,7 +1,7 @@
+import { Button } from '@langgenius/dify-ui/button'
import { RiBookOpenLine, RiEqualizer2Line } from '@remixicon/react'
import * as React from 'react'
import Divider from '@/app/components/base/divider'
-import { Button } from '@/app/components/base/ui/button'
type HeaderProps = {
onClickConfiguration?: () => void
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/index.tsx
index 2113e8841c..76614e3865 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/index.tsx
@@ -1,10 +1,10 @@
import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types'
import type { OnlineDriveFile } from '@/models/pipeline'
import type { DataSourceNodeCompletedResponse, DataSourceNodeErrorResponse } from '@/types/pipeline'
+import { toast } from '@langgenius/dify-ui/toast'
import { produce } from 'immer'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useShallow } from 'zustand/react/shallow'
-import { toast } from '@/app/components/base/ui/toast'
import { ACCOUNT_SETTING_TAB } from '@/app/components/header/account-setting/constants'
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
import { useDocLink } from '@/context/i18n'
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/utils.ts b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/utils.ts
index 89b84069fe..8f0ff13ac5 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/utils.ts
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/utils.ts
@@ -10,7 +10,7 @@ export const isBucketListInitiation = (data: OnlineDriveData[], prefix: string[]
if (bucket || prefix.length > 0)
return false
const hasBucket = data.every(item => !!item.bucket)
- return hasBucket && (data.length > 1 || (data.length === 1 && !!data[0].bucket && data[0].files.length === 0))
+ return hasBucket && (data.length > 1 || (data.length === 1 && !!data[0]!.bucket && data[0]!.files.length === 0))
}
export const convertOnlineDriveData = (data: OnlineDriveData[], prefix: string[], bucket: string): {
@@ -38,7 +38,7 @@ export const convertOnlineDriveData = (data: OnlineDriveData[], prefix: string[]
hasBucket = true
}
else {
- data[0].files.forEach((file) => {
+ data[0]!.files.forEach((file) => {
const { id, name, size, type } = file
const isFileType = isFile(type)
fileList.push({
@@ -48,9 +48,9 @@ export const convertOnlineDriveData = (data: OnlineDriveData[], prefix: string[]
type: isFileType ? OnlineDriveFileType.file : OnlineDriveFileType.folder,
})
})
- isTruncated = data[0].is_truncated ?? false
- nextPageParameters = data[0].next_page_parameters ?? {}
- hasBucket = !!data[0].bucket
+ isTruncated = data[0]!.is_truncated ?? false
+ nextPageParameters = data[0]!.next_page_parameters ?? {}
+ hasBucket = !!data[0]!.bucket
}
return { fileList, isTruncated, nextPageParameters, hasBucket }
}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/crawled-result-item.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/crawled-result-item.spec.tsx
index 62dba84e30..cded02b431 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/crawled-result-item.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/crawled-result-item.spec.tsx
@@ -3,7 +3,7 @@ import { render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import CrawledResultItem from '../crawled-result-item'
-vi.mock('@/app/components/base/ui/button', () => ({
+vi.mock('@langgenius/dify-ui/button', () => ({
Button: ({ children, onClick }: { children: React.ReactNode, onClick: () => void }) => (
),
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/crawled-result.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/crawled-result.spec.tsx
index 9c71f91d8d..6c476e6dd6 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/crawled-result.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/crawled-result.spec.tsx
@@ -49,9 +49,9 @@ const createItem = (url: string): CrawlResultItem => ({
})
const defaultList: CrawlResultItem[] = [
- createItem('https://example.com/a'),
- createItem('https://example.com/b'),
- createItem('https://example.com/c'),
+ createItem('https://example.com/a')!,
+ createItem('https://example.com/b')!,
+ createItem('https://example.com/c')!,
]
describe('CrawledResult', () => {
@@ -70,19 +70,18 @@ describe('CrawledResult', () => {
it('should render scrap time info with correct total and time', () => {
render()
- expect(
- screen.getByText(/scrapTimeInfo/),
- ).toBeInTheDocument()
+ expect(screen.getByText(/scrapTimeInfo/))!.toBeInTheDocument()
// The global i18n mock serialises params, so verify total and time appear
- expect(screen.getByText(/"total":3/)).toBeInTheDocument()
- expect(screen.getByText(/"time":"12.3"/)).toBeInTheDocument()
+ // The global i18n mock serialises params, so verify total and time appear
+ expect(screen.getByText(/"total":3/))!.toBeInTheDocument()
+ expect(screen.getByText(/"time":"12.3"/))!.toBeInTheDocument()
})
it('should render all items from list', () => {
render()
for (const item of defaultList) {
- expect(screen.getByTestId(`crawled-item-${item.source_url}`)).toBeInTheDocument()
+ expect(screen.getByTestId(`crawled-item-${item.source_url}`))!.toBeInTheDocument()
}
})
@@ -91,7 +90,7 @@ describe('CrawledResult', () => {
,
)
- expect(container.firstChild).toHaveClass('my-custom-class')
+ expect(container.firstChild)!.toHaveClass('my-custom-class')
})
})
@@ -100,7 +99,7 @@ describe('CrawledResult', () => {
it('should show check-all checkbox in multiple choice mode', () => {
render()
- expect(screen.getByTestId('check-all-checkbox')).toBeInTheDocument()
+ expect(screen.getByTestId('check-all-checkbox'))!.toBeInTheDocument()
})
it('should hide check-all checkbox in single choice mode', () => {
@@ -117,7 +116,7 @@ describe('CrawledResult', () => {
render(
,
)
@@ -150,13 +149,13 @@ describe('CrawledResult', () => {
render(
,
)
- fireEvent.click(screen.getByTestId(`check-${defaultList[1].source_url}`))
+ fireEvent.click(screen.getByTestId(`check-${defaultList[1]!.source_url}`))
expect(onSelectedChange).toHaveBeenCalledWith([defaultList[0], defaultList[1]])
})
@@ -166,13 +165,13 @@ describe('CrawledResult', () => {
render(
,
)
- fireEvent.click(screen.getByTestId(`check-${defaultList[1].source_url}`))
+ fireEvent.click(screen.getByTestId(`check-${defaultList[1]!.source_url}`))
expect(onSelectedChange).toHaveBeenCalledWith([defaultList[1]])
})
@@ -182,13 +181,13 @@ describe('CrawledResult', () => {
render(
,
)
- fireEvent.click(screen.getByTestId(`check-${defaultList[0].source_url}`))
+ fireEvent.click(screen.getByTestId(`check-${defaultList[0]!.source_url}`))
expect(onSelectedChange).toHaveBeenCalledWith([defaultList[1]])
})
@@ -206,7 +205,7 @@ describe('CrawledResult', () => {
/>,
)
- fireEvent.click(screen.getByTestId(`preview-${defaultList[1].source_url}`))
+ fireEvent.click(screen.getByTestId(`preview-${defaultList[1]!.source_url}`))
expect(onPreview).toHaveBeenCalledWith(defaultList[1], 1)
})
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/index.spec.tsx
index 99002e687c..fa5633e2df 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/index.spec.tsx
@@ -39,7 +39,7 @@ describe('CheckboxWithLabel', () => {
it('should render without crashing', () => {
render()
- expect(screen.getByText('Test Label')).toBeInTheDocument()
+ expect(screen.getByText('Test Label'))!.toBeInTheDocument()
})
it('should render checkbox in unchecked state', () => {
@@ -47,7 +47,7 @@ describe('CheckboxWithLabel', () => {
// Assert - Custom checkbox component uses div with data-testid
const checkbox = container.querySelector('[data-testid^="checkbox"]')
- expect(checkbox).toBeInTheDocument()
+ expect(checkbox)!.toBeInTheDocument()
expect(checkbox).not.toHaveClass('bg-components-checkbox-bg')
})
@@ -56,7 +56,7 @@ describe('CheckboxWithLabel', () => {
// Assert - Checked state has check icon
const checkIcon = container.querySelector('[data-testid^="check-icon"]')
- expect(checkIcon).toBeInTheDocument()
+ expect(checkIcon)!.toBeInTheDocument()
})
it('should render tooltip when provided', () => {
@@ -64,7 +64,7 @@ describe('CheckboxWithLabel', () => {
// Assert - Tooltip trigger should be present
const tooltipTrigger = document.querySelector('[class*="ml-0.5"]')
- expect(tooltipTrigger).toBeInTheDocument()
+ expect(tooltipTrigger)!.toBeInTheDocument()
})
it('should not render tooltip when not provided', () => {
@@ -82,14 +82,14 @@ describe('CheckboxWithLabel', () => {
)
const label = container.querySelector('label')
- expect(label).toHaveClass('custom-class')
+ expect(label)!.toHaveClass('custom-class')
})
it('should apply custom labelClassName', () => {
render()
const labelText = screen.getByText('Test Label')
- expect(labelText).toHaveClass('custom-label-class')
+ expect(labelText)!.toHaveClass('custom-label-class')
})
})
@@ -147,8 +147,8 @@ describe('CrawledResultItem', () => {
it('should render without crashing', () => {
render()
- expect(screen.getByText('Test Page Title')).toBeInTheDocument()
- expect(screen.getByText('https://example.com/page1')).toBeInTheDocument()
+ expect(screen.getByText('Test Page Title'))!.toBeInTheDocument()
+ expect(screen.getByText('https://example.com/page1'))!.toBeInTheDocument()
})
it('should render checkbox when isMultipleChoice is true', () => {
@@ -156,7 +156,7 @@ describe('CrawledResultItem', () => {
// Assert - Custom checkbox uses data-testid
const checkbox = container.querySelector('[data-testid^="checkbox"]')
- expect(checkbox).toBeInTheDocument()
+ expect(checkbox)!.toBeInTheDocument()
})
it('should render radio when isMultipleChoice is false', () => {
@@ -164,7 +164,7 @@ describe('CrawledResultItem', () => {
// Assert - Radio component has size-4 rounded-full classes
const radio = container.querySelector('.size-4.rounded-full')
- expect(radio).toBeInTheDocument()
+ expect(radio)!.toBeInTheDocument()
})
it('should render checkbox as checked when isChecked is true', () => {
@@ -172,13 +172,13 @@ describe('CrawledResultItem', () => {
// Assert - Checked state shows check icon
const checkIcon = container.querySelector('[data-testid^="check-icon"]')
- expect(checkIcon).toBeInTheDocument()
+ expect(checkIcon)!.toBeInTheDocument()
})
it('should render preview button when showPreview is true', () => {
render()
- expect(screen.getByRole('button')).toBeInTheDocument()
+ expect(screen.getByRole('button'))!.toBeInTheDocument()
})
it('should not render preview button when showPreview is false', () => {
@@ -191,15 +191,15 @@ describe('CrawledResultItem', () => {
const { container } = render()
const item = container.firstChild
- expect(item).toHaveClass('bg-state-base-active')
+ expect(item)!.toHaveClass('bg-state-base-active')
})
it('should apply hover styles when isPreview is false', () => {
const { container } = render()
const item = container.firstChild
- expect(item).toHaveClass('group')
- expect(item).toHaveClass('hover:bg-state-base-hover')
+ expect(item)!.toHaveClass('group')
+ expect(item)!.toHaveClass('hover:bg-state-base-hover')
})
})
@@ -209,7 +209,7 @@ describe('CrawledResultItem', () => {
render()
- expect(screen.getByText('Custom Title')).toBeInTheDocument()
+ expect(screen.getByText('Custom Title'))!.toBeInTheDocument()
})
it('should display payload source_url', () => {
@@ -217,7 +217,7 @@ describe('CrawledResultItem', () => {
render()
- expect(screen.getByText('https://custom.url/path')).toBeInTheDocument()
+ expect(screen.getByText('https://custom.url/path'))!.toBeInTheDocument()
})
it('should set title attribute for truncation tooltip', () => {
@@ -226,7 +226,7 @@ describe('CrawledResultItem', () => {
render()
const titleElement = screen.getByText('Very Long Title')
- expect(titleElement).toHaveAttribute('title', 'Very Long Title')
+ expect(titleElement)!.toHaveAttribute('title', 'Very Long Title')
})
})
@@ -310,22 +310,24 @@ describe('CrawledResult', () => {
render()
// Assert - Check for time info which contains total count
- expect(screen.getByText(/1.5/)).toBeInTheDocument()
+ // Assert - Check for time info which contains total count
+ expect(screen.getByText(/1.5/))!.toBeInTheDocument()
})
it('should render all list items', () => {
render()
- expect(screen.getByText('Page 1')).toBeInTheDocument()
- expect(screen.getByText('Page 2')).toBeInTheDocument()
- expect(screen.getByText('Page 3')).toBeInTheDocument()
+ expect(screen.getByText('Page 1'))!.toBeInTheDocument()
+ expect(screen.getByText('Page 2'))!.toBeInTheDocument()
+ expect(screen.getByText('Page 3'))!.toBeInTheDocument()
})
it('should display scrape time info', () => {
render()
// Assert - Check for the time display
- expect(screen.getByText(/2.5/)).toBeInTheDocument()
+ // Assert - Check for the time display
+ expect(screen.getByText(/2.5/))!.toBeInTheDocument()
})
it('should render select all checkbox when isMultipleChoice is true', () => {
@@ -350,7 +352,7 @@ describe('CrawledResult', () => {
it('should show "Select All" when not all items are checked', () => {
render()
- expect(screen.getByText(/selectAll|Select All/i)).toBeInTheDocument()
+ expect(screen.getByText(/selectAll|Select All/i))!.toBeInTheDocument()
})
it('should show "Reset All" when all items are checked', () => {
@@ -358,7 +360,7 @@ describe('CrawledResult', () => {
render()
- expect(screen.getByText(/resetAll|Reset All/i)).toBeInTheDocument()
+ expect(screen.getByText(/resetAll|Reset All/i))!.toBeInTheDocument()
})
})
@@ -368,7 +370,7 @@ describe('CrawledResult', () => {
,
)
- expect(container.firstChild).toHaveClass('custom-class')
+ expect(container.firstChild)!.toHaveClass('custom-class')
})
it('should highlight item at previewIndex', () => {
@@ -378,7 +380,7 @@ describe('CrawledResult', () => {
// Assert - Second item should have active state
const items = container.querySelectorAll('[class*="rounded-lg"][class*="cursor-pointer"]')
- expect(items[1]).toHaveClass('bg-state-base-active')
+ expect(items[1])!.toHaveClass('bg-state-base-active')
})
it('should pass showPreview to items', () => {
@@ -411,7 +413,7 @@ describe('CrawledResult', () => {
// Act - Click select all checkbox (first checkbox)
const checkboxes = container.querySelectorAll('[data-testid^="checkbox"]')
- fireEvent.click(checkboxes[0])
+ fireEvent.click(checkboxes[0]!)
expect(mockOnSelectedChange).toHaveBeenCalledWith(list)
})
@@ -429,7 +431,7 @@ describe('CrawledResult', () => {
)
const checkboxes = container.querySelectorAll('[data-testid^="checkbox"]')
- fireEvent.click(checkboxes[0])
+ fireEvent.click(checkboxes[0]!)
expect(mockOnSelectedChange).toHaveBeenCalledWith([])
})
@@ -441,14 +443,14 @@ describe('CrawledResult', () => {
,
)
// Act - Click second item checkbox (index 2, accounting for select all)
const checkboxes = container.querySelectorAll('[data-testid^="checkbox"]')
- fireEvent.click(checkboxes[2])
+ fireEvent.click(checkboxes[2]!)
expect(mockOnSelectedChange).toHaveBeenCalledWith([list[0], list[1]])
})
@@ -460,14 +462,14 @@ describe('CrawledResult', () => {
,
)
// Act - Uncheck first item (index 1, after select all)
const checkboxes = container.querySelectorAll('[data-testid^="checkbox"]')
- fireEvent.click(checkboxes[1])
+ fireEvent.click(checkboxes[1]!)
expect(mockOnSelectedChange).toHaveBeenCalledWith([list[1]])
})
@@ -479,7 +481,7 @@ describe('CrawledResult', () => {
,
@@ -487,7 +489,7 @@ describe('CrawledResult', () => {
// Act - Click second item radio (Radio uses size-4 rounded-full classes)
const radios = container.querySelectorAll('.size-4.rounded-full')
- fireEvent.click(radios[1])
+ fireEvent.click(radios[1]!)
// Assert - Should only select the clicked item
expect(mockOnSelectedChange).toHaveBeenCalledWith([list[1]])
@@ -506,7 +508,7 @@ describe('CrawledResult', () => {
)
const buttons = screen.getAllByRole('button')
- fireEvent.click(buttons[1]) // Second item's preview button
+ fireEvent.click(buttons[1]!) // Second item's preview button
expect(mockOnPreview).toHaveBeenCalledWith(list[1], 1)
})
@@ -525,10 +527,11 @@ describe('CrawledResult', () => {
// Act - Click preview button should trigger early return in handlePreview
const buttons = screen.getAllByRole('button')
- fireEvent.click(buttons[0])
+ fireEvent.click(buttons[0]!)
// Assert - Should not throw error, component still renders
- expect(screen.getByText('Page 1')).toBeInTheDocument()
+ // Assert - Should not throw error, component still renders
+ expect(screen.getByText('Page 1'))!.toBeInTheDocument()
})
})
@@ -537,7 +540,8 @@ describe('CrawledResult', () => {
render()
// Assert - Should show time info with 0 count
- expect(screen.getByText(/0.5/)).toBeInTheDocument()
+ // Assert - Should show time info with 0 count
+ expect(screen.getByText(/0.5/))!.toBeInTheDocument()
})
it('should handle single item list', () => {
@@ -545,13 +549,13 @@ describe('CrawledResult', () => {
render()
- expect(screen.getByText('Test Page Title')).toBeInTheDocument()
+ expect(screen.getByText('Test Page Title'))!.toBeInTheDocument()
})
it('should format usedTime to one decimal place', () => {
render()
- expect(screen.getByText(/1.6/)).toBeInTheDocument()
+ expect(screen.getByText(/1.6/))!.toBeInTheDocument()
})
})
})
@@ -571,13 +575,13 @@ describe('Crawling', () => {
it('should render without crashing', () => {
render()
- expect(screen.getByText(/5\/10/)).toBeInTheDocument()
+ expect(screen.getByText(/5\/10/))!.toBeInTheDocument()
})
it('should display crawled count and total', () => {
render()
- expect(screen.getByText(/3\/15/)).toBeInTheDocument()
+ expect(screen.getByText(/3\/15/))!.toBeInTheDocument()
})
it('should render skeleton items', () => {
@@ -602,19 +606,19 @@ describe('Crawling', () => {
,
)
- expect(container.firstChild).toHaveClass('custom-crawling-class')
+ expect(container.firstChild)!.toHaveClass('custom-crawling-class')
})
it('should handle zero values', () => {
render()
- expect(screen.getByText(/0\/0/)).toBeInTheDocument()
+ expect(screen.getByText(/0\/0/))!.toBeInTheDocument()
})
it('should handle large numbers', () => {
render()
- expect(screen.getByText(/999\/1000/)).toBeInTheDocument()
+ expect(screen.getByText(/999\/1000/))!.toBeInTheDocument()
})
})
@@ -623,9 +627,10 @@ describe('Crawling', () => {
const { container } = render()
// Assert - Check for various width classes
- expect(container.querySelector('.w-\\[35\\%\\]')).toBeInTheDocument()
- expect(container.querySelector('.w-\\[50\\%\\]')).toBeInTheDocument()
- expect(container.querySelector('.w-\\[40\\%\\]')).toBeInTheDocument()
+ // Assert - Check for various width classes
+ expect(container.querySelector('.w-\\[35\\%\\]'))!.toBeInTheDocument()
+ expect(container.querySelector('.w-\\[50\\%\\]'))!.toBeInTheDocument()
+ expect(container.querySelector('.w-\\[40\\%\\]'))!.toBeInTheDocument()
})
})
})
@@ -644,27 +649,27 @@ describe('ErrorMessage', () => {
it('should render without crashing', () => {
render()
- expect(screen.getByText('Error Title')).toBeInTheDocument()
+ expect(screen.getByText('Error Title'))!.toBeInTheDocument()
})
it('should render error icon', () => {
const { container } = render()
const icon = container.querySelector('svg')
- expect(icon).toBeInTheDocument()
- expect(icon).toHaveClass('text-text-destructive')
+ expect(icon)!.toBeInTheDocument()
+ expect(icon)!.toHaveClass('text-text-destructive')
})
it('should render title', () => {
render()
- expect(screen.getByText('Custom Error Title')).toBeInTheDocument()
+ expect(screen.getByText('Custom Error Title'))!.toBeInTheDocument()
})
it('should render error message when provided', () => {
render()
- expect(screen.getByText('Detailed error description')).toBeInTheDocument()
+ expect(screen.getByText('Detailed error description'))!.toBeInTheDocument()
})
it('should not render error message when not provided', () => {
@@ -682,14 +687,15 @@ describe('ErrorMessage', () => {
,
)
- expect(container.firstChild).toHaveClass('custom-error-class')
+ expect(container.firstChild)!.toHaveClass('custom-error-class')
})
it('should render with empty errorMsg', () => {
render()
// Assert - Empty string should not render message div
- expect(screen.getByText('Error Title')).toBeInTheDocument()
+ // Assert - Empty string should not render message div
+ expect(screen.getByText('Error Title'))!.toBeInTheDocument()
})
it('should handle long title text', () => {
@@ -697,7 +703,7 @@ describe('ErrorMessage', () => {
render()
- expect(screen.getByText(longTitle)).toBeInTheDocument()
+ expect(screen.getByText(longTitle))!.toBeInTheDocument()
})
it('should handle long error message', () => {
@@ -705,7 +711,7 @@ describe('ErrorMessage', () => {
render()
- expect(screen.getByText(longErrorMsg)).toBeInTheDocument()
+ expect(screen.getByText(longErrorMsg))!.toBeInTheDocument()
})
})
@@ -713,19 +719,19 @@ describe('ErrorMessage', () => {
it('should have error background styling', () => {
const { container } = render()
- expect(container.firstChild).toHaveClass('bg-toast-error-bg')
+ expect(container.firstChild)!.toHaveClass('bg-toast-error-bg')
})
it('should have border styling', () => {
const { container } = render()
- expect(container.firstChild).toHaveClass('border-components-panel-border')
+ expect(container.firstChild)!.toHaveClass('border-components-panel-border')
})
it('should have rounded-sm corners', () => {
const { container } = render()
- expect(container.firstChild).toHaveClass('rounded-xl')
+ expect(container.firstChild)!.toHaveClass('rounded-xl')
})
})
})
@@ -744,8 +750,9 @@ describe('Base Components Integration', () => {
)
// Assert - Both items should render
- expect(screen.getByText('Page 1')).toBeInTheDocument()
- expect(screen.getByText('Page 2')).toBeInTheDocument()
+ // Assert - Both items should render
+ expect(screen.getByText('Page 1'))!.toBeInTheDocument()
+ expect(screen.getByText('Page 2'))!.toBeInTheDocument()
})
it('should render CrawledResult with CheckboxWithLabel for select all', () => {
@@ -784,13 +791,13 @@ describe('Base Components Integration', () => {
// Act - Select first item (index 1, after select all)
const checkboxes = container.querySelectorAll('[data-testid^="checkbox"]')
- fireEvent.click(checkboxes[1])
+ fireEvent.click(checkboxes[1]!)
expect(mockOnSelectedChange).toHaveBeenCalledWith([list[0]])
// Act - Preview second item
const previewButtons = screen.getAllByRole('button')
- fireEvent.click(previewButtons[1])
+ fireEvent.click(previewButtons[1]!)
expect(mockOnPreview).toHaveBeenCalledWith(list[1], 1)
})
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/crawled-result-item.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/crawled-result-item.tsx
index 664a251e25..19019b4dd7 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/crawled-result-item.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/crawled-result-item.tsx
@@ -1,12 +1,12 @@
'use client'
import type { CrawlResultItem as CrawlResultItemType } from '@/models/datasets'
+import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import Checkbox from '@/app/components/base/checkbox'
import Radio from '@/app/components/base/radio/ui'
-import { Button } from '@/app/components/base/ui/button'
type CrawledResultItemProps = {
payload: CrawlResultItemType
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/crawled-result.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/crawled-result.tsx
index 8cd9a46054..b91c5bd6bc 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/crawled-result.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/crawled-result.tsx
@@ -59,7 +59,7 @@ const CrawledResult = ({
const handlePreview = useCallback((index: number) => {
if (!onPreview)
return
- onPreview(list[index], index)
+ onPreview(list[index]!, index)
}, [list, onPreview])
return (
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/options/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/options/__tests__/index.spec.tsx
index cea569fa5f..2ab8ad6d4b 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/options/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/options/__tests__/index.spec.tsx
@@ -10,8 +10,8 @@ const { mockToastError } = vi.hoisted(() => ({
mockToastError: vi.fn(),
}))
-vi.mock('@/app/components/base/ui/toast', async (importOriginal) => {
- const actual = await importOriginal()
+vi.mock('@langgenius/dify-ui/toast', async (importOriginal) => {
+ const actual = await importOriginal()
return {
...actual,
toast: {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/options/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/options/index.tsx
index 899c70e216..46c6c6f462 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/options/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/options/index.tsx
@@ -1,5 +1,7 @@
import type { RAGPipelineVariables } from '@/models/pipeline'
+import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
+import { toast } from '@langgenius/dify-ui/toast'
import { RiPlayLargeLine } from '@remixicon/react'
import { useBoolean } from 'ahooks'
import { useEffect, useMemo } from 'react'
@@ -8,8 +10,6 @@ import { useAppForm } from '@/app/components/base/form'
import BaseField from '@/app/components/base/form/form-scenarios/base/field'
import { generateZodSchema } from '@/app/components/base/form/form-scenarios/base/utils'
import { ArrowDownRoundFill } from '@/app/components/base/icons/src/vender/solid/general'
-import { Button } from '@/app/components/base/ui/button'
-import { toast } from '@/app/components/base/ui/toast'
import { useConfigurations, useInitialData } from '@/app/components/rag-pipeline/hooks/use-input-fields'
import { CrawlStep } from '@/models/datasets'
@@ -43,7 +43,7 @@ const Options = ({
if (!result.success) {
const issues = result.error.issues
const firstIssue = issues[0]
- const errorMessage = `"${firstIssue.path.join('.')}" ${firstIssue.message}`
+ const errorMessage = `"${firstIssue!.path.join('.')}" ${firstIssue!.message}`
toast.error(errorMessage)
return errorMessage
}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/hooks/__tests__/use-datasource-store.spec.ts b/web/app/components/datasets/documents/create-from-pipeline/hooks/__tests__/use-datasource-store.spec.ts
index 155b41541b..70d95000d7 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/hooks/__tests__/use-datasource-store.spec.ts
+++ b/web/app/components/datasets/documents/create-from-pipeline/hooks/__tests__/use-datasource-store.spec.ts
@@ -85,7 +85,7 @@ describe('useOnlineDocument', () => {
const { result } = renderHook(() => useOnlineDocument(), { wrapper: createWrapper(store) })
expect(result.current.PagesMapAndSelectedPagesId).toHaveProperty('p1')
- expect(result.current.PagesMapAndSelectedPagesId.p1.workspace_id).toBe('w1')
+ expect(result.current.PagesMapAndSelectedPagesId.p1!.workspace_id).toBe('w1')
})
it('should hide preview online document', () => {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/hooks/use-datasource-actions.ts b/web/app/components/datasets/documents/create-from-pipeline/hooks/use-datasource-actions.ts
index 66bd325c33..bad3b779fa 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/hooks/use-datasource-actions.ts
+++ b/web/app/components/datasets/documents/create-from-pipeline/hooks/use-datasource-actions.ts
@@ -251,7 +251,7 @@ export const useDatasourceActions = ({
if (datasourceType === DatasourceType.onlineDocument) {
const allIds = currentWorkspacePages?.map(page => page.page_id) || []
if (onlineDocuments.length < allIds.length) {
- const selectedPages = Array.from(allIds).map(pageId => PagesMapAndSelectedPagesId[pageId])
+ const selectedPages = Array.from(allIds).map(pageId => PagesMapAndSelectedPagesId[pageId]!)
setOnlineDocuments(selectedPages)
setSelectedPagesId(new Set(allIds))
}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/hooks/use-datasource-ui-state.ts b/web/app/components/datasets/documents/create-from-pipeline/hooks/use-datasource-ui-state.ts
index e398f90a48..f4c222f652 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/hooks/use-datasource-ui-state.ts
+++ b/web/app/components/datasets/documents/create-from-pipeline/hooks/use-datasource-ui-state.ts
@@ -122,7 +122,7 @@ export const useDatasourceUIState = ({
return {
datasourceType,
- isShowVectorSpaceFull,
+ isShowVectorSpaceFull: isShowVectorSpaceFull!,
nextBtnDisabled,
showSelect,
totalOptions,
diff --git a/web/app/components/datasets/documents/create-from-pipeline/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/index.tsx
index 62c1b919fe..8b8fad5885 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/index.tsx
@@ -133,7 +133,7 @@ const CreateFormPipeline = () => {
[DatasourceType.onlineDrive]: selectedFileIds.length,
}
const count = datasourceType ? multipleCheckMap[datasourceType] : 0
- if (count > 1) {
+ if (count! > 1) {
showPlanUpgradeModal()
return
}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/left-header.tsx b/web/app/components/datasets/documents/create-from-pipeline/left-header.tsx
index 925da57197..ab432d6962 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/left-header.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/left-header.tsx
@@ -1,8 +1,8 @@
import type { Step } from './step-indicator'
+import { Button } from '@langgenius/dify-ui/button'
import { RiArrowLeftLine } from '@remixicon/react'
import * as React from 'react'
import Effect from '@/app/components/base/effect'
-import { Button } from '@/app/components/base/ui/button'
import Link from '@/next/link'
import { useParams } from '@/next/navigation'
import StepIndicator from './step-indicator'
diff --git a/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/file-preview.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/file-preview.spec.tsx
index 715d1650df..82011102b6 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/file-preview.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/file-preview.spec.tsx
@@ -39,30 +39,30 @@ describe('FilePreview', () => {
it('should render preview label', () => {
render()
- expect(screen.getByText('datasetPipeline.addDocuments.stepOne.preview')).toBeInTheDocument()
+ expect(screen.getByText('datasetPipeline.addDocuments.stepOne.preview'))!.toBeInTheDocument()
})
it('should render file name', () => {
render()
- expect(screen.getByText('document.pdf')).toBeInTheDocument()
+ expect(screen.getByText('document.pdf'))!.toBeInTheDocument()
})
it('should render file content when loaded', () => {
render()
- expect(screen.getByText('file content here with some text')).toBeInTheDocument()
+ expect(screen.getByText('file content here with some text'))!.toBeInTheDocument()
})
it('should render loading state', () => {
mockIsFetching = true
render()
- expect(screen.getByTestId('loading')).toBeInTheDocument()
+ expect(screen.getByTestId('loading'))!.toBeInTheDocument()
})
it('should call hidePreview when close button clicked', () => {
render()
const buttons = screen.getAllByRole('button')
const closeBtn = buttons[buttons.length - 1]
- fireEvent.click(closeBtn)
+ fireEvent.click(closeBtn!)
expect(defaultProps.hidePreview).toHaveBeenCalled()
})
})
diff --git a/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/online-document-preview.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/online-document-preview.spec.tsx
index 1e094fedb0..96033a6f60 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/online-document-preview.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/online-document-preview.spec.tsx
@@ -9,8 +9,8 @@ const { mockToastError } = vi.hoisted(() => ({
mockToastError: vi.fn(),
}))
-vi.mock('@/app/components/base/ui/toast', async (importOriginal) => {
- const actual = await importOriginal()
+vi.mock('@langgenius/dify-ui/toast', async (importOriginal) => {
+ const actual = await importOriginal()
return {
...actual,
toast: {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/web-preview.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/web-preview.spec.tsx
index 1f59e11035..7bef4d0716 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/web-preview.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/web-preview.spec.tsx
@@ -20,29 +20,29 @@ describe('WebPreview', () => {
it('should render preview label', () => {
render()
- expect(screen.getByText('datasetPipeline.addDocuments.stepOne.preview')).toBeInTheDocument()
+ expect(screen.getByText('datasetPipeline.addDocuments.stepOne.preview'))!.toBeInTheDocument()
})
it('should render page title', () => {
render()
- expect(screen.getByText('Test Page')).toBeInTheDocument()
+ expect(screen.getByText('Test Page'))!.toBeInTheDocument()
})
it('should render source URL', () => {
render()
- expect(screen.getByText('https://example.com')).toBeInTheDocument()
+ expect(screen.getByText('https://example.com'))!.toBeInTheDocument()
})
it('should render markdown content', () => {
render()
- expect(screen.getByText('Hello **markdown** content')).toBeInTheDocument()
+ expect(screen.getByText('Hello **markdown** content'))!.toBeInTheDocument()
})
it('should call hidePreview when close button clicked', () => {
render()
const buttons = screen.getAllByRole('button')
const closeBtn = buttons[buttons.length - 1]
- fireEvent.click(closeBtn)
+ fireEvent.click(closeBtn!)
expect(defaultProps.hidePreview).toHaveBeenCalled()
})
})
diff --git a/web/app/components/datasets/documents/create-from-pipeline/preview/chunk-preview.tsx b/web/app/components/datasets/documents/create-from-pipeline/preview/chunk-preview.tsx
index a56e5bd6dc..9b56c6c8a3 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/preview/chunk-preview.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/preview/chunk-preview.tsx
@@ -1,13 +1,13 @@
import type { NotionPage } from '@/models/common'
import type { CrawlResultItem, CustomFile, DocumentItem, FileIndexingEstimateResponse } from '@/models/datasets'
import type { OnlineDriveFile } from '@/models/pipeline'
+import { Button } from '@langgenius/dify-ui/button'
import { RiSearchEyeLine } from '@remixicon/react'
import * as React from 'react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import Badge from '@/app/components/base/badge'
import { SkeletonContainer, SkeletonPoint, SkeletonRectangle, SkeletonRow } from '@/app/components/base/skeleton'
-import { Button } from '@/app/components/base/ui/button'
import SummaryLabel from '@/app/components/datasets/documents/detail/completed/common/summary-label'
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
import { ChunkingMode } from '@/models/datasets'
@@ -55,9 +55,9 @@ const ChunkPreview = ({
const currentDocForm = useDatasetDetailContextWithSelector(s => s.dataset?.doc_form)
const [previewFile, setPreviewFile] = useState(localFiles[0] as DocumentItem)
- const [previewOnlineDocument, setPreviewOnlineDocument] = useState(onlineDocuments[0])
- const [previewWebsitePage, setPreviewWebsitePage] = useState(websitePages[0])
- const [previewOnlineDriveFile, setPreviewOnlineDriveFile] = useState(onlineDriveFiles[0])
+ const [previewOnlineDocument, setPreviewOnlineDocument] = useState(onlineDocuments[0]!)
+ const [previewWebsitePage, setPreviewWebsitePage] = useState(websitePages[0]!)
+ const [previewOnlineDriveFile, setPreviewOnlineDriveFile] = useState(onlineDriveFiles[0]!)
return (
-
+
+
{t('addDocuments.stepOne.preview', { ns: 'datasetPipeline' })}
- {`${fileName}.${file.extension || ''}`}
-
+ {`${fileName}.${file.extension || ''}`}
+
)}
{!isFetching && fileData && (
-
+
{fileData.content}
)}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/preview/online-document-preview.tsx b/web/app/components/datasets/documents/create-from-pipeline/preview/online-document-preview.tsx
index ff2f9f46a4..793ba1f22b 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/preview/online-document-preview.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/preview/online-document-preview.tsx
@@ -1,12 +1,12 @@
'use client'
import type { NotionPage } from '@/models/common'
+import { toast } from '@langgenius/dify-ui/toast'
import { RiCloseLine } from '@remixicon/react'
import * as React from 'react'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Notion } from '@/app/components/base/icons/src/public/common'
import { Markdown } from '@/app/components/base/markdown'
-import { toast } from '@/app/components/base/ui/toast'
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
import { usePreviewOnlineDocument } from '@/service/use-pipeline'
import { formatNumberAbbreviated } from '@/utils/format'
@@ -50,12 +50,12 @@ const OnlineDocumentPreview = ({
}, [currentPage.page_id])
return (
-
-
+
+
{t('addDocuments.stepOne.preview', { ns: 'datasetPipeline' })}
- {currentPage?.page_name}
-
+ {currentPage?.page_name}
+
{currentPage.type}
·
@@ -76,7 +76,7 @@ const OnlineDocumentPreview = ({
)}
{!isPending && content && (
-
+
)}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/preview/web-preview.tsx b/web/app/components/datasets/documents/create-from-pipeline/preview/web-preview.tsx
index a527f12c0d..f83d68902f 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/preview/web-preview.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/preview/web-preview.tsx
@@ -17,12 +17,12 @@ const WebsitePreview = ({
const { t } = useTranslation()
return (
-
-
+
+
{t('addDocuments.stepOne.preview', { ns: 'datasetPipeline' })}
- {currentWebsite.title}
-
+ {currentWebsite.title}
+
{currentWebsite.source_url}
·
@@ -38,7 +38,7 @@ const WebsitePreview = ({
-
+
{currentWebsite.markdown}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/process-documents/__tests__/components.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/process-documents/__tests__/components.spec.tsx
index ff5f8afa66..16b6ef1373 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/process-documents/__tests__/components.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/process-documents/__tests__/components.spec.tsx
@@ -11,8 +11,8 @@ const { mockToastError } = vi.hoisted(() => ({
mockToastError: vi.fn(),
}))
-vi.mock('@/app/components/base/ui/toast', async (importOriginal) => {
- const actual = await importOriginal ()
+vi.mock('@langgenius/dify-ui/toast', async (importOriginal) => {
+ const actual = await importOriginal()
return {
...actual,
toast: {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/process-documents/__tests__/form.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/process-documents/__tests__/form.spec.tsx
index 09f28fc5da..dc54ba2757 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/process-documents/__tests__/form.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/process-documents/__tests__/form.spec.tsx
@@ -8,8 +8,8 @@ const { mockToastError } = vi.hoisted(() => ({
mockToastError: vi.fn(),
}))
-vi.mock('@/app/components/base/ui/toast', async (importOriginal) => {
- const actual = await importOriginal()
+vi.mock('@langgenius/dify-ui/toast', async (importOriginal) => {
+ const actual = await importOriginal()
return {
...actual,
toast: {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/process-documents/__tests__/header.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/process-documents/__tests__/header.spec.tsx
index 7e9eabaeda..431fa76f2c 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/process-documents/__tests__/header.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/process-documents/__tests__/header.spec.tsx
@@ -2,7 +2,7 @@ import { fireEvent, render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import Header from '../header'
-vi.mock('@/app/components/base/ui/button', () => ({
+vi.mock('@langgenius/dify-ui/button', () => ({
Button: ({ children, onClick, disabled, variant }: { children: React.ReactNode, onClick: () => void, disabled?: boolean, variant: string }) => (
|
{{ comment_content }}
+