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

@ -16,7 +16,7 @@ import {
const mockPush = vi.fn()
const mockRouter = { push: mockPush }
vi.mock('next/navigation', () => ({
vi.mock('@/next/navigation', () => ({
useRouter: () => mockRouter,
}))

View File

@ -6,7 +6,6 @@ import {
RiLoader2Fill,
RiTerminalBoxLine,
} from '@remixicon/react'
import { useRouter } from 'next/navigation'
import { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button'
@ -15,6 +14,7 @@ import { Plan } from '@/app/components/billing/type'
import { useProviderContext } from '@/context/provider-context'
import { useDatasetApiAccessUrl } from '@/hooks/use-api-access-url'
import Link from '@/next/link'
import { useRouter } from '@/next/navigation'
import { useProcessRule } from '@/service/knowledge/use-dataset'
import { useInvalidDocumentList } from '@/service/knowledge/use-document'
import IndexingProgressItem from './indexing-progress-item'

View File

@ -7,7 +7,7 @@ import EmptyDatasetCreationModal from '../index'
// Mock Next.js router
const mockPush = vi.fn()
vi.mock('next/navigation', () => ({
vi.mock('@/next/navigation', () => ({
useRouter: () => ({
push: mockPush,
}),

View File

@ -1,5 +1,4 @@
'use client'
import { useRouter } from 'next/navigation'
import * as React from 'react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
@ -9,6 +8,7 @@ import Button from '@/app/components/base/button'
import Input from '@/app/components/base/input'
import Modal from '@/app/components/base/modal'
import { ToastContext } from '@/app/components/base/toast/context'
import { useRouter } from '@/next/navigation'
import { createEmptyDataset } from '@/service/datasets'
import { useInvalidDatasetList } from '@/service/knowledge/use-dataset'

View File

@ -58,7 +58,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}>