From 331e8eb7be6d4ecfc6d5cc24d732e6c32dc37903 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 9 Aug 2024 11:39:58 +0200 Subject: [PATCH] Add view tests --- .../src/api/routes/tests/viewV2.spec.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/server/src/api/routes/tests/viewV2.spec.ts b/packages/server/src/api/routes/tests/viewV2.spec.ts index e18cffeaa8..9fec41ccac 100644 --- a/packages/server/src/api/routes/tests/viewV2.spec.ts +++ b/packages/server/src/api/routes/tests/viewV2.spec.ts @@ -1602,6 +1602,28 @@ describe.each([ }) expect(response.rows).toHaveLength(0) }) + + it("queries the row api passing the view fields only", async () => { + const searchSpy = jest.spyOn(sdk.rows, "search") + + const view = await config.api.viewV2.create({ + tableId: table._id!, + name: generator.guid(), + schema: { + id: { visible: true }, + one: { visible: false }, + }, + }) + + await config.api.viewV2.search(view.id, { query: {} }) + expect(searchSpy).toHaveBeenCalledTimes(1) + + expect(searchSpy).toHaveBeenCalledWith( + expect.objectContaining({ + fields: ["id"], + }) + ) + }) }) describe("permissions", () => {