Skip to content

Commit

Permalink
fix: Add template id to workflows created from templates (no-changelo…
Browse files Browse the repository at this point in the history
…g) (#8226)

In #8088 template ID was added to workflow metadata, but it was missing
from workflows that were created using the template credential setup.
This fixes that.
  • Loading branch information
tomi authored Jan 5, 2024
1 parent 071e6d6 commit 8a78ae1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 16 additions & 0 deletions cypress/e2e/34-template-credentials-setup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ describe('Template credentials setup', () => {
cy.wait('@createWorkflow');

workflowPage.getters.canvasNodes().should('have.length', 3);

// Focus the canvas so the copy to clipboard works
workflowPage.getters.canvasNodes().eq(0).realClick();
workflowPage.actions.selectAll();
workflowPage.actions.hitCopy();

cy.grantBrowserPermissions('clipboardReadWrite', 'clipboardSanitizedWrite');
// Check workflow JSON by copying it to clipboard
cy.readClipboard().then((workflowJSON) => {
const workflow = JSON.parse(workflowJSON);

expect(workflow.meta).to.haveOwnProperty('templateId', testTemplate.id.toString());
workflow.nodes.forEach((node: any) => {
expect(Object.keys(node.credentials ?? {})).to.have.lengthOf(1);
});
});
});

it('should work with a template that has no credentials (ADO-1603)', () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/editor-ui/src/utils/templates/templateActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export async function createWorkflowFromTemplate(opts: {
nodes,
connections,
active: false,
// Ignored: pinData, settings, tags, versionId, meta
meta: {
templateId: template.id.toString(),
},
// Ignored: pinData, settings, tags, versionId
};

const createdWorkflow = await workflowsStore.createNewWorkflow(workflowToCreate);
Expand Down

0 comments on commit 8a78ae1

Please sign in to comment.