Fix update and tests

This commit is contained in:
Adria Navarro 2024-07-18 17:11:11 +02:00
parent faf1d678fa
commit 2970bfc48a
2 changed files with 31 additions and 5 deletions

View File

@ -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),
},
},
})

View File

@ -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)