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

feat(editor): Redirect users to canvas if they don't have any workflows #5629

Merged
merged 7 commits into from
Mar 8, 2023
19 changes: 9 additions & 10 deletions cypress/e2e/1-workflows.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,19 @@ describe('Workflows', () => {
});

cy.signin({ email, password });
cy.visit(WorkflowsPage.url);
cy.visit('/');
cy.waitForLoad();
});

it('should create a new workflow using empty state card', () => {
WorkflowsPage.getters.newWorkflowButtonCard().should('be.visible');
WorkflowsPage.getters.newWorkflowButtonCard().click();

it('should land on empty canvas after registration', () => {
cy.url().should('include', WorkflowPage.url);
cy.createFixtureWorkflow('Test_workflow_1.json', `Empty State Card Workflow ${uuid()}`);

WorkflowPage.getters.workflowTags().should('contain.text', 'some-tag-1');
WorkflowPage.getters.workflowTags().should('contain.text', 'some-tag-2');
});

it('should create multiple new workflows using add workflow button', () => {
WorkflowsPage.getters.newWorkflowButtonCard().should('not.exist');

[...Array(multipleWorkflowsCount).keys()].forEach(() => {
cy.visit(WorkflowsPage.url);
WorkflowsPage.getters.createWorkflowButton().click();
Expand Down Expand Up @@ -95,8 +92,10 @@ describe('Workflows', () => {
WorkflowsPage.getters.newWorkflowTemplateCard().should('be.visible');
});

it('should contain empty state cards', () => {
WorkflowsPage.getters.newWorkflowButtonCard().should('be.visible');
WorkflowsPage.getters.newWorkflowTemplateCard().should('be.visible');
it('should redirect to new canvas if no workflows', () => {
cy.wait(1000);
cy.visit(WorkflowsPage.url);
cy.wait(1000);
cy.url().should('include', WorkflowPage.url);
});
});
1 change: 0 additions & 1 deletion cypress/e2e/10-undo-redo.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ describe('Undo/Redo', () => {

beforeEach(() => {
WorkflowPage.actions.visit();
cy.waitForLoad();
});

it('should undo/redo adding nodes', () => {
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/12-canvas.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ describe('Canvas Actions', () => {

beforeEach(() => {
WorkflowPage.actions.visit();
cy.waitForLoad();
});

it('should render canvas', () => {
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/13-pinning.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('Data pinning', () => {

beforeEach(() => {
workflowPage.actions.visit();
cy.waitForLoad();
});

it('Should be able to pin node output', () => {
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/14-mapping.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ describe('Data mapping', () => {

beforeEach(() => {
workflowPage.actions.visit();
cy.waitForLoad();

cy.window()
// @ts-ignore
Expand Down
5 changes: 0 additions & 5 deletions cypress/e2e/15-scheduler-node.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ describe('Schedule Trigger node', async () => {
beforeEach(() => {
cy.resetAll();
cy.skipSetup();
cy.visit(workflowsPage.url);
});

it('should execute and return the execution timestamp', () => {
workflowsPage.actions.createWorkflowFromCard();
cy.waitForLoad();
workflowPage.actions.addInitialNodeToCanvas('Schedule Trigger');
workflowPage.actions.openNode('Schedule Trigger');
ndv.actions.execute();
Expand All @@ -22,8 +19,6 @@ describe('Schedule Trigger node', async () => {
});

it('should execute once per second when activated', () => {
workflowsPage.actions.createWorkflowFromCard();
cy.waitForLoad();
workflowPage.actions.renameWorkflow('Schedule Trigger Workflow');
workflowPage.actions.addInitialNodeToCanvas('Schedule Trigger');
workflowPage.actions.openNode('Schedule Trigger');
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/16-webhook-node.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ describe('Webhook Trigger node', async () => {

beforeEach(() => {
workflowPage.actions.visit();
cy.waitForLoad();

cy.window()
// @ts-ignore
Expand Down
4 changes: 1 addition & 3 deletions cypress/e2e/17-sharing.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ describe('Sharing', () => {
credentialsModal.actions.save();
credentialsModal.actions.close();

cy.visit(workflowsPage.url);
workflowsPage.getters.newWorkflowButtonCard().click();
cy.waitForLoad();
workflowPage.actions.visit();
workflowPage.actions.setWorkflowName('Workflow W1');
workflowPage.actions.addInitialNodeToCanvas('Manual Trigger');
workflowPage.actions.addNodeToCanvas('Notion', true, true);
Expand Down
2 changes: 0 additions & 2 deletions cypress/e2e/17-workflow-tags.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ describe('Workflow tags', () => {
beforeEach(() => {
cy.resetAll();
cy.skipSetup();
wf.actions.visit();
cy.waitForLoad();
});

it('should create and attach tags inline', () => {
Expand Down
3 changes: 0 additions & 3 deletions cypress/e2e/19-execution.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ describe('Execution', () => {
beforeEach(() => {
cy.resetAll();
cy.skipSetup();
// Import workflow
workflowsPage.getters.newWorkflowButtonCard().click();
cy.waitForLoad();
});

it('should test manual workflow', () => {
Expand Down
7 changes: 0 additions & 7 deletions cypress/e2e/2-credentials.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ describe('Credentials', () => {

it('should create credentials from NDV for node with multiple auth options', () => {
workflowPage.actions.visit();
cy.waitForLoad();
workflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
workflowPage.actions.addNodeToCanvas(GMAIL_NODE_NAME);
workflowPage.getters.canvasNodes().last().click();
Expand All @@ -129,7 +128,6 @@ describe('Credentials', () => {

it('should show multiple credential types in the same dropdown', () => {
workflowPage.actions.visit();
cy.waitForLoad();
workflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
workflowPage.actions.addNodeToCanvas(GMAIL_NODE_NAME);
workflowPage.getters.canvasNodes().last().click();
Expand All @@ -155,7 +153,6 @@ describe('Credentials', () => {

it('should correctly render required and optional credentials', () => {
workflowPage.actions.visit();
cy.waitForLoad();
workflowPage.actions.addNodeToCanvas(PIPEDRIVE_NODE_NAME, true, true);
cy.get('body').type('{downArrow}');
cy.get('body').type('{enter}');
Expand All @@ -180,7 +177,6 @@ describe('Credentials', () => {

it('should create credentials from NDV for node with no auth options', () => {
workflowPage.actions.visit();
cy.waitForLoad();
workflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
workflowPage.actions.addNodeToCanvas(TRELLO_NODE_NAME);
workflowPage.getters.canvasNodes().last().click();
Expand All @@ -194,7 +190,6 @@ describe('Credentials', () => {

it('should delete credentials from NDV', () => {
workflowPage.actions.visit();
cy.waitForLoad();
workflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
workflowPage.actions.addNodeToCanvas(NOTION_NODE_NAME);
workflowPage.getters.canvasNodes().last().click();
Expand All @@ -214,7 +209,6 @@ describe('Credentials', () => {

it('should rename credentials from NDV', () => {
workflowPage.actions.visit();
cy.waitForLoad();
workflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
workflowPage.actions.addNodeToCanvas(TRELLO_NODE_NAME);
workflowPage.getters.canvasNodes().last().click();
Expand All @@ -235,7 +229,6 @@ describe('Credentials', () => {

it('should setup generic authentication for HTTP node', () => {
workflowPage.actions.visit();
cy.waitForLoad();
workflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
workflowPage.actions.addNodeToCanvas(HTTP_REQUEST_NODE_NAME);
workflowPage.getters.canvasNodes().last().click();
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/20-workflow-executions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('Current Workflow Executions', () => {

beforeEach(() => {
workflowPage.actions.visit();
cy.waitForLoad();
cy.createFixtureWorkflow('Test_workflow_4_executions_view.json', `My test workflow`);
createMockExecutions();
});
Expand Down
5 changes: 0 additions & 5 deletions cypress/e2e/3-default-owner.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ describe('Default owner', () => {
it('should be able to create workflows', () => {
cy.resetAll();
cy.skipSetup();
cy.visit('/');
workflowsPage.getters.newWorkflowButtonCard().should('be.visible');
workflowsPage.getters.newWorkflowButtonCard().click();

cy.waitForLoad();
cy.createFixtureWorkflow('Test_workflow_1.json', `Test workflow`);

// reload page, ensure owner still has access
Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/4-node-creator.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ describe('Node Creator', () => {
});

beforeEach(() => {
cy.visit(nodeCreatorFeature.url);
cy.waitForLoad();
WorkflowPage.actions.visit();
});

it('should open node creator on trigger tab if no trigger is on canvas', () => {
Expand Down
9 changes: 5 additions & 4 deletions cypress/e2e/5-ndv.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ const workflowPage = new WorkflowPage();
const ndv = new NDV();

describe('NDV', () => {

beforeEach(() => {
before(() => {
cy.resetAll();
cy.skipSetup();
cy.visit(workflowPage.url)
cy.waitForLoad();

});
beforeEach(() => {
workflowPage.actions.visit();
workflowPage.actions.renameWorkflow(uuid());
workflowPage.actions.saveWorkflowOnButtonClick();
});
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/6-code-node.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('Code node', () => {
});

it('should execute the placeholder in all-items mode successfully', () => {
WorkflowPage.actions.visit();
WorkflowPage.actions.addInitialNodeToCanvas('Manual');
WorkflowPage.actions.addNodeToCanvas('Code');
WorkflowPage.actions.openNode('Code');
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/7-workflow-actions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe('Workflow Actions', () => {

beforeEach(() => {
WorkflowPage.actions.visit();
cy.waitForLoad();
});

it('should be able to save on button click', () => {
Expand Down
6 changes: 1 addition & 5 deletions cypress/e2e/8-http-request-node.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { WorkflowPage, WorkflowsPage, NDV } from '../pages';
import { WorkflowPage, NDV } from '../pages';

const workflowsPage = new WorkflowsPage();
const workflowPage = new WorkflowPage();
const ndv = new NDV();

Expand All @@ -11,9 +10,6 @@ describe('HTTP Request node', () => {
});

it('should make a request with a URL and receive a response', () => {
cy.visit(workflowsPage.url);

workflowsPage.actions.createWorkflowFromCard();
workflowPage.actions.addInitialNodeToCanvas('Manual');
workflowPage.actions.addNodeToCanvas('HTTP Request');
workflowPage.actions.openNode('HTTP Request');
Expand Down
8 changes: 4 additions & 4 deletions cypress/pages/settings-users.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { SettingsSidebar } from './sidebar/settings-sidebar';
import { MainSidebar } from './sidebar/main-sidebar';
import { WorkflowsPage } from './workflows';
import { WorkflowPage } from './workflow';
import { BasePage } from './base';

const workflowsPage = new WorkflowsPage();
const workflowPage = new WorkflowPage();
const mainSidebar = new MainSidebar();
const settingsSidebar = new SettingsSidebar();

Expand All @@ -30,7 +30,7 @@ export class SettingsUsersPage extends BasePage {
goToOwnerSetup: () => this.getters.setUpOwnerButton().click(),
loginAndVisit: (email: string, password: string, isOwner: boolean) => {
cy.signin({ email, password });
cy.visit(workflowsPage.url);
workflowPage.actions.visit();
mainSidebar.actions.goToSettings();
if (isOwner) {
settingsSidebar.getters.menuItem('Users').click();
Expand All @@ -39,7 +39,7 @@ export class SettingsUsersPage extends BasePage {
settingsSidebar.getters.menuItem('Users').should('not.exist');
// Should be redirected to workflows page if trying to access UM url
cy.visit('/settings/users');
cy.url().should('match', new RegExp(workflowsPage.url));
cy.url().should('match', new RegExp(workflowPage.url));
}
},
opedDeleteDialog: (email: string) => {
Expand Down
8 changes: 8 additions & 0 deletions cypress/pages/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,20 @@ export class WorkflowPage extends BasePage {
turnOnManualExecutionSaving: () => {
this.getters.workflowMenu().click();
this.getters.workflowMenuItemSettings().click();
cy.get('.el-loading-mask').should('not.be.visible');
this.getters
.workflowSettingsSaveManualExecutionsSelect()
.find('li:contains("Yes")')
.click({ force: true });

this.getters.workflowSettingsSaveManualExecutionsSelect().should('contain', 'Yes');
this.getters.workflowSettingsSaveButton().click();
this.getters.successToast().should('exist');

this.getters.workflowMenu().click();
this.getters.workflowMenuItemSettings().click();
this.getters.workflowSettingsSaveManualExecutionsSelect().should('contain', 'Yes');
this.getters.workflowSettingsSaveButton().click();
},
};
}
21 changes: 13 additions & 8 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
import 'cypress-real-events';
import { WorkflowsPage, SigninPage, SignupPage, SettingsUsersPage } from '../pages';
import { WorkflowsPage, SigninPage, SignupPage, SettingsUsersPage, WorkflowPage } from '../pages';
import { N8N_AUTH_COOKIE } from '../constants';
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
import { MessageBox } from '../pages/modals/message-box';
Expand Down Expand Up @@ -54,13 +54,13 @@ Cypress.Commands.add(
);

Cypress.Commands.add('waitForLoad', () => {
cy.getByTestId('node-view-loader', { timeout: 10000 }).should('not.exist');
cy.get('.el-loading-mask', { timeout: 10000 }).should('not.exist');
cy.getByTestId('node-view-loader', { timeout: 20000 }).should('not.exist');
cy.get('.el-loading-mask', { timeout: 20000 }).should('not.exist');
});

Cypress.Commands.add('signin', ({ email, password }) => {
const signinPage = new SigninPage();
const workflowsPage = new WorkflowsPage();
const workflowPage = new WorkflowPage();

cy.session(
[email, password],
Expand All @@ -74,7 +74,10 @@ Cypress.Commands.add('signin', ({ email, password }) => {
});

// we should be redirected to /workflows
cy.url().should('include', workflowsPage.url);
cy.visit(workflowPage.url);
cy.url().should('include', workflowPage.url);
cy.intercept('GET', '/rest/workflows/new').as('loading');
cy.wait('@loading');
},
{
validate() {
Expand Down Expand Up @@ -158,7 +161,7 @@ Cypress.Commands.add('inviteUsers', ({ instanceOwner, users }) => {

Cypress.Commands.add('skipSetup', () => {
const signupPage = new SignupPage();
const workflowsPage = new WorkflowsPage();
const workflowPage = new WorkflowPage();
const Confirmation = new MessageBox();

cy.visit(signupPage.url);
Expand All @@ -171,8 +174,10 @@ Cypress.Commands.add('skipSetup', () => {
Confirmation.getters.header().should('contain.text', 'Skip owner account setup?');
Confirmation.actions.confirm();

// we should be redirected to /workflows
cy.url().should('include', workflowsPage.url);
// we should be redirected to empty canvas
cy.intercept('GET', '/rest/workflows/new').as('loading');
cy.url().should('include', workflowPage.url);
cy.wait('@loading');
} else {
cy.log('User already signed up');
}
Expand Down
Loading