From 6a8d55a00cf221a8b0cf411db01ebf32a3df3871 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 26 Aug 2024 18:00:14 +0200 Subject: [PATCH] Add tests --- packages/server/src/api/controllers/rowAction/run.ts | 4 ++-- packages/server/src/api/routes/tests/rowAction.spec.ts | 4 +++- packages/server/src/middleware/triggerRowActionAuthorised.ts | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/server/src/api/controllers/rowAction/run.ts b/packages/server/src/api/controllers/rowAction/run.ts index f17b9594a7..c4b6a276bf 100644 --- a/packages/server/src/api/controllers/rowAction/run.ts +++ b/packages/server/src/api/controllers/rowAction/run.ts @@ -2,9 +2,9 @@ import { RowActionTriggerRequest, Ctx } from "@budibase/types" import sdk from "../../../sdk" export async function run(ctx: Ctx) { - const { sourceId, actionId } = ctx.params + const { tableId, actionId } = ctx.params const { rowId } = ctx.request.body - await sdk.rowActions.run(sourceId, actionId, rowId) + await sdk.rowActions.run(tableId, actionId, rowId) ctx.status = 200 } diff --git a/packages/server/src/api/routes/tests/rowAction.spec.ts b/packages/server/src/api/routes/tests/rowAction.spec.ts index d61ea55e3b..aab26a2e2f 100644 --- a/packages/server/src/api/routes/tests/rowAction.spec.ts +++ b/packages/server/src/api/routes/tests/rowAction.spec.ts @@ -726,6 +726,7 @@ describe("/rowsActions", () => { ) ).id + await config.publish() await config.api.rowAction.trigger( viewId, rowAction.id, @@ -757,7 +758,8 @@ describe("/rowsActions", () => { rowAction.id ) - await config.api.rowAction.trigger(tableId, rowAction.id, { + await config.publish() + await config.api.rowAction.trigger(viewId, rowAction.id, { rowId: row._id!, }) diff --git a/packages/server/src/middleware/triggerRowActionAuthorised.ts b/packages/server/src/middleware/triggerRowActionAuthorised.ts index 4cc654c139..be5c6a97e1 100644 --- a/packages/server/src/middleware/triggerRowActionAuthorised.ts +++ b/packages/server/src/middleware/triggerRowActionAuthorised.ts @@ -23,6 +23,7 @@ export function triggerRowActionAuthorised( const tableId = isTableId ? sourceId : utils.extractViewInfoFromID(sourceId).tableId + const rowAction = await sdk.rowActions.get(tableId, rowActionId) if (isTableId && !rowAction.permissions.table.runAllowed) { @@ -37,6 +38,8 @@ export function triggerRowActionAuthorised( ) } + // Enrich tableId + ctx.params.tableId = tableId return next() } }