From 8e904cea13c9bd116bda0e1cc42be5c60a987e52 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 24 Jul 2023 15:05:20 +0200 Subject: [PATCH] Set order to the tests --- .../src/sdk/app/tables/tests/tables.spec.ts | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/packages/server/src/sdk/app/tables/tests/tables.spec.ts b/packages/server/src/sdk/app/tables/tests/tables.spec.ts index 48bcac7920..a474f2aa43 100644 --- a/packages/server/src/sdk/app/tables/tests/tables.spec.ts +++ b/packages/server/src/sdk/app/tables/tests/tables.spec.ts @@ -15,6 +15,7 @@ describe("table sdk", () => { name: "name", visible: true, width: 80, + order: 2, constraints: { type: "string", }, @@ -32,6 +33,7 @@ describe("table sdk", () => { type: FieldType.NUMBER, name: "id", visible: true, + order: 1, constraints: { type: "number", }, @@ -70,6 +72,7 @@ describe("table sdk", () => { type: "string", name: "name", visible: true, + order: 2, width: 80, constraints: { type: "string", @@ -88,6 +91,7 @@ describe("table sdk", () => { type: "number", name: "id", visible: true, + order: 1, constraints: { type: "number", }, @@ -136,6 +140,7 @@ describe("table sdk", () => { type: "string", name: "name", visible: true, + order: 2, width: 80, constraints: { type: "string", @@ -145,6 +150,7 @@ describe("table sdk", () => { type: "number", name: "id", visible: true, + order: 1, constraints: { type: "number", }, @@ -181,6 +187,7 @@ describe("table sdk", () => { name: { type: "string", name: "name", + order: 2, visible: true, width: 80, constraints: { @@ -193,6 +200,58 @@ describe("table sdk", () => { }) ) }) + + it("if view schema only defines visiblility, should only fetch the selected fields", async () => { + const tableId = basicTable._id! + const view: ViewV2 = { + version: 2, + id: generator.guid(), + name: generator.guid(), + tableId, + columns: { + name: { visible: true }, + id: { visible: true }, + description: { visible: false }, + }, + } + + const res = sdk.tables.enrichViewSchemas({ + ...basicTable, + views: { [view.name]: view }, + }) + + expect(res).toEqual( + expect.objectContaining({ + ...basicTable, + views: { + [view.name]: { + ...view, + schema: { + name: { + type: "string", + name: "name", + order: 2, + visible: true, + width: 80, + constraints: { + type: "string", + }, + }, + id: { + type: "number", + name: "id", + order: 1, + visible: true, + constraints: { + type: "number", + }, + }, + }, + }, + }, + }) + ) + }) }) }) })