mirror of
https://github.com/langgenius/dify.git
synced 2026-05-09 12:59:18 +08:00
refactor(tests): update toast mock implementation to use new UI toast structure
This commit is contained in:
parent
c494f80452
commit
74e5ac4153
@ -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 }),
|
||||
},
|
||||
}))
|
||||
|
||||
|
||||
@ -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(() => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user