From ec2e5a0263d1563bb152ce3dd5528641acd25f4e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 26 Aug 2024 12:11:09 +0200 Subject: [PATCH] Add test utils --- .../src/tests/utilities/api/rowAction.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/packages/server/src/tests/utilities/api/rowAction.ts b/packages/server/src/tests/utilities/api/rowAction.ts index 80535e5853..d59f9aac5a 100644 --- a/packages/server/src/tests/utilities/api/rowAction.ts +++ b/packages/server/src/tests/utilities/api/rowAction.ts @@ -70,4 +70,42 @@ export class RowActionAPI extends TestAPI { } ) } + + setViewPermission = async ( + tableId: string, + viewId: string, + rowActionId: string, + expectations?: Expectations, + config?: { publicUser?: boolean } + ) => { + return await this._post( + `/api/tables/${tableId}/actions/${rowActionId}/permissions/${viewId}`, + { + expectations: { + ...expectations, + status: expectations?.status || 204, + }, + ...config, + } + ) + } + + unsetViewPermission = async ( + tableId: string, + viewId: string, + rowActionId: string, + expectations?: Expectations, + config?: { publicUser?: boolean } + ) => { + return await this._delete( + `/api/tables/${tableId}/actions/${rowActionId}/permissions/${viewId}`, + { + expectations: { + ...expectations, + status: expectations?.status || 204, + }, + ...config, + } + ) + } }