Fix update and tests
This commit is contained in:
parent
faf1d678fa
commit
2970bfc48a
|
@ -1,7 +1,11 @@
|
||||||
import _ from "lodash"
|
import _ from "lodash"
|
||||||
import tk from "timekeeper"
|
import tk from "timekeeper"
|
||||||
|
|
||||||
import { CreateRowActionRequest, RowActionResponse } from "@budibase/types"
|
import {
|
||||||
|
CreateRowActionRequest,
|
||||||
|
DocumentType,
|
||||||
|
RowActionResponse,
|
||||||
|
} from "@budibase/types"
|
||||||
import * as setup from "./utilities"
|
import * as setup from "./utilities"
|
||||||
import { generator } from "@budibase/backend-core/tests"
|
import { generator } from "@budibase/backend-core/tests"
|
||||||
|
|
||||||
|
@ -90,6 +94,9 @@ describe("/rowsActions", () => {
|
||||||
...rowAction,
|
...rowAction,
|
||||||
id: res.id,
|
id: res.id,
|
||||||
tableId: tableId,
|
tableId: tableId,
|
||||||
|
automationId: expect.stringMatching(
|
||||||
|
`^${DocumentType.AUTOMATION}_.+`
|
||||||
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -129,9 +136,24 @@ describe("/rowsActions", () => {
|
||||||
|
|
||||||
expect(await config.api.rowAction.find(tableId)).toEqual({
|
expect(await config.api.rowAction.find(tableId)).toEqual({
|
||||||
actions: {
|
actions: {
|
||||||
[responses[0].id]: { ...rowActions[0], id: responses[0].id, tableId },
|
[responses[0].id]: {
|
||||||
[responses[1].id]: { ...rowActions[1], id: responses[1].id, tableId },
|
...rowActions[0],
|
||||||
[responses[2].id]: { ...rowActions[2], id: responses[2].id, tableId },
|
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,
|
id: res.id,
|
||||||
tableId: tableId,
|
tableId: tableId,
|
||||||
...rowAction,
|
...rowAction,
|
||||||
|
automationId: expect.any(String),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -125,7 +125,10 @@ export async function update(
|
||||||
|
|
||||||
ensureUniqueAndThrow(actionsDoc, action.name, rowActionId)
|
ensureUniqueAndThrow(actionsDoc, action.name, rowActionId)
|
||||||
|
|
||||||
actionsDoc.actions[rowActionId] = action
|
actionsDoc.actions[rowActionId] = {
|
||||||
|
automationId: actionsDoc.actions[rowActionId].automationId,
|
||||||
|
...action,
|
||||||
|
}
|
||||||
|
|
||||||
const db = context.getAppDB()
|
const db = context.getAppDB()
|
||||||
await db.put(actionsDoc)
|
await db.put(actionsDoc)
|
||||||
|
|
Loading…
Reference in New Issue