mirror of
https://github.com/langgenius/dify.git
synced 2026-04-27 05:58:14 +08:00
use base ui toast
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import type { FileUploadConfigResponse } from '@/models/common'
|
||||
import type { VarInInspect } from '@/types/workflow'
|
||||
import { fireEvent, render, screen } from '@testing-library/react'
|
||||
import { ToastContext } from '@/app/components/base/toast/context'
|
||||
import { VarType } from '@/app/components/workflow/types'
|
||||
import { VarInInspectType } from '@/types/workflow'
|
||||
import {
|
||||
@ -12,6 +11,20 @@ import {
|
||||
TextEditorSection,
|
||||
} from '../value-content-sections'
|
||||
|
||||
const mockToast = Object.assign(vi.fn(), {
|
||||
success: vi.fn(),
|
||||
error: vi.fn(),
|
||||
warning: vi.fn(),
|
||||
info: vi.fn(),
|
||||
dismiss: vi.fn(),
|
||||
update: vi.fn(),
|
||||
promise: vi.fn(),
|
||||
})
|
||||
|
||||
vi.mock('@/app/components/base/ui/toast', () => ({
|
||||
toast: mockToast,
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/workflow/nodes/llm/components/json-schema-config-modal/schema-editor', () => ({
|
||||
default: ({ schema, onUpdate }: { schema: string, onUpdate: (value: string) => void }) => (
|
||||
<textarea data-testid="schema-editor" value={schema} onChange={event => onUpdate(event.target.value)} />
|
||||
@ -127,15 +140,13 @@ describe('value-content sections', () => {
|
||||
|
||||
it('should render the file editor section', () => {
|
||||
render(
|
||||
<ToastContext.Provider value={{ notify: vi.fn(), close: vi.fn() }}>
|
||||
<FileEditorSection
|
||||
currentVar={createVar({ name: 'files', value_type: VarType.file })}
|
||||
fileValue={[]}
|
||||
fileUploadConfig={createFileUploadConfig()}
|
||||
textEditorDisabled={false}
|
||||
onChange={vi.fn()}
|
||||
/>
|
||||
</ToastContext.Provider>,
|
||||
<FileEditorSection
|
||||
currentVar={createVar({ name: 'files', value_type: VarType.file })}
|
||||
fileValue={[]}
|
||||
fileUploadConfig={createFileUploadConfig()}
|
||||
textEditorDisabled={false}
|
||||
onChange={vi.fn()}
|
||||
/>,
|
||||
)
|
||||
|
||||
expect(screen.getAllByRole('button').length).toBeGreaterThan(0)
|
||||
|
||||
Reference in New Issue
Block a user