refactor(web): migrate to Vitest and esm (#29974)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
This commit is contained in:
Stephen Zhou
2025-12-22 16:35:22 +08:00
committed by GitHub
parent 42f7ecda12
commit eabdc5f0eb
268 changed files with 5455 additions and 6307 deletions

View File

@ -3,9 +3,9 @@ import StepThree from './index'
import type { FullDocumentDetail, IconInfo, createDocumentResponse } from '@/models/datasets'
// Mock the EmbeddingProcess component since it has complex async logic
jest.mock('../embedding-process', () => ({
vi.mock('../embedding-process', () => ({
__esModule: true,
default: jest.fn(({ datasetId, batchId, documents, indexingType, retrievalMethod }) => (
default: vi.fn(({ datasetId, batchId, documents, indexingType, retrievalMethod }) => (
<div data-testid="embedding-process">
<span data-testid="ep-dataset-id">{datasetId}</span>
<span data-testid="ep-batch-id">{batchId}</span>
@ -18,18 +18,18 @@ jest.mock('../embedding-process', () => ({
// Mock useBreakpoints hook
let mockMediaType = 'pc'
jest.mock('@/hooks/use-breakpoints', () => ({
vi.mock('@/hooks/use-breakpoints', () => ({
__esModule: true,
MediaType: {
mobile: 'mobile',
tablet: 'tablet',
pc: 'pc',
},
default: jest.fn(() => mockMediaType),
default: vi.fn(() => mockMediaType),
}))
// Mock useDocLink hook
jest.mock('@/context/i18n', () => ({
vi.mock('@/context/i18n', () => ({
useDocLink: () => (path?: string) => `https://docs.dify.ai/en-US${path || ''}`,
}))
@ -104,7 +104,7 @@ const renderStepThree = (props: Partial<Parameters<typeof StepThree>[0]> = {}) =
// ============================================================================
describe('StepThree', () => {
beforeEach(() => {
jest.clearAllMocks()
vi.clearAllMocks()
mockMediaType = 'pc'
})