fix(Code Node): Ensure 'Generate Code' works with empty input object (#14352)

This commit is contained in:
Charlie Kolb
2025-04-04 11:24:27 +02:00
committed by GitHub
parent 0bac6ffac6
commit 480b44d024
2 changed files with 9 additions and 4 deletions

View File

@@ -167,8 +167,9 @@ return []
const askAiReq = cy.wait('@ask-ai'); const askAiReq = cy.wait('@ask-ai');
askAiReq.its('request.body').should('have.keys', ['question', 'context', 'forNode']); askAiReq.its('request.body').should('have.keys', ['question', 'context', 'forNode']);
askAiReq
askAiReq.its('context').should('have.keys', ['schema', 'ndvPushRef', 'pushRef']); .its('context')
.should('have.keys', ['schema', 'ndvPushRef', 'pushRef', 'inputSchema']);
cy.contains('Code generation completed').should('be.visible'); cy.contains('Code generation completed').should('be.visible');
cy.getByTestId('code-node-tab-code').should('contain.text', 'console.log("Hello World")'); cy.getByTestId('code-node-tab-code').should('contain.text', 'console.log("Hello World")');

View File

@@ -106,7 +106,11 @@ function getSchemas() {
}) })
.filter((node) => node.schema?.value.length > 0); .filter((node) => node.schema?.value.length > 0);
const inputSchema = parentNodesSchemas.shift(); // Account for empty objects
const inputSchema = parentNodesSchemas.shift() ?? {
nodeName: parentNodesNames[0] ?? '',
schema: { path: '', type: 'undefined', value: '' },
};
return { return {
parentNodesNames, parentNodesNames,
@@ -161,7 +165,7 @@ async function onSubmit() {
question: prompt.value, question: prompt.value,
context: { context: {
schema: schemas.parentNodesSchemas, schema: schemas.parentNodesSchemas,
inputSchema: schemas.inputSchema!, inputSchema: schemas.inputSchema,
ndvPushRef: useNDVStore().pushRef, ndvPushRef: useNDVStore().pushRef,
pushRef: rootStore.pushRef, pushRef: rootStore.pushRef,
}, },