Add tests

This commit is contained in:
Adria Navarro 2024-08-26 18:00:14 +02:00
parent 5cd3b9dc88
commit 6a8d55a00c
3 changed files with 8 additions and 3 deletions

View File

@ -2,9 +2,9 @@ import { RowActionTriggerRequest, Ctx } from "@budibase/types"
import sdk from "../../../sdk" import sdk from "../../../sdk"
export async function run(ctx: Ctx<RowActionTriggerRequest, void>) { export async function run(ctx: Ctx<RowActionTriggerRequest, void>) {
const { sourceId, actionId } = ctx.params const { tableId, actionId } = ctx.params
const { rowId } = ctx.request.body const { rowId } = ctx.request.body
await sdk.rowActions.run(sourceId, actionId, rowId) await sdk.rowActions.run(tableId, actionId, rowId)
ctx.status = 200 ctx.status = 200
} }

View File

@ -726,6 +726,7 @@ describe("/rowsActions", () => {
) )
).id ).id
await config.publish()
await config.api.rowAction.trigger( await config.api.rowAction.trigger(
viewId, viewId,
rowAction.id, rowAction.id,
@ -757,7 +758,8 @@ describe("/rowsActions", () => {
rowAction.id rowAction.id
) )
await config.api.rowAction.trigger(tableId, rowAction.id, { await config.publish()
await config.api.rowAction.trigger(viewId, rowAction.id, {
rowId: row._id!, rowId: row._id!,
}) })

View File

@ -23,6 +23,7 @@ export function triggerRowActionAuthorised(
const tableId = isTableId const tableId = isTableId
? sourceId ? sourceId
: utils.extractViewInfoFromID(sourceId).tableId : utils.extractViewInfoFromID(sourceId).tableId
const rowAction = await sdk.rowActions.get(tableId, rowActionId) const rowAction = await sdk.rowActions.get(tableId, rowActionId)
if (isTableId && !rowAction.permissions.table.runAllowed) { if (isTableId && !rowAction.permissions.table.runAllowed) {
@ -37,6 +38,8 @@ export function triggerRowActionAuthorised(
) )
} }
// Enrich tableId
ctx.params.tableId = tableId
return next() return next()
} }
} }