use base ui toast

This commit is contained in:
yyh
2026-03-25 20:38:44 +08:00
parent a7178b4d5c
commit 20dea1faa2
274 changed files with 3597 additions and 8129 deletions

View File

@ -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)