From 2e80bab7ad53c1a95d87e6e670b089e9ae076c0f Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 31 Mar 2023 17:13:25 +0100 Subject: [PATCH] Removing requirement for built client library in component test case. --- packages/server/src/api/controllers/component.ts | 4 ++-- packages/server/src/utilities/fileSystem/app.ts | 11 ++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/server/src/api/controllers/component.ts b/packages/server/src/api/controllers/component.ts index 9b196ca289..52b1ac66bf 100644 --- a/packages/server/src/api/controllers/component.ts +++ b/packages/server/src/api/controllers/component.ts @@ -2,9 +2,9 @@ import { DocumentType } from "../../db/utils" import { Plugin } from "@budibase/types" import { db as dbCore, context, tenancy } from "@budibase/backend-core" import { getComponentLibraryManifest } from "../../utilities/fileSystem" -import { BBContext } from "@budibase/types" +import { UserCtx } from "@budibase/types" -export async function fetchAppComponentDefinitions(ctx: BBContext) { +export async function fetchAppComponentDefinitions(ctx: UserCtx) { try { const db = context.getAppDB() const app = await db.get(DocumentType.APP_METADATA) diff --git a/packages/server/src/utilities/fileSystem/app.ts b/packages/server/src/utilities/fileSystem/app.ts index b8976336ac..f5e1f6e40e 100644 --- a/packages/server/src/utilities/fileSystem/app.ts +++ b/packages/server/src/utilities/fileSystem/app.ts @@ -33,15 +33,8 @@ export const deleteApp = async (appId: string) => { export const getComponentLibraryManifest = async (library: string) => { const appId = context.getAppId() const filename = "manifest.json" - /* istanbul ignore next */ - // when testing in cypress and so on we need to get the package - // as the environment may not be fully fleshed out for dev or prod - if (env.isTest()) { - library = library.replace("standard-components", "client") - const lib = library.split("/")[1] - const path = require.resolve(library).split(lib)[0] - return require(join(path, lib, filename)) - } else if (env.isDev()) { + + if (env.isDev() || env.isTest()) { const path = join(NODE_MODULES_PATH, "@budibase", "client", filename) // always load from new so that updates are refreshed delete require.cache[require.resolve(path)]