From 7c2ef4d43fb2a331438a5f480d5357986cf14418 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 25 Mar 2021 13:32:05 +0000 Subject: [PATCH] Fixing cypress test issues. --- packages/server/src/api/controllers/application.js | 6 +++--- packages/server/src/api/controllers/component.js | 13 +++---------- packages/server/src/utilities/fileSystem/index.js | 4 ++++ .../server/src/utilities/fileSystem/utilities.js | 2 ++ 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js index 8f4cfaf24d..c5d48038ce 100644 --- a/packages/server/src/api/controllers/application.js +++ b/packages/server/src/api/controllers/application.js @@ -174,7 +174,7 @@ exports.create = async function(ctx) { await createEmptyAppPackage(ctx, newApplication) /* istanbul ignore next */ - if (env.NODE_ENV !== "jest") { + if (!env.isTest()) { await createApp(appId) } @@ -204,8 +204,8 @@ exports.delete = async function(ctx) { const db = new CouchDB(ctx.params.appId) const app = await db.get(ctx.params.appId) const result = await db.destroy() - - if (env.NODE_ENV !== "jest") { + /* istanbul ignore next */ + if (!env.isTest()) { await deleteApp(ctx.params.appId) } diff --git a/packages/server/src/api/controllers/component.js b/packages/server/src/api/controllers/component.js index 7610bc6fa4..a9b88a5bff 100644 --- a/packages/server/src/api/controllers/component.js +++ b/packages/server/src/api/controllers/component.js @@ -1,8 +1,5 @@ const CouchDB = require("../../db") -const { join } = require("../../utilities/centralPath") -const { budibaseTempDir } = require("../../utilities/budibaseDir") -const fileSystem = require("../../utilities/fileSystem") -const env = require("../../environment") +const { getComponentLibraryManifest } = require("../../utilities/fileSystem") exports.fetchAppComponentDefinitions = async function(ctx) { const appId = ctx.params.appId || ctx.appId @@ -11,12 +8,8 @@ exports.fetchAppComponentDefinitions = async function(ctx) { let componentManifests = await Promise.all( app.componentLibraries.map(async library => { - let manifest - if (env.isDev() && !env.isTest()) { - manifest = require(join(budibaseTempDir(), library, "manifest.json")) - } else { - manifest = await fileSystem.getComponentLibraryManifest(appId, library) - } + let manifest = await getComponentLibraryManifest(appId, library) + return { manifest, library, diff --git a/packages/server/src/utilities/fileSystem/index.js b/packages/server/src/utilities/fileSystem/index.js index a64a24a9fc..001bddd44c 100644 --- a/packages/server/src/utilities/fileSystem/index.js +++ b/packages/server/src/utilities/fileSystem/index.js @@ -157,6 +157,10 @@ exports.downloadTemplate = async (type, name) => { * Retrieves component libraries from object store (or tmp symlink if in local) */ exports.getComponentLibraryManifest = async (appId, library) => { + const devPath = join(budibaseTempDir(), library, "manifest.json") + if (env.isDev() && fs.existsSync(devPath)) { + return require(devPath) + } const path = join(appId, "node_modules", library, "package", "manifest.json") let resp = await retrieve(ObjectStoreBuckets.APPS, path) if (typeof resp !== "string") { diff --git a/packages/server/src/utilities/fileSystem/utilities.js b/packages/server/src/utilities/fileSystem/utilities.js index db515106c0..77e5160a5a 100644 --- a/packages/server/src/utilities/fileSystem/utilities.js +++ b/packages/server/src/utilities/fileSystem/utilities.js @@ -49,6 +49,8 @@ const PUBLIC_BUCKETS = [ObjectStoreBuckets.APPS] * @constructor */ exports.ObjectStore = bucket => { + console.log("CREATED OBJECT STORE") + console.trace() if (env.SELF_HOSTED) { AWS.config.update({ accessKeyId: env.MINIO_ACCESS_KEY,