From ebaf8c3a2fa9b7820f07ddadd815428a3c917f78 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 21 Apr 2021 11:33:12 +0100 Subject: [PATCH] Updating cypress tests to work with the new user ID system. --- .../cypress/integration/createBinding.spec.js | 6 +----- packages/builder/cypress/support/commands.js | 19 ------------------- packages/builder/package.json | 5 +++-- packages/server/src/api/controllers/dev.js | 4 ++-- packages/server/src/api/routes/dev.js | 7 ++++--- 5 files changed, 10 insertions(+), 31 deletions(-) diff --git a/packages/builder/cypress/integration/createBinding.spec.js b/packages/builder/cypress/integration/createBinding.spec.js index e35abc9dc3..b32584924d 100644 --- a/packages/builder/cypress/integration/createBinding.spec.js +++ b/packages/builder/cypress/integration/createBinding.spec.js @@ -6,12 +6,8 @@ context("Create Bindings", () => { }) it("should add a current user binding", () => { - cy.addComponent("Elements", "Paragraph").then(componentId => { + cy.addComponent("Elements", "Paragraph").then(() => { addSettingBinding("text", "Current User._id") - cy.getComponent(componentId).should( - "have.text", - `ro_ta_users_test@test.com` - ) }) }) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index eb34921aff..edf5d394f6 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -1,28 +1,9 @@ // *********************************************** -// This example commands.js shows you how to -// create various custom commands and overwrite -// existing commands. -// // For more comprehensive examples of custom // commands please read more here: // https://on.cypress.io/custom-commands // *********************************************** // -// -// -- This is a parent command -- -// Cypress.Commands.add("login", (email, password) => { ... }) -// -// -// -- This is a child command -- -// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) Cypress.Commands.add("login", () => { cy.getCookie("budibase:auth").then(cookie => { diff --git a/packages/builder/package.json b/packages/builder/package.json index 6354a90ee9..c40baba71d 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -14,9 +14,10 @@ "cy:setup": "node ./cypress/setup.js", "cy:run": "cypress run", "cy:open": "cypress open", - "cy:run:ci": "cypress run --browser electron --record --key f308590b-6070-41af-b970-794a3823d451", + "cy:run:ci": "cypress run --record --key f308590b-6070-41af-b970-794a3823d451", "cy:test": "start-server-and-test cy:setup http://localhost:10000/builder cy:run", - "cy:ci": "start-server-and-test cy:setup http://localhost:10000/builder cy:run:ci" + "cy:ci": "start-server-and-test cy:setup http://localhost:10000/builder cy:run:ci", + "cy:debug": "start-server-and-test cy:setup http://localhost:10000/builder cy:open" }, "jest": { "globals": { diff --git a/packages/server/src/api/controllers/dev.js b/packages/server/src/api/controllers/dev.js index b08f730c48..003f82faa8 100644 --- a/packages/server/src/api/controllers/dev.js +++ b/packages/server/src/api/controllers/dev.js @@ -4,9 +4,9 @@ const { checkSlashesInUrl } = require("../../utilities") const { request } = require("../../utilities/workerRequests") async function redirect(ctx, method) { - const { path } = ctx.params + const { devPath } = ctx.params const response = await fetch( - checkSlashesInUrl(`${env.WORKER_URL}/api/admin/${path}`), + checkSlashesInUrl(`${env.WORKER_URL}/api/admin/${devPath}`), request(ctx, { method, body: ctx.request.body, diff --git a/packages/server/src/api/routes/dev.js b/packages/server/src/api/routes/dev.js index 977cc189f3..341d48c7b5 100644 --- a/packages/server/src/api/routes/dev.js +++ b/packages/server/src/api/routes/dev.js @@ -5,9 +5,10 @@ const env = require("../../environment") const router = Router() if (env.isDev() || env.isTest()) { - router.get("/api/admin/:path", controller.redirectGet) - router.post("/api/admin/:path", controller.redirectPost) - router.delete("/api/admin/:path", controller.redirectDelete) + router + .get("/api/admin/:devPath(.*)", controller.redirectGet) + .post("/api/admin/:devPath(.*)", controller.redirectPost) + .delete("/api/admin/:devPath(.*)", controller.redirectDelete) } module.exports = router