refactor: route next/navigation through compat re-export (#33636)

This commit is contained in:
yyh
2026-03-18 12:57:03 +08:00
committed by GitHub
parent 04c0bf61fa
commit 296b7044af
269 changed files with 320 additions and 328 deletions

View File

@ -90,7 +90,7 @@ vi.mock('@/app/components/base/amplitude', () => ({
trackEvent: vi.fn(),
}))
vi.mock('next/navigation', () => ({
vi.mock('@/next/navigation', () => ({
useParams: () => ({ datasetId: 'test-dataset-id' }),
useRouter: () => ({
push: vi.fn(),

View File

@ -3,7 +3,7 @@ import { render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import LeftHeader from '../left-header'
vi.mock('next/navigation', () => ({
vi.mock('@/next/navigation', () => ({
useParams: () => ({ datasetId: 'test-ds-id' }),
}))

View File

@ -4,7 +4,7 @@ import Actions from '../index'
// Mock next/navigation - useParams returns datasetId
const mockDatasetId = 'test-dataset-id'
vi.mock('next/navigation', () => ({
vi.mock('@/next/navigation', () => ({
useParams: () => ({ datasetId: mockDatasetId }),
}))

View File

@ -1,11 +1,11 @@
import { RiArrowRightLine } from '@remixicon/react'
import { useParams } from 'next/navigation'
import * as React from 'react'
import { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button'
import Checkbox from '@/app/components/base/checkbox'
import Link from '@/next/link'
import { useParams } from '@/next/navigation'
type ActionsProps = {
disabled?: boolean

View File

@ -26,7 +26,7 @@ vi.mock('@/app/components/datasets/common/document-file-icon', () => ({
}))
// Mock SimplePieChart
vi.mock('next/dynamic', () => ({
vi.mock('@/next/dynamic', () => ({
default: () => {
const Component = ({ percentage }: { percentage: number }) => (
<div data-testid="pie-chart">

View File

@ -17,7 +17,7 @@ vi.mock('@/types/app', () => ({
}))
// Mock SimplePieChart with dynamic import handling
vi.mock('next/dynamic', () => ({
vi.mock('@/next/dynamic', () => ({
default: () => {
const DynamicComponent = ({ percentage, stroke, fill }: { percentage: number, stroke: string, fill: string }) => (
<div data-testid="pie-chart" data-percentage={percentage} data-stroke={stroke} data-fill={fill}>

View File

@ -1,10 +1,10 @@
import type { Step } from './step-indicator'
import { RiArrowLeftLine } from '@remixicon/react'
import { useParams } from 'next/navigation'
import * as React from 'react'
import Button from '@/app/components/base/button'
import Effect from '@/app/components/base/effect'
import Link from '@/next/link'
import { useParams } from '@/next/navigation'
import StepIndicator from './step-indicator'
type LeftHeaderProps = {

View File

@ -10,7 +10,7 @@ import { RETRIEVE_METHOD } from '@/types/app'
import EmbeddingProcess from '../index'
const mockPush = vi.fn()
vi.mock('next/navigation', () => ({
vi.mock('@/next/navigation', () => ({
useRouter: () => ({
push: mockPush,
}),

View File

@ -10,7 +10,6 @@ import {
RiLoader2Fill,
RiTerminalBoxLine,
} from '@remixicon/react'
import { useRouter } from 'next/navigation'
import * as React from 'react'
import { useEffect, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
@ -26,6 +25,7 @@ import { useProviderContext } from '@/context/provider-context'
import { useDatasetApiAccessUrl } from '@/hooks/use-api-access-url'
import { DatasourceType } from '@/models/pipeline'
import Link from '@/next/link'
import { useRouter } from '@/next/navigation'
import { useIndexingStatusBatch, useProcessRule } from '@/service/knowledge/use-dataset'
import { useInvalidDocumentList } from '@/service/knowledge/use-document'
import { cn } from '@/utils/classnames'

View File

@ -143,7 +143,7 @@ vi.mock('@/service/base', () => ({
upload: vi.fn().mockResolvedValue({ id: 'uploaded-file-id' }),
}))
vi.mock('next/navigation', () => ({
vi.mock('@/next/navigation', () => ({
useParams: () => ({ datasetId: 'mock-dataset-id' }),
useRouter: () => ({ push: vi.fn() }),
usePathname: () => '/datasets/mock-dataset-id',