Skip to content

Commit

Permalink
fix(editor): Fix E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cstuncsik committed Apr 11, 2024
1 parent 466131f commit b17a40a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
3 changes: 1 addition & 2 deletions cypress/e2e/20-workflow-executions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ describe('Current Workflow Executions', () => {
it('should render executions tab correctly', () => {
createMockExecutions();
cy.intercept('GET', '/rest/executions?filter=*').as('getExecutions');
cy.intercept('GET', '/rest/executions/active?filter=*').as('getActiveExecutions');

executionsTab.actions.switchToExecutionsTab();

cy.wait(['@getExecutions', '@getActiveExecutions']);
cy.wait(['@getExecutions']);

executionsTab.getters.executionsList().scrollTo(0, 500).wait(0);

Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/28-debug.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ describe('Debug', () => {
it('should be able to debug executions', () => {
cy.intercept('GET', '/rest/executions?filter=*').as('getExecutions');
cy.intercept('GET', '/rest/executions/*').as('getExecution');
cy.intercept('GET', '/rest/executions/active?filter=*').as('getActiveExecutions');
cy.intercept('POST', '/rest/workflows/run').as('postWorkflowRun');

cy.signin({ email: INSTANCE_OWNER.email, password: INSTANCE_OWNER.password });
Expand All @@ -41,7 +40,7 @@ describe('Debug', () => {

executionsTab.actions.switchToExecutionsTab();

cy.wait(['@getExecutions', '@getActiveExecutions']);
cy.wait(['@getExecutions']);

executionsTab.getters.executionDebugButton().should('have.text', 'Debug in editor').click();
cy.url().should('include', '/debug');
Expand Down
6 changes: 2 additions & 4 deletions cypress/e2e/30-editor-after-route-changes.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ describe('Editor actions should work', () => {

it('after switching between Editor and Executions', () => {
cy.intercept('GET', '/rest/executions?filter=*').as('getExecutions');
cy.intercept('GET', '/rest/executions/active?filter=*').as('getActiveExecutions');

executionsTab.actions.switchToExecutionsTab();
cy.wait(['@getExecutions', '@getActiveExecutions']);
cy.wait(['@getExecutions']);
cy.wait(500);
executionsTab.actions.switchToEditorTab();
editWorkflowAndDeactivate();
Expand All @@ -149,15 +148,14 @@ describe('Editor actions should work', () => {
it('after switching between Editor and Debug', () => {
cy.intercept('GET', '/rest/executions?filter=*').as('getExecutions');
cy.intercept('GET', '/rest/executions/*').as('getExecution');
cy.intercept('GET', '/rest/executions/active?filter=*').as('getActiveExecutions');
cy.intercept('POST', '/rest/workflows/run').as('postWorkflowRun');

editWorkflowAndDeactivate();
workflowPage.actions.executeWorkflow();
cy.wait(['@postWorkflowRun']);

executionsTab.actions.switchToExecutionsTab();
cy.wait(['@getExecutions', '@getActiveExecutions']);
cy.wait(['@getExecutions']);

executionsTab.getters.executionListItems().should('have.length', 1).first().click();
cy.wait(['@getExecution']);
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/5-ndv.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ describe('NDV', () => {
});
});

it('Stop listening for trigger event from NDV', () => {
it.only('Stop listening for trigger event from NDV', () => {
cy.intercept('POST', '/rest/workflows/run').as('workflowRun');
workflowPage.actions.addInitialNodeToCanvas('Local File Trigger', {
keepNdvOpen: true,
Expand Down
26 changes: 14 additions & 12 deletions cypress/e2e/7-workflow-actions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,19 @@ describe('Workflow Actions', () => {
// This happens when users click save button from workflow name input
// In this case blur on the input saves the workflow and then click on the button saves it again
WorkflowPage.actions.visit();
WorkflowPage.getters.workflowNameInput().invoke('val').then((oldName) => {
WorkflowPage.getters.workflowNameInputContainer().click();
WorkflowPage.getters.workflowNameInput().type('{selectall}');
WorkflowPage.getters.workflowNameInput().type('Test');
WorkflowPage.getters.saveButton().click();
WorkflowPage.getters.workflowNameInput().should('have.value', 'Test');
cy.visit(WorkflowPages.url);
// There should be no workflow with the old name (duplicate save)
WorkflowPages.getters.workflowCards().contains(String(oldName)).should('not.exist');
});
WorkflowPage.getters
.workflowNameInput()
.invoke('val')
.then((oldName) => {
WorkflowPage.getters.workflowNameInputContainer().click();
WorkflowPage.getters.workflowNameInput().type('{selectall}');
WorkflowPage.getters.workflowNameInput().type('Test');
WorkflowPage.getters.saveButton().click();
WorkflowPage.getters.workflowNameInput().should('have.value', 'Test');
cy.visit(WorkflowPages.url);
// There should be no workflow with the old name (duplicate save)
WorkflowPages.getters.workflowCards().contains(String(oldName)).should('not.exist');
});
});

it('should copy nodes', () => {
Expand Down Expand Up @@ -252,7 +255,6 @@ describe('Workflow Actions', () => {

it('should keep endpoint click working when switching between execution and editor tab', () => {
cy.intercept('GET', '/rest/executions?filter=*').as('getExecutions');
cy.intercept('GET', '/rest/executions/active?filter=*').as('getActiveExecutions');

WorkflowPage.actions.addInitialNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
WorkflowPage.actions.addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME);
Expand All @@ -263,7 +265,7 @@ describe('Workflow Actions', () => {
cy.get('body').type('{esc}');

executionsTab.actions.switchToExecutionsTab();
cy.wait(['@getExecutions', '@getActiveExecutions']);
cy.wait(['@getExecutions']);
cy.wait(500);
executionsTab.actions.switchToEditorTab();

Expand Down
6 changes: 4 additions & 2 deletions packages/editor-ui/src/composables/useRunWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import type { useRouter } from 'vue-router';
import { isEmpty } from '@/utils/typesUtils';
import { useI18n } from '@/composables/useI18n';
import { get } from 'lodash-es';
import { useExecutionsStore } from '@/stores/executions.store';

export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof useRouter> }) {
const nodeHelpers = useNodeHelpers();
Expand All @@ -48,6 +49,7 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
const rootStore = useRootStore();
const uiStore = useUIStore();
const workflowsStore = useWorkflowsStore();
const executionsStore = useExecutionsStore();

// Starts to execute a workflow on server
async function runWorkflowApi(runData: IStartRunData): Promise<IExecutionPushResponse> {
Expand Down Expand Up @@ -384,10 +386,10 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
}

try {
await workflowsStore.stopCurrentExecution(executionId);
await executionsStore.stopCurrentExecution(executionId);
} catch (error) {
// Execution stop might fail when the execution has already finished. Let's treat this here.
const execution = await this.workflowsStore.getExecution(executionId);
const execution = await workflowsStore.getExecution(executionId);

if (execution === undefined) {
// execution finished but was not saved (e.g. due to low connectivity)
Expand Down

0 comments on commit b17a40a

Please sign in to comment.