Skip to content

Commit c4f3293

Browse files
fix(editor): Add workflows to the store when fetching current page (n8n-io#13583)
1 parent 727f6f3 commit c4f3293

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

cypress/e2e/1-workflows.cy.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import { WorkflowSharingModal } from '../pages';
12
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
23
import { WorkflowsPage as WorkflowsPageClass } from '../pages/workflows';
34
import { getUniqueWorkflowName } from '../utils/workflowUtils';
45

56
const WorkflowsPage = new WorkflowsPageClass();
67
const WorkflowPage = new WorkflowPageClass();
8+
const workflowSharingModal = new WorkflowSharingModal();
79

810
const multipleWorkflowsCount = 5;
911

@@ -138,4 +140,10 @@ describe('Workflows', () => {
138140
cy.url().should('include', 'sort=lastCreated');
139141
cy.url().should('include', 'pageSize=25');
140142
});
143+
144+
it('should be able to share workflows from workflows list', () => {
145+
WorkflowsPage.getters.workflowCardActions('Empty State Card Workflow').click();
146+
WorkflowsPage.getters.workflowActionItem('share').click();
147+
workflowSharingModal.getters.modal().should('be.visible');
148+
});
141149
});

cypress/pages/workflows.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class WorkflowsPage extends BasePage {
3535
this.getters.workflowActivator(workflowName).findChildByTestId('workflow-activator-status'),
3636
workflowCardActions: (workflowName: string) =>
3737
this.getters.workflowCard(workflowName).findChildByTestId('workflow-card-actions'),
38+
workflowActionItem: (action: string) => cy.getByTestId(`action-${action}`).filter(':visible'),
3839
workflowDeleteButton: () =>
3940
cy.getByTestId('action-toggle-dropdown').filter(':visible').contains('Delete'),
4041
workflowMoveButton: () =>

packages/editor-ui/src/stores/workflows.store.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,19 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
517517
);
518518

519519
totalWorkflowCount.value = count;
520+
// Also set fetched workflows to store
521+
// When fetching workflows from overview page, they don't have resource property
522+
// so in order to filter out folders, we need to check if resource is not folder
523+
data
524+
.filter((item) => item.resource !== 'folder')
525+
.forEach((item) => {
526+
addWorkflow({
527+
...item,
528+
nodes: [],
529+
connections: {},
530+
versionId: '',
531+
});
532+
});
520533
return data;
521534
}
522535

0 commit comments

Comments
 (0)