refactor(tests): update toast mock implementation to use new UI toast structure

This commit is contained in:
CodingOnStar 2026-03-25 13:59:52 +08:00
parent c494f80452
commit 74e5ac4153
2 changed files with 15 additions and 5 deletions

View File

@ -39,10 +39,13 @@ vi.mock('@/app/components/base/button', () => ({
),
}))
vi.mock('@/app/components/base/toast', () => ({
vi.mock('@/app/components/base/ui/toast', () => ({
__esModule: true,
default: {
notify: (...args: unknown[]) => mockNotify(...args),
toast: {
success: (message: string) => mockNotify({ type: 'success', message }),
error: (message: string) => mockNotify({ type: 'error', message }),
warning: (message: string) => mockNotify({ type: 'warning', message }),
info: (message: string) => mockNotify({ type: 'info', message }),
},
}))

View File

@ -1,7 +1,6 @@
import type { StartNodeType } from '../types'
import type { InputVar, ValueSelector } from '@/app/components/workflow/types'
import { act, renderHook } from '@testing-library/react'
import Toast from '@/app/components/base/toast'
import { BlockEnum, ChangeType, InputVarType } from '@/app/components/workflow/types'
import useConfig from '../use-config'
@ -11,6 +10,7 @@ const mockUseWorkflow = vi.hoisted(() => vi.fn())
const mockUseIsChatMode = vi.hoisted(() => vi.fn())
const mockUseNodeCrud = vi.hoisted(() => vi.fn())
const mockUseInspectVarsCrud = vi.hoisted(() => vi.fn())
const mockNotify = vi.hoisted(() => vi.fn())
vi.mock('react-i18next', () => ({
useTranslation: () => mockUseTranslation(),
@ -32,6 +32,13 @@ vi.mock('@/app/components/workflow/hooks/use-inspect-vars-crud', () => ({
default: (...args: unknown[]) => mockUseInspectVarsCrud(...args),
}))
vi.mock('@/app/components/base/ui/toast', () => ({
__esModule: true,
toast: {
error: (message: string) => mockNotify({ type: 'error', message }),
},
}))
const createInputVar = (overrides: Partial<InputVar> = {}): InputVar => ({
label: 'Question',
variable: 'query',
@ -64,7 +71,7 @@ describe('start/use-config', () => {
const mockDeleteNodeInspectorVars = vi.fn()
const mockRenameInspectVarName = vi.fn()
const mockDeleteInspectVar = vi.fn()
const toastSpy = vi.spyOn(Toast, 'notify').mockImplementation(() => ({}))
const toastSpy = mockNotify
let currentInputs: StartNodeType
beforeEach(() => {