From ad62a9c7d8967d8d98c85fbb984731f9a3ef40e8 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Wed, 11 Mar 2020 17:07:18 +0000 Subject: [PATCH] broken tests --- packages/server/tests/builder.spec.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/server/tests/builder.spec.js b/packages/server/tests/builder.spec.js index ff8954dd7f..c6ac17b5d2 100644 --- a/packages/server/tests/builder.spec.js +++ b/packages/server/tests/builder.spec.js @@ -10,11 +10,19 @@ const screen2 = require("../appPackages/testApp/pages/main/screens/screen2.json" const { readJSON, pathExists, unlink, readFile } = require("fs-extra") const { getHashedCssPaths } = require("../utilities/builder/convertCssToFiles") const listScreens = require("../utilities/builder/listScreens") +const { getApisWithFullAccess } = require("../utilities/budibaseApi") const app = require("./testApp")() testComponents.textbox.name = `./customComponents/textbox` testMoreComponents.textbox.name = `./moreCustomComponents/textbox` +let _master +const getmaster = async () => { + if (!_master) + _master = await getApisWithFullAccess({}, app.masterAppPackage) + return _master +} + beforeAll(async () => { const testScreen = "./appPackages/testApp/pages/main/screens/newscreen.json" const testScreenAfterMove = @@ -24,6 +32,23 @@ beforeAll(async () => { if (await pathExists(testScreenAfterMove)) await unlink(testScreenAfterMove) await app.start() + + const response = await app + .post(`/_master/api/authenticate`, { + username: app.credentials.masterOwner.username, + password: app.credentials.masterOwner.password, + }) + .expect(statusCodes.OK) + + app.credentials.masterOwner.cookie = response.header["set-cookie"] + + const master = await getmaster() + const newApp = master.recordApi.getNew("/applications", "application") + newApp.name = "testApp" + await app + .post(`/_master/api/record/${newApp.key}`, newApp) + .set("cookie", app.credentials.masterOwner.cookie) + .expect(statusCodes.OK) }) afterAll(async () => await app.destroy())