From 2970bfc48a59a902389693539cd116f3f727d93a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 18 Jul 2024 17:11:11 +0200 Subject: [PATCH] Fix update and tests --- .../src/api/routes/tests/rowAction.spec.ts | 31 ++++++++++++++++--- packages/server/src/sdk/app/rowActions.ts | 5 ++- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/packages/server/src/api/routes/tests/rowAction.spec.ts b/packages/server/src/api/routes/tests/rowAction.spec.ts index efdfdd2392..4df9f630c5 100644 --- a/packages/server/src/api/routes/tests/rowAction.spec.ts +++ b/packages/server/src/api/routes/tests/rowAction.spec.ts @@ -1,7 +1,11 @@ import _ from "lodash" import tk from "timekeeper" -import { CreateRowActionRequest, RowActionResponse } from "@budibase/types" +import { + CreateRowActionRequest, + DocumentType, + RowActionResponse, +} from "@budibase/types" import * as setup from "./utilities" import { generator } from "@budibase/backend-core/tests" @@ -90,6 +94,9 @@ describe("/rowsActions", () => { ...rowAction, id: res.id, tableId: tableId, + automationId: expect.stringMatching( + `^${DocumentType.AUTOMATION}_.+` + ), }, }, }) @@ -129,9 +136,24 @@ describe("/rowsActions", () => { expect(await config.api.rowAction.find(tableId)).toEqual({ actions: { - [responses[0].id]: { ...rowActions[0], id: responses[0].id, tableId }, - [responses[1].id]: { ...rowActions[1], id: responses[1].id, tableId }, - [responses[2].id]: { ...rowActions[2], id: responses[2].id, tableId }, + [responses[0].id]: { + ...rowActions[0], + id: responses[0].id, + tableId, + automationId: expect.any(String), + }, + [responses[1].id]: { + ...rowActions[1], + id: responses[1].id, + tableId, + automationId: expect.any(String), + }, + [responses[2].id]: { + ...rowActions[2], + id: responses[2].id, + tableId, + automationId: expect.any(String), + }, }, }) }) @@ -172,6 +194,7 @@ describe("/rowsActions", () => { id: res.id, tableId: tableId, ...rowAction, + automationId: expect.any(String), }, }, }) diff --git a/packages/server/src/sdk/app/rowActions.ts b/packages/server/src/sdk/app/rowActions.ts index 59c6d9bd40..80266fe572 100644 --- a/packages/server/src/sdk/app/rowActions.ts +++ b/packages/server/src/sdk/app/rowActions.ts @@ -125,7 +125,10 @@ export async function update( ensureUniqueAndThrow(actionsDoc, action.name, rowActionId) - actionsDoc.actions[rowActionId] = action + actionsDoc.actions[rowActionId] = { + automationId: actionsDoc.actions[rowActionId].automationId, + ...action, + } const db = context.getAppDB() await db.put(actionsDoc)