1
0
Fork 0
mirror of synced 2024-06-28 11:00:55 +12:00

Update URLs to use builder instead of _builder

This commit is contained in:
Andrew Kingston 2021-04-01 10:06:22 +01:00
parent d945d76e59
commit 23641a5d56
8 changed files with 20 additions and 22 deletions

View file

@ -1,5 +1,5 @@
{ {
"baseUrl": "http://localhost:4001/_builder/", "baseUrl": "http://localhost:4001/builder/",
"video": true, "video": true,
"projectId": "bmbemn", "projectId": "bmbemn",
"env": { "env": {

View file

@ -1,7 +1,7 @@
context("Create an Application", () => { context("Create an Application", () => {
it("should create a new application", () => { it("should create a new application", () => {
cy.createTestApp() cy.createTestApp()
cy.visit(`localhost:${Cypress.env("PORT")}/_builder`) cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
cy.contains("Cypress Tests").should("exist") cy.contains("Cypress Tests").should("exist")
}) })
}) })

View file

@ -25,7 +25,7 @@
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
Cypress.Commands.add("createApp", name => { 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.contains("Create New Web App").click()
cy.get("body") cy.get("body")
.then($body => { .then($body => {
@ -56,7 +56,7 @@ Cypress.Commands.add("createApp", name => {
}) })
Cypress.Commands.add("deleteApp", 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.get("body").then($body => {
cy.wait(1000) cy.wait(1000)
if ($body.find(`[data-cy="app-${name}"]`).length) { if ($body.find(`[data-cy="app-${name}"]`).length) {

View file

@ -3,7 +3,6 @@
"version": "0.8.9", "version": "0.8.9",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"private": true, "private": true,
"type": "module",
"scripts": { "scripts": {
"build": "routify -b && vite build", "build": "routify -b && vite build",
"start": "routify -c rollup", "start": "routify -c rollup",
@ -16,8 +15,8 @@
"cy:run": "cypress run", "cy:run": "cypress run",
"cy:open": "cypress open", "cy:open": "cypress open",
"cy:run:ci": "cypress run --browser electron --record --key f308590b-6070-41af-b970-794a3823d451", "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: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:ci": "start-server-and-test cy:setup http://localhost:4001/builder cy:run:ci"
}, },
"jest": { "jest": {
"globals": { "globals": {

View file

@ -64,6 +64,6 @@ for (let route of mainRoutes) {
router.use(staticRoutes.routes()) router.use(staticRoutes.routes())
router.use(staticRoutes.allowedMethods()) router.use(staticRoutes.allowedMethods())
router.redirect("/", "/_builder") router.redirect("/", "/builder")
module.exports = router module.exports = router

View file

@ -11,7 +11,7 @@ const {
} = require("../utilities") } = require("../utilities")
module.exports = async (ctx, next) => { module.exports = async (ctx, next) => {
if (ctx.path === "/_builder") { if (ctx.path === "/builder") {
await next() await next()
return return
} }

View file

@ -1,5 +1,5 @@
const { AuthTypes } = require("../../constants") const { AuthTypes } = require("../../constants")
const authenticatedMiddleware = require("../authenticated") const authenticatedMiddleware = require("../authenticated")
const jwt = require("jsonwebtoken") const jwt = require("jsonwebtoken")
jest.mock("jsonwebtoken") jest.mock("jsonwebtoken")
@ -11,15 +11,15 @@ class TestConfiguration {
auth: {}, auth: {},
cookies: { cookies: {
set: jest.fn(), set: jest.fn(),
get: jest.fn() get: jest.fn(),
}, },
headers: {}, headers: {},
params: {}, params: {},
path: "", path: "",
request: { request: {
headers: {} headers: {},
}, },
throw: jest.fn() throw: jest.fn(),
} }
this.next = jest.fn() this.next = jest.fn()
} }
@ -49,7 +49,7 @@ describe("Authenticated middleware", () => {
}) })
it("calls next() when on the builder path", async () => { it("calls next() when on the builder path", async () => {
config.ctx.path = "/_builder" config.ctx.path = "/builder"
await config.executeMiddleware() 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 () => { it("sets a new cookie when the current cookie does not match the app id from context", async () => {
const appId = "app_123" const appId = "app_123"
config.setHeaders({ config.setHeaders({
"x-budibase-app-id": appId "x-budibase-app-id": appId,
}) })
config.ctx.cookies.get.mockImplementation(() => "cookieAppId") config.ctx.cookies.get.mockImplementation(() => "cookieAppId")
await config.executeMiddleware() await config.executeMiddleware()
expect(config.ctx.cookies.set).toHaveBeenCalledWith( expect(config.ctx.cookies.set).toHaveBeenCalledWith(
"budibase:currentapp:local", "budibase:currentapp:local",
appId, appId,
expect.any(Object) expect.any(Object)
) )
}) })
it("sets the correct BUILDER auth type information when the x-budibase-type header is not 'client'", async () => { 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") config.ctx.cookies.get.mockImplementation(() => "budibase:builder:local")
jwt.verify.mockImplementationOnce(() => ({ jwt.verify.mockImplementationOnce(() => ({
apiKey: "1234", apiKey: "1234",
roleId: "BUILDER" roleId: "BUILDER",
})) }))
await config.executeMiddleware() 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 () => { it("sets the correct APP auth type information when the user is not in the builder", async () => {
config.setHeaders({ config.setHeaders({
"x-budibase-type": "client" "x-budibase-type": "client",
}) })
config.ctx.cookies.get.mockImplementation(() => `budibase:app:local`) config.ctx.cookies.get.mockImplementation(() => `budibase:app:local`)
jwt.verify.mockImplementationOnce(() => ({ jwt.verify.mockImplementationOnce(() => ({
apiKey: "1234", apiKey: "1234",
roleId: "ADMIN" roleId: "ADMIN",
})) }))
await config.executeMiddleware() await config.executeMiddleware()
@ -108,7 +107,7 @@ describe("Authenticated middleware", () => {
expect(config.ctx.user.role).toEqual({ expect(config.ctx.user.role).toEqual({
_id: "PUBLIC", _id: "PUBLIC",
name: "Public", name: "Public",
permissionId: "public" permissionId: "public",
}) })
}) })
@ -122,4 +121,4 @@ describe("Authenticated middleware", () => {
expect(config.ctx.cookies.set).toBeCalledWith("budibase:builder:local") expect(config.ctx.cookies.set).toBeCalledWith("budibase:builder:local")
}) })
}) })