diff --git a/packages/server/specs/openapi.json b/packages/server/specs/openapi.json index ce410823ec..62f59e9113 100644 --- a/packages/server/specs/openapi.json +++ b/packages/server/specs/openapi.json @@ -783,6 +783,7 @@ "type": "string", "enum": [ "string", + "barcodeqr", "longform", "options", "number", @@ -986,6 +987,7 @@ "type": "string", "enum": [ "string", + "barcodeqr", "longform", "options", "number", @@ -1200,6 +1202,7 @@ "type": "string", "enum": [ "string", + "barcodeqr", "longform", "options", "number", diff --git a/packages/server/specs/openapi.yaml b/packages/server/specs/openapi.yaml index ed13ac01f4..25069f40a4 100644 --- a/packages/server/specs/openapi.yaml +++ b/packages/server/specs/openapi.yaml @@ -579,6 +579,7 @@ components: type: string enum: - string + - barcodeqr - longform - options - number @@ -741,6 +742,7 @@ components: type: string enum: - string + - barcodeqr - longform - options - number @@ -910,6 +912,7 @@ components: type: string enum: - string + - barcodeqr - longform - options - number diff --git a/packages/server/src/api/controllers/deploy/index.ts b/packages/server/src/api/controllers/deploy/index.ts index b3b875e397..a1cb905930 100644 --- a/packages/server/src/api/controllers/deploy/index.ts +++ b/packages/server/src/api/controllers/deploy/index.ts @@ -20,7 +20,6 @@ import { import { events } from "@budibase/backend-core" import { backups } from "@budibase/pro" import { AppBackupTrigger } from "@budibase/types" -import env from "../../../environment" // the max time we can wait for an invalidation to complete before considering it failed const MAX_PENDING_TIME_MS = 30 * 60000 @@ -108,17 +107,10 @@ async function deployApp(deployment: any, userId: string) { const devAppId = getDevelopmentAppID(appId) const productionAppId = getProdAppID(appId) - // can't do this in test - if (!env.isTest()) { - // trigger backup initially - await backups.triggerAppBackup( - productionAppId, - AppBackupTrigger.PUBLISH, - { - createdBy: userId, - } - ) - } + // trigger backup initially + await backups.triggerAppBackup(productionAppId, AppBackupTrigger.PUBLISH, { + createdBy: userId, + }) const config: any = { source: devAppId, diff --git a/packages/server/src/api/routes/tests/deployment.spec.js b/packages/server/src/api/routes/tests/deployment.spec.js deleted file mode 100644 index be126fa239..0000000000 --- a/packages/server/src/api/routes/tests/deployment.spec.js +++ /dev/null @@ -1,25 +0,0 @@ -const setup = require("./utilities") -const { events } = require("@budibase/backend-core") - -describe("/deployments", () => { - let request = setup.getRequest() - let config = setup.getConfig() - - afterAll(setup.afterAll) - - beforeEach(async () => { - await config.init() - jest.clearAllMocks() - }) - - describe("deploy", () => { - it("should deploy the application", async () => { - await request - .post(`/api/deploy`) - .set(config.defaultHeaders()) - .expect("Content-Type", /json/) - .expect(200) - expect(events.app.published.mock.calls.length).toBe(1) - }) - }) -}) \ No newline at end of file diff --git a/packages/server/src/api/routes/tests/deployment.spec.ts b/packages/server/src/api/routes/tests/deployment.spec.ts new file mode 100644 index 0000000000..e659ff1a69 --- /dev/null +++ b/packages/server/src/api/routes/tests/deployment.spec.ts @@ -0,0 +1,40 @@ +const triggerAppBackupMock = jest.fn() +jest.mock("@budibase/pro", () => ({ + ...jest.requireActual("@budibase/pro"), + backups: { + triggerAppBackup: triggerAppBackupMock, + addAppBackupProcessors: jest.fn(), + }, +})) +import setup from "./utilities" +import { events } from "@budibase/backend-core" +import { AppBackupTrigger } from "@budibase/types" + +describe("/deployments", () => { + let request = setup.getRequest() + let config = setup.getConfig() + + afterAll(setup.afterAll) + + beforeEach(async () => { + await config.init() + jest.clearAllMocks() + }) + + describe("deploy", () => { + it("should deploy the application", async () => { + await request + .post(`/api/deploy`) + .set(config.defaultHeaders()) + .expect("Content-Type", /json/) + .expect(200) + expect(triggerAppBackupMock).toBeCalledTimes(1) + expect(triggerAppBackupMock).toBeCalledWith( + config.prodAppId, + AppBackupTrigger.PUBLISH, + { createdBy: config.userMetadataId } + ) + expect((events.app.published as jest.Mock).mock.calls.length).toBe(1) + }) + }) +}) diff --git a/packages/server/src/tests/utilities/TestConfiguration.js b/packages/server/src/tests/utilities/TestConfiguration.js index 38aa84be2d..097b2eabaf 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.js +++ b/packages/server/src/tests/utilities/TestConfiguration.js @@ -25,7 +25,7 @@ const newid = require("../../db/newid") const context = require("@budibase/backend-core/context") const { generateDevInfoID, SEPARATOR } = require("@budibase/backend-core/db") const { encrypt } = require("@budibase/backend-core/encryption") -const { DocumentType } = require("../../db/utils") +const { DocumentType, generateUserMetadataID } = require("../../db/utils") const GLOBAL_USER_ID = "us_uuid1" const EMAIL = "babs@babs.com" @@ -95,7 +95,10 @@ class TestConfiguration { // use a new id as the name to avoid name collisions async init(appName = newid()) { - await this.globalUser() + this.user = await this.globalUser() + this.globalUserId = this.user._id + this.userMetadataId = generateUserMetadataID(this.globalUserId) + return this.createApp(appName) }