From 4c20427c33528c1d8875f74bf8e275ccf029b204 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 15 Apr 2021 18:29:11 +0100 Subject: [PATCH] login step configured correctly --- .../cypress/integration/createApp.spec.js | 1 + .../integration/createAutomation.spec.js | 1 + .../cypress/integration/createBinding.spec.js | 1 + .../integration/createComponents.spec.js | 1 + .../cypress/integration/createScreen.js | 1 + .../cypress/integration/createTable.spec.js | 1 + .../cypress/integration/createUser.spec.js | 1 + .../cypress/integration/createView.spec.js | 1 + packages/builder/cypress/support/commands.js | 22 ++++++++++--------- 9 files changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/builder/cypress/integration/createApp.spec.js b/packages/builder/cypress/integration/createApp.spec.js index 2cc3dd1ae1..34f152b540 100644 --- a/packages/builder/cypress/integration/createApp.spec.js +++ b/packages/builder/cypress/integration/createApp.spec.js @@ -1,5 +1,6 @@ context("Create an Application", () => { it("should create a new application", () => { + cy.login() cy.createTestApp() cy.visit(`localhost:${Cypress.env("PORT")}/builder`) cy.contains("Cypress Tests").should("exist") diff --git a/packages/builder/cypress/integration/createAutomation.spec.js b/packages/builder/cypress/integration/createAutomation.spec.js index 36db9797c3..b8aab9d52e 100644 --- a/packages/builder/cypress/integration/createAutomation.spec.js +++ b/packages/builder/cypress/integration/createAutomation.spec.js @@ -1,5 +1,6 @@ context("Create a automation", () => { before(() => { + cy.login() cy.createTestApp() }) diff --git a/packages/builder/cypress/integration/createBinding.spec.js b/packages/builder/cypress/integration/createBinding.spec.js index d901dc608d..04b5366337 100644 --- a/packages/builder/cypress/integration/createBinding.spec.js +++ b/packages/builder/cypress/integration/createBinding.spec.js @@ -1,5 +1,6 @@ context("Create Bindings", () => { before(() => { + cy.login() cy.createTestApp() cy.navigateToFrontend() }) diff --git a/packages/builder/cypress/integration/createComponents.spec.js b/packages/builder/cypress/integration/createComponents.spec.js index 3fc61f8d1a..8c63d85575 100644 --- a/packages/builder/cypress/integration/createComponents.spec.js +++ b/packages/builder/cypress/integration/createComponents.spec.js @@ -2,6 +2,7 @@ context("Create Components", () => { let headlineId before(() => { + cy.login() cy.createTestApp() cy.createTable("dog") cy.addColumn("dog", "name", "string") diff --git a/packages/builder/cypress/integration/createScreen.js b/packages/builder/cypress/integration/createScreen.js index c658ab51e1..4e166daaec 100644 --- a/packages/builder/cypress/integration/createScreen.js +++ b/packages/builder/cypress/integration/createScreen.js @@ -1,5 +1,6 @@ context("Screen Tests", () => { before(() => { + cy.login() cy.createTestApp() cy.navigateToFrontend() }) diff --git a/packages/builder/cypress/integration/createTable.spec.js b/packages/builder/cypress/integration/createTable.spec.js index bbdb2e67fe..f37b445ab2 100644 --- a/packages/builder/cypress/integration/createTable.spec.js +++ b/packages/builder/cypress/integration/createTable.spec.js @@ -1,5 +1,6 @@ context("Create a Table", () => { before(() => { + cy.login() cy.createTestApp() }) diff --git a/packages/builder/cypress/integration/createUser.spec.js b/packages/builder/cypress/integration/createUser.spec.js index 0beaf5b80f..54baec79a5 100644 --- a/packages/builder/cypress/integration/createUser.spec.js +++ b/packages/builder/cypress/integration/createUser.spec.js @@ -1,5 +1,6 @@ context("Create a User", () => { before(() => { + cy.login() cy.createTestApp() }) diff --git a/packages/builder/cypress/integration/createView.spec.js b/packages/builder/cypress/integration/createView.spec.js index 2d4bd121cb..6c8aa2004d 100644 --- a/packages/builder/cypress/integration/createView.spec.js +++ b/packages/builder/cypress/integration/createView.spec.js @@ -1,5 +1,6 @@ context("Create a View", () => { before(() => { + cy.login() cy.createTestApp() cy.createTable("data") cy.addColumn("data", "group", "Text") diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index 01470fcd37..35ee0c1fc0 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -25,22 +25,24 @@ // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) Cypress.Commands.add("login", () => { - if (cy.getCookie("budibase:auth")) return + cy.getCookie("budibase:auth").then(cookie => { + // Already logged in + if (cookie) return - cy.visit(`localhost:${Cypress.env("PORT")}/builder`) - cy.contains("Create Test User").click() - cy.get("input") - .first() - .type("test@test.com") + cy.visit(`localhost:${Cypress.env("PORT")}/builder`) + cy.contains("Create Test User").click() + cy.get("input") + .first() + .type("test@test.com") - cy.get('input[type="password"]').type("test") + cy.get('input[type="password"]').type("test") + + cy.contains("Login").click() + }) - cy.contains("Login").click() - cy.wait(1000) }) Cypress.Commands.add("createApp", name => { - cy.login() cy.visit(`localhost:${Cypress.env("PORT")}/builder`) // wait for init API calls on visit cy.wait(100)