fix: Prevent copying workflow when copying outside of canvas (#10813)

This commit is contained in:
Mutasem Aldmour
2024-09-16 12:27:44 +02:00
committed by GitHub
parent 3be31e27ed
commit 22c1890139
7 changed files with 349 additions and 0 deletions

View File

@@ -128,4 +128,24 @@ describe('AskAssistantChat', () => {
});
expect(container).toMatchSnapshot();
});
it('renders message with code snippet', () => {
const { container } = render(AskAssistantChat, {
props: {
user: { firstName: 'Kobi', lastName: 'Dog' },
messages: [
{
id: '1',
type: 'text',
role: 'assistant',
content:
'Hi Max! Here is my top solution to fix the error in your **Transform data** node👇',
codeSnippet:
"node.on('input', function(msg) {\n if (msg.seed) { dummyjson.seed = msg.seed; }\n try {\n var value = dummyjson.parse(node.template, {mockdata: msg});\n if (node.syntax === 'json') {\n try { value = JSON.parse(value); }\n catch(e) { node.error(RED._('datagen.errors.json-error')); }\n }\n if (node.fieldType === 'msg') {\n RED.util.setMessageProperty(msg,node.field,value);\n }\n else if (node.fieldType === 'flow') {\n node.context().flow.set(node.field,value);\n }\n else if (node.fieldType === 'global') {\n node.context().global.set(node.field,value);\n }\n node.send(msg);\n }\n catch(e) {",
read: false,
},
],
},
});
expect(container).toMatchSnapshot();
});
});