From 37410e041a089af9a6acd7b52a46d0652a00b6b8 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 23 Nov 2022 11:44:15 +0000 Subject: [PATCH] Some fixes based on test runs. --- packages/server/src/api/routes/tests/backup.spec.js | 10 +++++++++- .../server/src/middleware/tests/authorized.spec.js | 2 +- packages/server/src/utilities/rowProcessor/index.ts | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/server/src/api/routes/tests/backup.spec.js b/packages/server/src/api/routes/tests/backup.spec.js index 7863129c75..7131aca852 100644 --- a/packages/server/src/api/routes/tests/backup.spec.js +++ b/packages/server/src/api/routes/tests/backup.spec.js @@ -1,4 +1,12 @@ -jest.mock("../../../utilities/fileSystem/utilities") +jest.mock("@budibase/backend-core", () => { + const core = jest.requireActual("@budibase/backend-core") + return { + ...core, + objectStore: { + budibaseTempDir: core.objectStore.budibaseTempDir, + }, + } +}) const { checkBuilderEndpoint } = require("./utilities/TestFunctions") const setup = require("./utilities") diff --git a/packages/server/src/middleware/tests/authorized.spec.js b/packages/server/src/middleware/tests/authorized.spec.js index 18a100bd93..85697b6052 100644 --- a/packages/server/src/middleware/tests/authorized.spec.js +++ b/packages/server/src/middleware/tests/authorized.spec.js @@ -154,7 +154,7 @@ describe("Authorization middleware", () => { _id: "" }, }) - config.setMiddlewareRequiredPermission(PermissionType.ADMIN, PermissionLevel.BASIC) + config.setMiddlewareRequiredPermission(permissions.PermissionType.ADMIN, permissions.PermissionLevel.BASIC) await config.executeMiddleware() expect(config.throw).toHaveBeenCalledWith(403, "User does not have permission") diff --git a/packages/server/src/utilities/rowProcessor/index.ts b/packages/server/src/utilities/rowProcessor/index.ts index 5595d0c5fb..9807fc7d61 100644 --- a/packages/server/src/utilities/rowProcessor/index.ts +++ b/packages/server/src/utilities/rowProcessor/index.ts @@ -52,7 +52,7 @@ export function processAutoColumn( user: User | null, table: Table, row: Row, - opts: AutoColumnProcessingOpts + opts?: AutoColumnProcessingOpts ) { let noUser = !user || !user.userId let isUserTable = table._id === InternalTables.USER_METADATA @@ -61,7 +61,7 @@ export function processAutoColumn( const creating = !row._rev // check its not user table, or whether any of the processing options have been disabled const shouldUpdateUserFields = - !isUserTable && !opts.reprocessing && !opts.noAutoRelationships && !noUser + !isUserTable && !opts?.reprocessing && !opts?.noAutoRelationships && !noUser for (let [key, schema] of Object.entries(table.schema)) { if (!schema.autocolumn) { continue