Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add template id to workflows created from templates (no-changelog) #8226

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion cypress/e2e/34-template-credentials-setup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('Template credentials setup', () => {
workflowPage.getters.canvasNodes().should('have.length', 3);
});

it('can create credentials and workflow from the template', () => {
it.only('can create credentials and workflow from the template', () => {
tomi marked this conversation as resolved.
Show resolved Hide resolved
templateCredentialsSetupPage.visitTemplateCredentialSetupPage(testTemplate.id);

// Continue button should be disabled if no credentials are created
Expand All @@ -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
Loading