From 23641a5d56c65a702ea906f435d2bc34dd78acb8 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 1 Apr 2021 10:06:22 +0100 Subject: [PATCH] Update URLs to use builder instead of _builder --- .../{babel.config.cjs => babel.config.js} | 0 packages/builder/cypress.json | 2 +- .../cypress/integration/createApp.spec.js | 2 +- packages/builder/cypress/support/commands.js | 4 +-- packages/builder/package.json | 5 ++-- packages/server/src/api/index.js | 2 +- .../server/src/middleware/authenticated.js | 2 +- .../middleware/tests/authenticated.spec.js | 25 +++++++++---------- 8 files changed, 20 insertions(+), 22 deletions(-) rename packages/builder/{babel.config.cjs => babel.config.js} (100%) diff --git a/packages/builder/babel.config.cjs b/packages/builder/babel.config.js similarity index 100% rename from packages/builder/babel.config.cjs rename to packages/builder/babel.config.js diff --git a/packages/builder/cypress.json b/packages/builder/cypress.json index 84c50ae863..048e1af10a 100644 --- a/packages/builder/cypress.json +++ b/packages/builder/cypress.json @@ -1,5 +1,5 @@ { - "baseUrl": "http://localhost:4001/_builder/", + "baseUrl": "http://localhost:4001/builder/", "video": true, "projectId": "bmbemn", "env": { diff --git a/packages/builder/cypress/integration/createApp.spec.js b/packages/builder/cypress/integration/createApp.spec.js index 74c9e2999d..2cc3dd1ae1 100644 --- a/packages/builder/cypress/integration/createApp.spec.js +++ b/packages/builder/cypress/integration/createApp.spec.js @@ -1,7 +1,7 @@ context("Create an Application", () => { it("should create a new application", () => { cy.createTestApp() - cy.visit(`localhost:${Cypress.env("PORT")}/_builder`) + cy.visit(`localhost:${Cypress.env("PORT")}/builder`) cy.contains("Cypress Tests").should("exist") }) }) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index a157477665..aacf9bb219 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -25,7 +25,7 @@ // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) Cypress.Commands.add("createApp", name => { - cy.visit(`localhost:${Cypress.env("PORT")}/_builder`) + cy.visit(`localhost:${Cypress.env("PORT")}/builder`) cy.contains("Create New Web App").click() cy.get("body") .then($body => { @@ -56,7 +56,7 @@ Cypress.Commands.add("createApp", name => { }) Cypress.Commands.add("deleteApp", name => { - cy.visit(`localhost:${Cypress.env("PORT")}/_builder`) + cy.visit(`localhost:${Cypress.env("PORT")}/builder`) cy.get("body").then($body => { cy.wait(1000) if ($body.find(`[data-cy="app-${name}"]`).length) { diff --git a/packages/builder/package.json b/packages/builder/package.json index ca30fb755b..7c9f52c205 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -3,7 +3,6 @@ "version": "0.8.9", "license": "AGPL-3.0", "private": true, - "type": "module", "scripts": { "build": "routify -b && vite build", "start": "routify -c rollup", @@ -16,8 +15,8 @@ "cy:run": "cypress run", "cy:open": "cypress open", "cy:run:ci": "cypress run --browser electron --record --key f308590b-6070-41af-b970-794a3823d451", - "cy:test": "start-server-and-test cy:setup http://localhost:4001/_builder cy:run", - "cy:ci": "start-server-and-test cy:setup http://localhost:4001/_builder cy:run:ci" + "cy:test": "start-server-and-test cy:setup http://localhost:4001/builder cy:run", + "cy:ci": "start-server-and-test cy:setup http://localhost:4001/builder cy:run:ci" }, "jest": { "globals": { diff --git a/packages/server/src/api/index.js b/packages/server/src/api/index.js index aeceb65039..93505b27b0 100644 --- a/packages/server/src/api/index.js +++ b/packages/server/src/api/index.js @@ -64,6 +64,6 @@ for (let route of mainRoutes) { router.use(staticRoutes.routes()) router.use(staticRoutes.allowedMethods()) -router.redirect("/", "/_builder") +router.redirect("/", "/builder") module.exports = router diff --git a/packages/server/src/middleware/authenticated.js b/packages/server/src/middleware/authenticated.js index 32ed3f63d0..ba4ef36781 100644 --- a/packages/server/src/middleware/authenticated.js +++ b/packages/server/src/middleware/authenticated.js @@ -11,7 +11,7 @@ const { } = require("../utilities") module.exports = async (ctx, next) => { - if (ctx.path === "/_builder") { + if (ctx.path === "/builder") { await next() return } diff --git a/packages/server/src/middleware/tests/authenticated.spec.js b/packages/server/src/middleware/tests/authenticated.spec.js index fe7e592528..94441b7a5e 100644 --- a/packages/server/src/middleware/tests/authenticated.spec.js +++ b/packages/server/src/middleware/tests/authenticated.spec.js @@ -1,5 +1,5 @@ const { AuthTypes } = require("../../constants") -const authenticatedMiddleware = require("../authenticated") +const authenticatedMiddleware = require("../authenticated") const jwt = require("jsonwebtoken") jest.mock("jsonwebtoken") @@ -11,15 +11,15 @@ class TestConfiguration { auth: {}, cookies: { set: jest.fn(), - get: jest.fn() + get: jest.fn(), }, headers: {}, params: {}, path: "", request: { - headers: {} + headers: {}, }, - throw: jest.fn() + throw: jest.fn(), } this.next = jest.fn() } @@ -49,7 +49,7 @@ describe("Authenticated middleware", () => { }) it("calls next() when on the builder path", async () => { - config.ctx.path = "/_builder" + config.ctx.path = "/builder" await config.executeMiddleware() @@ -59,25 +59,24 @@ describe("Authenticated middleware", () => { it("sets a new cookie when the current cookie does not match the app id from context", async () => { const appId = "app_123" config.setHeaders({ - "x-budibase-app-id": appId + "x-budibase-app-id": appId, }) config.ctx.cookies.get.mockImplementation(() => "cookieAppId") await config.executeMiddleware() expect(config.ctx.cookies.set).toHaveBeenCalledWith( - "budibase:currentapp:local", + "budibase:currentapp:local", appId, expect.any(Object) ) - }) it("sets the correct BUILDER auth type information when the x-budibase-type header is not 'client'", async () => { config.ctx.cookies.get.mockImplementation(() => "budibase:builder:local") jwt.verify.mockImplementationOnce(() => ({ apiKey: "1234", - roleId: "BUILDER" + roleId: "BUILDER", })) await config.executeMiddleware() @@ -88,12 +87,12 @@ describe("Authenticated middleware", () => { it("sets the correct APP auth type information when the user is not in the builder", async () => { config.setHeaders({ - "x-budibase-type": "client" + "x-budibase-type": "client", }) config.ctx.cookies.get.mockImplementation(() => `budibase:app:local`) jwt.verify.mockImplementationOnce(() => ({ apiKey: "1234", - roleId: "ADMIN" + roleId: "ADMIN", })) await config.executeMiddleware() @@ -108,7 +107,7 @@ describe("Authenticated middleware", () => { expect(config.ctx.user.role).toEqual({ _id: "PUBLIC", name: "Public", - permissionId: "public" + permissionId: "public", }) }) @@ -122,4 +121,4 @@ describe("Authenticated middleware", () => { expect(config.ctx.cookies.set).toBeCalledWith("budibase:builder:local") }) -}) \ No newline at end of file +})