From cef71ff70830c5798cd2ee546381b50443a6c57e Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 13 Oct 2023 18:03:10 +0100 Subject: [PATCH] Adding test cases for navbar update. --- .../[application]/settings/exportImport.svelte | 2 +- .../src/api/routes/tests/appImport.spec.ts | 5 ++++- .../src/tests/utilities/api/application.ts | 18 ++++++++++++++++++ .../server/src/tests/utilities/api/index.ts | 3 +++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 packages/server/src/tests/utilities/api/application.ts diff --git a/packages/builder/src/pages/builder/app/[application]/settings/exportImport.svelte b/packages/builder/src/pages/builder/app/[application]/settings/exportImport.svelte index bfa0274781..64ca0e0a2c 100644 --- a/packages/builder/src/pages/builder/app/[application]/settings/exportImport.svelte +++ b/packages/builder/src/pages/builder/app/[application]/settings/exportImport.svelte @@ -13,7 +13,7 @@ import ExportAppModal from "components/start/ExportAppModal.svelte" import ImportAppModal from "components/start/ImportAppModal.svelte" - $: filteredApps = $apps.filter(app => app.devId == $store.appId) + $: filteredApps = $apps.filter(app => app.devId === $store.appId) $: app = filteredApps.length ? filteredApps[0] : {} $: appDeployed = app?.status === AppStatus.DEPLOYED diff --git a/packages/server/src/api/routes/tests/appImport.spec.ts b/packages/server/src/api/routes/tests/appImport.spec.ts index ef3c739e72..51331323de 100644 --- a/packages/server/src/api/routes/tests/appImport.spec.ts +++ b/packages/server/src/api/routes/tests/appImport.spec.ts @@ -23,7 +23,10 @@ describe("/applications/:appId/import", () => { .set(config.defaultHeaders()) .expect("Content-Type", /json/) .expect(200) - expect(res.body.message).toBe("app updated") + const appPackage = await config.api.application.get(appId!) + expect(appPackage.navigation?.links?.length).toBe(2) + expect(expect(appPackage.navigation?.links?.[0].url).toBe("/blank")) + expect(expect(appPackage.navigation?.links?.[1].url).toBe("/derp")) const screens = await config.api.screen.list() expect(screens.length).toBe(2) expect(screens[0].routing.route).toBe("/derp") diff --git a/packages/server/src/tests/utilities/api/application.ts b/packages/server/src/tests/utilities/api/application.ts new file mode 100644 index 0000000000..85bc4e4173 --- /dev/null +++ b/packages/server/src/tests/utilities/api/application.ts @@ -0,0 +1,18 @@ +import { App } from "@budibase/types" +import TestConfiguration from "../TestConfiguration" +import { TestAPI } from "./base" + +export class ApplicationAPI extends TestAPI { + constructor(config: TestConfiguration) { + super(config) + } + + get = async (appId: string): Promise => { + const result = await this.request + .get(`/api/applications/${appId}/appPackage`) + .set(this.config.defaultHeaders()) + .expect("Content-Type", /json/) + .expect(200) + return result.body.application as App + } +} diff --git a/packages/server/src/tests/utilities/api/index.ts b/packages/server/src/tests/utilities/api/index.ts index 889133b847..fce8237760 100644 --- a/packages/server/src/tests/utilities/api/index.ts +++ b/packages/server/src/tests/utilities/api/index.ts @@ -6,6 +6,7 @@ import { ViewV2API } from "./viewV2" import { DatasourceAPI } from "./datasource" import { LegacyViewAPI } from "./legacyView" import { ScreenAPI } from "./screen" +import { ApplicationAPI } from "./application" export default class API { table: TableAPI @@ -15,6 +16,7 @@ export default class API { permission: PermissionAPI datasource: DatasourceAPI screen: ScreenAPI + application: ApplicationAPI constructor(config: TestConfiguration) { this.table = new TableAPI(config) @@ -24,5 +26,6 @@ export default class API { this.permission = new PermissionAPI(config) this.datasource = new DatasourceAPI(config) this.screen = new ScreenAPI(config) + this.application = new ApplicationAPI(config) } }