From d46050c9745731cfa318bc7a06b8d4f9fed59ff1 Mon Sep 17 00:00:00 2001 From: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> Date: Thu, 24 Nov 2022 12:52:09 +0100 Subject: [PATCH] test: Add initial e2e tests for default owner setup (#4710) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * use user-folder override consistently everywhere, including for the `.cache` folder * use consistent config for e2e tesing, skipping config loading from env and config files * simplify all the cypress commands, and run all e2e tests on master * add tests for skipping owner setup * add todos Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ --- cypress/e2e/0-smoke.cy.ts | 2 +- cypress/e2e/3-default-owner.cy.ts | 9 +++++++++ cypress/pages/modals/message-box.ts | 18 ++++++++++++++++++ cypress/pages/signup.ts | 2 ++ cypress/support/commands.ts | 27 +++++++++++++++++++++++++++ cypress/support/index.ts | 2 ++ 6 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 cypress/e2e/3-default-owner.cy.ts create mode 100644 cypress/pages/modals/message-box.ts diff --git a/cypress/e2e/0-smoke.cy.ts b/cypress/e2e/0-smoke.cy.ts index 6a750b676e..3f394a4182 100644 --- a/cypress/e2e/0-smoke.cy.ts +++ b/cypress/e2e/0-smoke.cy.ts @@ -7,7 +7,7 @@ const firstName = randFirstName(); const lastName = randLastName(); describe('Authentication', () => { - it('should sign user up', () => { + it('should setup owner', () => { cy.signup(username, firstName, lastName, password); }); diff --git a/cypress/e2e/3-default-owner.cy.ts b/cypress/e2e/3-default-owner.cy.ts new file mode 100644 index 0000000000..5f1682c35f --- /dev/null +++ b/cypress/e2e/3-default-owner.cy.ts @@ -0,0 +1,9 @@ +describe('Authentication', () => { + it('should skip owner setup', () => { + cy.skipSetup(); + }); + + // todo test for adding workflow + // todo test for setting up UM again through settings + // todo test that workflows migrated successfully +}); diff --git a/cypress/pages/modals/message-box.ts b/cypress/pages/modals/message-box.ts new file mode 100644 index 0000000000..55f76cd9fd --- /dev/null +++ b/cypress/pages/modals/message-box.ts @@ -0,0 +1,18 @@ +import { BasePage } from "../base"; + +export class MessageBox extends BasePage { + getters = { + modal: () => cy.get('.el-message-box', { withinSubject: null }), + header: () => this.getters.modal().find('.el-message-box__title'), + confirm: () => this.getters.modal().find('.btn--confirm'), + cancel: () => this.getters.modal().find('.btn--cancel'), + }; + actions = { + confirm: () => { + this.getters.confirm().click(); + }, + cancel: () => { + this.getters.cancel().click(); + }, + }; +} diff --git a/cypress/pages/signup.ts b/cypress/pages/signup.ts index 2a5b61dfdf..c72c8098df 100644 --- a/cypress/pages/signup.ts +++ b/cypress/pages/signup.ts @@ -1,5 +1,6 @@ import { BasePage } from "./base"; +// todo rename to setup export class SignupPage extends BasePage { url = '/setup'; getters = { @@ -9,5 +10,6 @@ export class SignupPage extends BasePage { lastName: () => cy.getByTestId('lastName'), password: () => cy.getByTestId('password'), submit: () => cy.get('button'), + skip: () => cy.get('a'), } } diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 820b1bb3e6..81f3088806 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -27,6 +27,7 @@ import { WorkflowsPage, SigninPage, SignupPage } from "../pages"; import { N8N_AUTH_COOKIE } from "../constants"; import { WorkflowPage as WorkflowPageClass } from '../pages/workflow'; +import { MessageBox } from '../pages/modals/message-box'; Cypress.Commands.add('getByTestId', (selector, ...args) => { return cy.get(`[data-test-id="${selector}"]`, ...args) @@ -74,6 +75,7 @@ Cypress.Commands.add( }); }); +// todo rename to setup Cypress.Commands.add('signup', (email, firstName, lastName, password) => { const signupPage = new SignupPage(); @@ -93,3 +95,28 @@ Cypress.Commands.add('signup', (email, firstName, lastName, password) => { }); }); }) + +Cypress.Commands.add('skipSetup', () => { + const signupPage = new SignupPage(); + const workflowsPage = new WorkflowsPage(); + const Confirmation = new MessageBox(); + + cy.visit(signupPage.url); + + signupPage.getters.form().within(() => { + cy.url().then((url) => { + if (url.endsWith(signupPage.url)) { + signupPage.getters.skip().click(); + + + 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); + } else { + cy.log('User already signed up'); + } + }); + }); +}) diff --git a/cypress/support/index.ts b/cypress/support/index.ts index 1519e68fb0..2567772d1e 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -8,7 +8,9 @@ declare global { findChildByTestId(childTestId: string): Chainable> createFixtureWorkflow(fixtureKey: string, workflowName: string): void; signin(email: string, password: string): void; + // todo: rename to setup signup(email: string, firstName: string, lastName: string, password: string): void; + skipSetup(): void; } } }