mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-16 08:01:18 +00:00

* fix(api): 修复二级路由下的页面判断逻辑 在请求错误处理中,添加基础URL前缀以正确判断当前是否为外部链接页面。 * perf: use global var * remove invalid code * feat: response limit;perf: copy avatar image;perf: markdown parse (#5719) * feat: response limit * remove placeholder * perf: copy avatar image * perf: markdown parse * fix: child app cannot show cite * doc * fix: node template bugs (#5727) * add dataset search count track (#5721) * add dataset search count track * remove pro * change to track * remove unused * fix * perf: track code --------- Co-authored-by: archer <545436317@qq.com> * http response limit * deploy doc * fix: test * doc * remove invalid code * remove invalid code --------- Co-authored-by: 戴盛利 <1639499287@qq.com> Co-authored-by: heheer <heheer@sealos.io>
87 lines
2.4 KiB
TypeScript
87 lines
2.4 KiB
TypeScript
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node';
|
|
import { storeNode2FlowNode } from '@/web/core/workflow/utils';
|
|
import type { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
|
|
|
|
describe('storeNode2FlowNode with deprecated inputs/outputs', () => {
|
|
beforeEach(() => {
|
|
vi.mock('@fastgpt/global/core/workflow/template/constants', () => {
|
|
return {
|
|
moduleTemplatesFlat: [
|
|
{
|
|
flowNodeType: 'userInput',
|
|
name: 'User Input',
|
|
avatar: '',
|
|
intro: '',
|
|
version: '1.0',
|
|
inputs: [
|
|
{
|
|
key: 'deprecatedInput',
|
|
deprecated: true,
|
|
label: 'Deprecated Input',
|
|
renderTypeList: ['input'],
|
|
selectedTypeIndex: 0
|
|
}
|
|
],
|
|
outputs: [
|
|
{
|
|
key: 'deprecatedOutput',
|
|
id: 'deprecatedId',
|
|
type: 'input',
|
|
deprecated: true,
|
|
label: 'Deprecated Output'
|
|
}
|
|
]
|
|
}
|
|
]
|
|
};
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
vi.resetAllMocks();
|
|
vi.resetModules();
|
|
});
|
|
|
|
it('should handle deprecated inputs and outputs', () => {
|
|
const storeNode = {
|
|
nodeId: 'node1',
|
|
flowNodeType: 'userInput' as FlowNodeTypeEnum,
|
|
position: { x: 0, y: 0 },
|
|
inputs: [
|
|
{
|
|
key: 'deprecatedInput',
|
|
value: 'old value',
|
|
renderTypeList: ['input'],
|
|
label: 'Deprecated Input'
|
|
}
|
|
],
|
|
outputs: [
|
|
{
|
|
key: 'deprecatedOutput',
|
|
id: 'deprecatedId',
|
|
type: 'input',
|
|
label: 'Deprecated Output'
|
|
}
|
|
],
|
|
name: 'Test Node',
|
|
version: '1.0'
|
|
};
|
|
|
|
const result = storeNode2FlowNode({
|
|
item: storeNode as any,
|
|
t: ((key: any) => key) as any
|
|
});
|
|
|
|
const deprecatedInput = result.data.inputs.find((input) => input.key === 'deprecatedInput');
|
|
expect(deprecatedInput).toBeDefined();
|
|
expect(deprecatedInput?.deprecated).toBe(undefined);
|
|
|
|
const deprecatedOutput = result.data.outputs.find(
|
|
(output) => output.key === 'deprecatedOutput'
|
|
);
|
|
expect(deprecatedOutput).toBeDefined();
|
|
expect(deprecatedOutput?.deprecated).toBe(true);
|
|
});
|
|
});
|