From 24332f2f4516541c83b795c8293b0e0432606902 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 29 Aug 2023 16:39:19 +0200 Subject: [PATCH] Fix tests --- .../src/api/routes/tests/viewV2.spec.ts | 53 +++++++------------ 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/packages/server/src/api/routes/tests/viewV2.spec.ts b/packages/server/src/api/routes/tests/viewV2.spec.ts index 371e04b31d..a9c9f3a320 100644 --- a/packages/server/src/api/routes/tests/viewV2.spec.ts +++ b/packages/server/src/api/routes/tests/viewV2.spec.ts @@ -10,7 +10,6 @@ import { ViewV2, } from "@budibase/types" import { generator } from "@budibase/backend-core/tests" -import { buildExternalTableId } from "../../../integrations/utils" import { generateDatasourceID } from "../../../db/utils" function priceTable(): Table { @@ -41,7 +40,7 @@ beforeAll(async () => { }) describe.each([ - // ["internal ds", () => config.createTable(priceTable())], + ["internal ds", () => config.createTable(priceTable())], [ "external ds", async () => { @@ -175,7 +174,8 @@ describe.each([ let view: ViewV2 beforeEach(async () => { - await config.createTable(priceTable()) + table = await tableBuilder() + view = await config.api.viewV2.create({ name: "View A" }) }) @@ -186,19 +186,12 @@ describe.each([ query: [{ operator: "equal", field: "newField", value: "thatValue" }], }) - expect(await config.api.table.get(tableId)).toEqual({ - ...config.table, - views: { - [view.name]: { - ...view, - query: [ - { operator: "equal", field: "newField", value: "thatValue" }, - ], - schema: expect.anything(), - }, + expect((await config.api.table.get(tableId)).views).toEqual({ + [view.name]: { + ...view, + query: [{ operator: "equal", field: "newField", value: "thatValue" }], + schema: expect.anything(), }, - _rev: expect.any(String), - updatedAt: expect.any(String), }) }) @@ -231,24 +224,19 @@ describe.each([ } await config.api.viewV2.update(updatedData) - expect(await config.api.table.get(tableId)).toEqual({ - ...config.table, - views: { - [view.name]: { - ...updatedData, - schema: { - ...table.schema, - Category: expect.objectContaining({ - visible: false, - }), - Price: expect.objectContaining({ - visible: false, - }), - }, + expect((await config.api.table.get(tableId)).views).toEqual({ + [view.name]: { + ...updatedData, + schema: { + ...table.schema, + Category: expect.objectContaining({ + visible: false, + }), + Price: expect.objectContaining({ + visible: false, + }), }, }, - _rev: expect.any(String), - updatedAt: expect.any(String), }) }) @@ -401,7 +389,6 @@ describe.each([ let view: ViewV2 beforeAll(async () => { - await config.createTable(priceTable()) view = await config.api.viewV2.create() }) @@ -420,8 +407,6 @@ describe.each([ describe("fetch view (through table)", () => { it("should be able to fetch a view V2", async () => { - const table = await config.createTable(priceTable()) - const newView: CreateViewRequest = { name: generator.name(), tableId: table._id!,