chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -27,7 +27,7 @@ import {
|
||||
|
||||
describe('with-query-client.tsx', () => {
|
||||
beforeEach(() => {
|
||||
// 清理 QueryClient 缓存
|
||||
// Clean up the QueryClient cache
|
||||
workflowQueryClient.clear();
|
||||
});
|
||||
|
||||
@@ -89,10 +89,10 @@ describe('with-query-client.tsx', () => {
|
||||
const WrappedComponent = withQueryClient(TestComponent);
|
||||
const { container } = render(<WrappedComponent />);
|
||||
|
||||
// 初始加载状态
|
||||
// initial loading state
|
||||
expect(container.innerHTML).toContain('Loading...');
|
||||
|
||||
// 等待数据加载完成
|
||||
// Wait for data loading to complete
|
||||
await waitFor(() => {
|
||||
expect(container.innerHTML).toContain('test data');
|
||||
});
|
||||
@@ -198,10 +198,10 @@ describe('with-query-client.tsx', () => {
|
||||
const WrappedComponent = withQueryClient(ParentComponent);
|
||||
const { container } = render(<WrappedComponent />);
|
||||
|
||||
// 初始加载状态
|
||||
// initial loading state
|
||||
expect(container.innerHTML).toContain('Loading Parent...');
|
||||
|
||||
// 等待所有查询完成
|
||||
// Wait for all queries to complete
|
||||
await waitFor(() => {
|
||||
expect(container.innerHTML).toContain('parent data');
|
||||
expect(container.innerHTML).toContain('child data');
|
||||
|
||||
@@ -28,7 +28,7 @@ vi.mock('../../src/entities', async () => {
|
||||
const actual = await vi.importActual('../../src/entities');
|
||||
return {
|
||||
...actual,
|
||||
// 如果需要mock其他实体,可以在这里添加
|
||||
// If you need to mock other entities, you can add them here.
|
||||
};
|
||||
});
|
||||
|
||||
@@ -198,7 +198,7 @@ describe('WorkflowNode', () => {
|
||||
const newData = { test: 'new data' };
|
||||
workflowNode.setData(newData);
|
||||
|
||||
// 验证原始数据没有被修改
|
||||
// Verify that the original data source has not been modified
|
||||
expect(newData).toEqual({ test: 'new data' });
|
||||
expect(mockFormItem.value).toEqual({ test: 'new data' });
|
||||
});
|
||||
|
||||
@@ -56,7 +56,7 @@ vi.mock('../../src/utils', () => ({
|
||||
describe('useNodeTestId', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
// 设置 concatTestId 的默认行为
|
||||
// Set the default behavior of concatTestId
|
||||
mockConcatTestId.mockImplementation((...args: string[]) => args.join('.'));
|
||||
});
|
||||
|
||||
@@ -99,8 +99,8 @@ describe('useNodeTestId', () => {
|
||||
it('应该返回正确的节点设置器 ID', () => {
|
||||
mockUseCurrentEntity.mockReturnValue({ id: '123' });
|
||||
mockConcatTestId
|
||||
.mockReturnValueOnce('playground.node.123') // 用于 getNodeTestId
|
||||
.mockReturnValueOnce('playground.node.123.llm'); // 用于 getNodeSetterId
|
||||
.mockReturnValueOnce('playground.node.123') // For getNodeTestId
|
||||
.mockReturnValueOnce('playground.node.123.llm'); // For getNodeSetterId
|
||||
|
||||
const { result } = renderHook(() => useNodeTestId());
|
||||
|
||||
@@ -140,7 +140,7 @@ describe('useNodeTestId', () => {
|
||||
});
|
||||
|
||||
it('应该在多个组件中返回不同的节点测试 ID', () => {
|
||||
// 第一个组件
|
||||
// The first component
|
||||
mockUseCurrentEntity.mockReturnValue({ id: '123' });
|
||||
mockConcatTestId.mockReturnValueOnce('playground.node.123');
|
||||
|
||||
@@ -148,7 +148,7 @@ describe('useNodeTestId', () => {
|
||||
expect(result1.current.getNodeTestId()).toBe('playground.node.123');
|
||||
expect(mockConcatTestId).toHaveBeenCalledWith('playground.node', '123');
|
||||
|
||||
// 第二个组件
|
||||
// The second component
|
||||
mockUseCurrentEntity.mockReturnValue({ id: '456' });
|
||||
mockConcatTestId.mockReturnValueOnce('playground.node.456');
|
||||
|
||||
@@ -158,11 +158,11 @@ describe('useNodeTestId', () => {
|
||||
});
|
||||
|
||||
it('应该在多个组件中返回不同的节点设置器 ID', () => {
|
||||
// 第一个组件
|
||||
// The first component
|
||||
mockUseCurrentEntity.mockReturnValue({ id: '123' });
|
||||
mockConcatTestId
|
||||
.mockReturnValueOnce('playground.node.123') // 用于 getNodeTestId
|
||||
.mockReturnValueOnce('playground.node.123.llm'); // 用于 getNodeSetterId
|
||||
.mockReturnValueOnce('playground.node.123') // For getNodeTestId
|
||||
.mockReturnValueOnce('playground.node.123.llm'); // For getNodeSetterId
|
||||
|
||||
const { result: result1 } = renderHook(() => useNodeTestId());
|
||||
expect(result1.current.getNodeSetterId('llm')).toBe(
|
||||
@@ -179,11 +179,11 @@ describe('useNodeTestId', () => {
|
||||
'llm',
|
||||
);
|
||||
|
||||
// 第二个组件
|
||||
// The second component
|
||||
mockUseCurrentEntity.mockReturnValue({ id: '456' });
|
||||
mockConcatTestId
|
||||
.mockReturnValueOnce('playground.node.456') // 用于 getNodeTestId
|
||||
.mockReturnValueOnce('playground.node.456.llm'); // 用于 getNodeSetterId
|
||||
.mockReturnValueOnce('playground.node.456') // For getNodeTestId
|
||||
.mockReturnValueOnce('playground.node.456.llm'); // For getNodeSetterId
|
||||
|
||||
const { result: result2 } = renderHook(() => useNodeTestId());
|
||||
expect(result2.current.getNodeSetterId('llm')).toBe(
|
||||
|
||||
@@ -22,7 +22,7 @@ import { useWorkflowStore } from '../../../src/store/workflow';
|
||||
|
||||
describe('useWorkflowStore', () => {
|
||||
beforeEach(() => {
|
||||
// 重置 store 状态
|
||||
// Reset store state
|
||||
useWorkflowStore.setState({
|
||||
nodes: [],
|
||||
edges: [],
|
||||
@@ -63,7 +63,7 @@ describe('useWorkflowStore', () => {
|
||||
});
|
||||
|
||||
it('应该能够重置为空数组', () => {
|
||||
// 先设置一些数据
|
||||
// Let's set up some data.
|
||||
useWorkflowStore.getState().setNodes([
|
||||
{
|
||||
id: '1',
|
||||
@@ -75,7 +75,7 @@ describe('useWorkflowStore', () => {
|
||||
},
|
||||
]);
|
||||
|
||||
// 设置为空数组
|
||||
// Set to empty array
|
||||
useWorkflowStore.getState().setNodes([]);
|
||||
expect(useWorkflowStore.getState().nodes).toEqual([]);
|
||||
});
|
||||
@@ -99,7 +99,7 @@ describe('useWorkflowStore', () => {
|
||||
});
|
||||
|
||||
it('应该能够重置为空数组', () => {
|
||||
// 先设置一些数据
|
||||
// Let's set up some data.
|
||||
useWorkflowStore.getState().setEdges([
|
||||
{
|
||||
sourceNodeID: '1',
|
||||
@@ -107,7 +107,7 @@ describe('useWorkflowStore', () => {
|
||||
},
|
||||
]);
|
||||
|
||||
// 设置为空数组
|
||||
// Set to empty array
|
||||
useWorkflowStore.getState().setEdges([]);
|
||||
expect(useWorkflowStore.getState().edges).toEqual([]);
|
||||
});
|
||||
@@ -115,11 +115,11 @@ describe('useWorkflowStore', () => {
|
||||
|
||||
describe('setIsCreatingWorkflow', () => {
|
||||
it('应该正确设置创建状态', () => {
|
||||
// 设置为 true
|
||||
// Set to true
|
||||
useWorkflowStore.getState().setIsCreatingWorkflow(true);
|
||||
expect(useWorkflowStore.getState().isCreatingWorkflow).toBe(true);
|
||||
|
||||
// 设置为 false
|
||||
// Set to false
|
||||
useWorkflowStore.getState().setIsCreatingWorkflow(false);
|
||||
expect(useWorkflowStore.getState().isCreatingWorkflow).toBe(false);
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
describe('node-type', () => {
|
||||
describe('StandardNodeType', () => {
|
||||
it('应该包含所有预定义的节点类型', () => {
|
||||
// 测试一些关键的节点类型
|
||||
// Test some key node types
|
||||
expect(StandardNodeType.Start).toBe('1');
|
||||
expect(StandardNodeType.End).toBe('2');
|
||||
expect(StandardNodeType.LLM).toBe('3');
|
||||
|
||||
@@ -29,7 +29,7 @@ describe('is-general-workflow', () => {
|
||||
});
|
||||
|
||||
it('应该在 flowMode 为其他值时返回 false', () => {
|
||||
// 测试其他可能的 WorkflowMode 值
|
||||
// Test other possible WorkflowMode values
|
||||
expect(isGeneralWorkflow(WorkflowMode.Imageflow)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,17 +27,17 @@ vi.mock('@coze-arch/bot-utils', () => ({
|
||||
typeSafeJSONParse: (str: string) => {
|
||||
try {
|
||||
const result = JSON.parse(str);
|
||||
// 如果是批处理数据,确保返回数组类型
|
||||
// If it is batch data, make sure to return an array type
|
||||
if (str === 'invalid json') {
|
||||
return str;
|
||||
}
|
||||
// 如果是批处理数据,确保返回数组类型
|
||||
// If it is batch data, make sure to return an array type
|
||||
if (str.includes('batch')) {
|
||||
return Array.isArray(result) ? result : [];
|
||||
}
|
||||
return result;
|
||||
} catch {
|
||||
// 如果是批处理数据,返回空数组
|
||||
// If it is batch data, return an empty array
|
||||
if (str.includes('batch')) {
|
||||
return [];
|
||||
}
|
||||
@@ -110,7 +110,7 @@ describe('default-parser', () => {
|
||||
expect(result.nodeType).toBe(StandardNodeType.LLM);
|
||||
expect(result.isBatch).toBe(false);
|
||||
expect(result.caseResult).toHaveLength(1);
|
||||
expect(result.caseResult?.[0].dataList).toHaveLength(3); // 输入、原始输出、最终输出
|
||||
expect(result.caseResult?.[0].dataList).toHaveLength(3); // Input, original output, final output
|
||||
});
|
||||
|
||||
it('应该正确解析 Code 节点结果', () => {
|
||||
@@ -122,7 +122,7 @@ describe('default-parser', () => {
|
||||
const result = defaultParser(nodeResult, workflowSchema);
|
||||
|
||||
expect(result.nodeType).toBe(StandardNodeType.Code);
|
||||
expect(result.caseResult?.[0].dataList).toHaveLength(3); // 输入、原始输出、最终输出
|
||||
expect(result.caseResult?.[0].dataList).toHaveLength(3); // Input, original output, final output
|
||||
});
|
||||
|
||||
it('应该正确解析 Start 节点结果', () => {
|
||||
@@ -134,7 +134,7 @@ describe('default-parser', () => {
|
||||
const result = defaultParser(nodeResult, workflowSchema);
|
||||
|
||||
expect(result.nodeType).toBe(StandardNodeType.Start);
|
||||
expect(result.caseResult?.[0].dataList).toHaveLength(1); // 只有输入
|
||||
expect(result.caseResult?.[0].dataList).toHaveLength(1); // input only
|
||||
});
|
||||
|
||||
it('应该正确解析 End 节点结果', () => {
|
||||
@@ -154,7 +154,7 @@ describe('default-parser', () => {
|
||||
const result = defaultParser(nodeResult, workflowSchema);
|
||||
|
||||
expect(result.nodeType).toBe(StandardNodeType.End);
|
||||
expect(result.caseResult?.[0].dataList).toHaveLength(2); // 输出变量、回答内容
|
||||
expect(result.caseResult?.[0].dataList).toHaveLength(2); // Output variables, answer content
|
||||
});
|
||||
|
||||
it('应该正确解析 Message 节点结果', () => {
|
||||
@@ -166,7 +166,7 @@ describe('default-parser', () => {
|
||||
const result = defaultParser(nodeResult, workflowSchema);
|
||||
|
||||
expect(result.nodeType).toBe(StandardNodeType.Output);
|
||||
expect(result.caseResult?.[0].dataList).toHaveLength(2); // 输出变量、回答内容
|
||||
expect(result.caseResult?.[0].dataList).toHaveLength(2); // Output variables, answer content
|
||||
});
|
||||
|
||||
it('应该正确解析包含图片的输出', () => {
|
||||
@@ -256,7 +256,7 @@ describe('default-parser', () => {
|
||||
|
||||
it('应该正确处理 Text 节点的原始输出', () => {
|
||||
const nodeResult = createMockNodeResult('1', {
|
||||
raw_output: '{"key": "value"}', // 即使是有效的 JSON 字符串也应该保持原样
|
||||
raw_output: '{"key": "value"}', // Even valid JSON strings should remain intact
|
||||
});
|
||||
const workflowSchema = createMockWorkflowSchema(
|
||||
'1',
|
||||
@@ -272,7 +272,7 @@ describe('default-parser', () => {
|
||||
|
||||
it('应该正确处理不存在的节点类型', () => {
|
||||
const nodeResult = createMockNodeResult('1');
|
||||
const workflowSchema = createMockWorkflowSchema('2'); // 不同的节点 ID
|
||||
const workflowSchema = createMockWorkflowSchema('2'); // Different node IDs
|
||||
const result = defaultParser(nodeResult, workflowSchema);
|
||||
|
||||
expect(result.nodeType).toBeUndefined();
|
||||
|
||||
@@ -184,7 +184,7 @@ describe('ref-input-parameters-parser', () => {
|
||||
param4: undefined,
|
||||
param5: {
|
||||
type: 'string',
|
||||
value: {}, // 空的 value 对象
|
||||
value: {}, // Empty value object
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user