feat: 优化代码节点 main 编写体验

- 更新代码节点帮助、占位示例与补全片段

- 保留 _result 旧版兼容提示并补充补全测试
This commit is contained in:
2026-07-30 17:34:56 +08:00
parent 9959f95b94
commit 2abff304ed
3 changed files with 43 additions and 14 deletions

View File

@@ -52,6 +52,25 @@ describe('codeCompletion utils', () => {
).toBe(true);
});
it('should prefer main return snippets for javascript output', () => {
const completions = createBusinessCompletions('javascript', []);
const mainCompletion = completions.find((item) => item.label === 'main');
const resultCompletion = completions.find(
(item) => item.label === 'result-object',
);
expect(mainCompletion).toMatchObject({
type: 'snippet',
detail: '代码节点入口',
boost: 1000,
});
expect(String(mainCompletion?.apply)).toContain('function main');
expect(String(mainCompletion?.apply)).toContain('return {');
expect(String(resultCompletion?.apply)).toBe(
"return { message: 'ok', data };",
);
});
it('should detect blocked nodes for comment/string/property contexts', () => {
expect(shouldSkipBusinessCompletion('Comment')).toBe(true);
expect(shouldSkipBusinessCompletion('LineComment')).toBe(true);