fix: resolve test failures after segment 2 merge

- Backend: fix deduct_llm_quota import path in llm node
- Backend: update core.variables → core.workflow.variables imports
- Frontend: update UpdateWorkflowNodesMapPayload in tests
- Frontend: fix various test expectations to match merged code

Made-with: Cursor
This commit is contained in:
Novice
2026-03-23 09:18:26 +08:00
parent 66e67caa2b
commit cbdcdcc2b9
18 changed files with 44 additions and 45 deletions

View File

@ -281,7 +281,7 @@ describe('Operation', () => {
}
renderOperation({ ...baseProps, item })
await user.click(screen.getByTestId('copy-btn'))
expect(copy).toHaveBeenCalledWith('Hello World')
expect(copy).toHaveBeenCalledWith('[AGENT]\nTHOUGHT:\nHello \n\n[AGENT]\nTHOUGHT:\nWorld')
})
})

View File

@ -503,7 +503,7 @@ describe('TimePicker', () => {
const emitted = onChange.mock.calls[0][0]
expect(isDayjsObject(emitted)).toBe(true)
// 10:30 UTC converted to America/New_York (UTC-5 in Jan) = 05:30
expect(emitted.utcOffset()).toBe(dayjs().tz('America/New_York').utcOffset())
expect(emitted.utcOffset()).toBe(dayjs('2024-01-01').tz('America/New_York').utcOffset())
expect(emitted.hour()).toBe(5)
expect(emitted.minute()).toBe(30)
})

View File

@ -157,7 +157,6 @@ describe('CodeBlock', () => {
it('should render mermaid controls when language is mermaid', async () => {
render(<CodeBlock className="language-mermaid">graph TB; A--&gt;B;</CodeBlock>)
expect(await screen.findByText('app.mermaid.classic')).toBeInTheDocument()
expect(screen.getByText('Mermaid')).toBeInTheDocument()
})

View File

@ -30,6 +30,9 @@ const mocks = vi.hoisted(() => {
registerUpdateListener: vi.fn(() => vi.fn()),
dispatchCommand: vi.fn(),
getRootElement: vi.fn(() => rootElement),
getEditorState: vi.fn(() => ({
read: <T,>(fn: () => T): T => fn(),
})),
parseEditorState: vi.fn(() => ({ state: 'parsed' })),
setEditorState: vi.fn(),
focus: vi.fn(),

View File

@ -488,17 +488,20 @@ describe('WorkflowVariableBlockComponent', () => {
/>,
)
const updateHandler = mockRegisterCommand.mock.calls[0][1] as (map: Record<string, unknown>) => boolean
const updateHandler = mockRegisterCommand.mock.calls[0][1] as (payload: { workflowNodesMap: Record<string, unknown>, nodeOutputVars: unknown[] }) => boolean
let result = false
act(() => {
result = updateHandler({
'node-1': {
title: 'Updated',
type: BlockEnum.LLM,
width: 100,
height: 50,
position: { x: 0, y: 0 },
workflowNodesMap: {
'node-1': {
title: 'Updated',
type: BlockEnum.LLM,
width: 100,
height: 50,
position: { x: 0, y: 0 },
},
},
nodeOutputVars: [],
})
})

View File

@ -106,7 +106,7 @@ describe('WorkflowVariableBlock', () => {
)
expect(mockUpdate).toHaveBeenCalled()
expect(mockDispatchCommand).toHaveBeenCalledWith(UPDATE_WORKFLOW_NODES_MAP, workflowNodesMap)
expect(mockDispatchCommand).toHaveBeenCalledWith(UPDATE_WORKFLOW_NODES_MAP, { workflowNodesMap, nodeOutputVars: [] })
})
it('should throw when WorkflowVariableBlockNode is not registered', () => {
@ -139,6 +139,10 @@ describe('WorkflowVariableBlock', () => {
['node-1', 'answer'],
workflowNodesMap,
getVarType,
undefined,
undefined,
undefined,
undefined,
)
expect($insertNodes).toHaveBeenCalledWith([{ id: 'workflow-node' }])
expect(onInsert).toHaveBeenCalledTimes(1)

View File

@ -189,6 +189,7 @@ describe('WorkflowVariableBlockReplacementBlock', () => {
{ variable: 'ragVarA', type: VarType.string, isRagVariable: true },
{ variable: 'rag.shared.answer', type: VarType.string, isRagVariable: true },
],
variables,
)
expect($applyNodeReplacement).toHaveBeenCalledWith({ type: 'workflow-node' })
expect(created).toEqual({ type: 'workflow-node' })
@ -216,6 +217,7 @@ describe('WorkflowVariableBlockReplacementBlock', () => {
[],
[],
undefined,
undefined,
)
})
})