From 732d701a868bd7b198cb5a9dcd64b12fdf565cb5 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 23 Oct 2024 13:16:55 +0200 Subject: [PATCH] Remove row action update tests --- .../src/api/routes/tests/rowAction.spec.ts | 123 ------------------ .../src/tests/utilities/api/rowAction.ts | 17 --- 2 files changed, 140 deletions(-) diff --git a/packages/server/src/api/routes/tests/rowAction.spec.ts b/packages/server/src/api/routes/tests/rowAction.spec.ts index c0b5c4210f..5cec83fe23 100644 --- a/packages/server/src/api/routes/tests/rowAction.spec.ts +++ b/packages/server/src/api/routes/tests/rowAction.spec.ts @@ -328,129 +328,6 @@ describe("/rowsActions", () => { }) }) - describe("update", () => { - unauthorisedTests((expectations, testConfig) => - config.api.rowAction.update( - tableId, - generator.guid(), - createRowActionRequest(), - expectations, - testConfig - ) - ) - - it("can update existing actions", async () => { - for (const rowAction of createRowActionRequests(3)) { - await createRowAction(tableId, rowAction) - } - - const persisted = await config.api.rowAction.find(tableId) - - const [actionId, actionData] = _.sample( - Object.entries(persisted.actions) - )! - - const updatedName = generator.string() - - const res = await config.api.rowAction.update(tableId, actionId, { - name: updatedName, - }) - - expect(res).toEqual({ - id: actionId, - tableId, - name: updatedName, - automationId: actionData.automationId, - allowedSources: [tableId], - }) - - expect(await config.api.rowAction.find(tableId)).toEqual( - expect.objectContaining({ - actions: expect.objectContaining({ - [actionId]: { - name: updatedName, - id: actionData.id, - tableId: actionData.tableId, - automationId: actionData.automationId, - allowedSources: [tableId], - }, - }), - }) - ) - }) - - it("trims row action names", async () => { - const rowAction = await createRowAction(tableId, createRowActionRequest()) - - const res = await config.api.rowAction.update(tableId, rowAction.id, { - name: " action name ", - }) - - expect(res).toEqual(expect.objectContaining({ name: "action name" })) - - expect(await config.api.rowAction.find(tableId)).toEqual( - expect.objectContaining({ - actions: expect.objectContaining({ - [rowAction.id]: expect.objectContaining({ - name: "action name", - }), - }), - }) - ) - }) - - it("throws Bad Request when trying to update by a non-existing id", async () => { - await createRowAction(tableId, createRowActionRequest()) - - await config.api.rowAction.update( - tableId, - generator.guid(), - createRowActionRequest(), - { status: 400 } - ) - }) - - it("throws Bad Request when trying to update by a via another table id", async () => { - const otherTable = await config.api.table.save( - setup.structures.basicTable() - ) - await createRowAction(otherTable._id!, createRowActionRequest()) - - const action = await createRowAction(tableId, createRowActionRequest()) - await config.api.rowAction.update( - otherTable._id!, - action.id, - createRowActionRequest(), - { status: 400 } - ) - }) - - it("can not use existing row action names (for the same table)", async () => { - const action1 = await createRowAction(tableId, createRowActionRequest()) - const action2 = await createRowAction(tableId, createRowActionRequest()) - - await config.api.rowAction.update( - tableId, - action1.id, - { name: action2.name }, - { - status: 409, - body: { - message: "A row action with the same name already exists.", - }, - } - ) - }) - - it("does not throw with name conflicts for the same row action", async () => { - const action1 = await createRowAction(tableId, createRowActionRequest()) - - await config.api.rowAction.update(tableId, action1.id, { - name: action1.name, - }) - }) - }) - describe("delete", () => { unauthorisedTests((expectations, testConfig) => config.api.rowAction.delete( diff --git a/packages/server/src/tests/utilities/api/rowAction.ts b/packages/server/src/tests/utilities/api/rowAction.ts index e18f2ce6b6..5d5ef69b8a 100644 --- a/packages/server/src/tests/utilities/api/rowAction.ts +++ b/packages/server/src/tests/utilities/api/rowAction.ts @@ -41,23 +41,6 @@ export class RowActionAPI extends TestAPI { ) } - update = async ( - tableId: string, - rowActionId: string, - rowAction: CreateRowActionRequest, - expectations?: Expectations, - config?: { publicUser?: boolean } - ) => { - return await this._put( - `/api/tables/${tableId}/actions/${rowActionId}`, - { - body: rowAction, - expectations, - ...config, - } - ) - } - delete = async ( tableId: string, rowActionId: string,