From 645abea2cdb4e27f53829d7636bbb7f3117c0f9e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 11 Jul 2024 10:19:11 +0200 Subject: [PATCH] Add extra tests --- .../src/api/routes/tests/rowAction.spec.ts | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/packages/server/src/api/routes/tests/rowAction.spec.ts b/packages/server/src/api/routes/tests/rowAction.spec.ts index e817259315..6281023991 100644 --- a/packages/server/src/api/routes/tests/rowAction.spec.ts +++ b/packages/server/src/api/routes/tests/rowAction.spec.ts @@ -85,7 +85,7 @@ describe("/rowsActions", () => { }) }) - it("can create multiple row actions for the same tables", async () => { + it("can create multiple row actions for the same table", async () => { const rowActions = generator.unique(() => createRowActionRequest(), 3) await config.api.rowAction.save(tableId, rowActions[0], { @@ -108,6 +108,41 @@ describe("/rowsActions", () => { }) }) + it("can create row actions for different tables", async () => { + const otherTable = await config.api.table.save( + setup.structures.basicTable() + ) + const otherTableId = otherTable._id! + + const rowAction1 = createRowActionRequest() + const rowAction2 = createRowActionRequest() + + const res1 = await config.api.rowAction.save(tableId, rowAction1, { + status: 201, + }) + const res2 = await config.api.rowAction.save(otherTableId, rowAction2, { + status: 201, + }) + + expect(res1).toEqual({ + _id: `${tableId}_row_actions`, + _rev: expect.stringMatching(/^1-\w+/), + actions: [rowAction1], + tableId: tableId, + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), + }) + + expect(res2).toEqual({ + _id: `${otherTableId}_row_actions`, + _rev: expect.stringMatching(/^1-\w+/), + actions: [rowAction2], + tableId: otherTableId, + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), + }) + }) + it("rejects with bad request when creating with no name", async () => { const rowAction: CreateRowActionRequest = { name: "",