This commit is contained in:
Adria Navarro 2024-07-11 17:16:14 +02:00
parent 9ff3d8cf77
commit ba2d6fd73b
4 changed files with 14 additions and 18 deletions

View File

@ -65,7 +65,6 @@ export async function update(
ctx.body = { ctx.body = {
tableId: table._id!, tableId: table._id!,
...actions, ...actions,
} }
} }

View File

@ -95,8 +95,8 @@ describe("/rowsActions", () => {
}) })
expect(res).toEqual({ expect(res).toEqual({
id: expect.stringMatching(/^row_action_\w+/),
tableId: tableId, tableId: tableId,
actionId: expect.stringMatching(/^row_action_\w+/),
...rowAction, ...rowAction,
}) })
@ -105,7 +105,7 @@ describe("/rowsActions", () => {
_rev: expect.stringMatching(/^1-\w+/), _rev: expect.stringMatching(/^1-\w+/),
tableId: tableId, tableId: tableId,
actions: { actions: {
[res.actionId]: rowAction, [res.id]: rowAction,
}, },
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(), updatedAt: new Date().toISOString(),
@ -123,9 +123,9 @@ describe("/rowsActions", () => {
_id: `ra_${tableId}`, _id: `ra_${tableId}`,
_rev: expect.stringMatching(/^3-\w+/), _rev: expect.stringMatching(/^3-\w+/),
actions: { actions: {
[responses[0].actionId]: rowActions[0], [responses[0].id]: rowActions[0],
[responses[1].actionId]: rowActions[1], [responses[1].id]: rowActions[1],
[responses[2].actionId]: rowActions[2], [responses[2].id]: rowActions[2],
}, },
tableId: tableId, tableId: tableId,
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
@ -166,9 +166,9 @@ describe("/rowsActions", () => {
expect.objectContaining({ expect.objectContaining({
tableId, tableId,
actions: { actions: {
[rowActions[0].actionId]: expect.any(Object), [rowActions[0].id]: expect.any(Object),
[rowActions[1].actionId]: expect.any(Object), [rowActions[1].id]: expect.any(Object),
[rowActions[2].actionId]: expect.any(Object), [rowActions[2].id]: expect.any(Object),
}, },
}) })
) )
@ -207,8 +207,8 @@ describe("/rowsActions", () => {
}) })
expect(res).toEqual({ expect(res).toEqual({
id: actionId,
tableId, tableId,
actionId,
...actionData, ...actionData,
name: updatedName, name: updatedName,
}) })
@ -245,7 +245,7 @@ describe("/rowsActions", () => {
const action = await createRowAction(tableId, createRowActionRequest()) const action = await createRowAction(tableId, createRowActionRequest())
await config.api.rowAction.update( await config.api.rowAction.update(
otherTable._id!, otherTable._id!,
action.actionId, action.id,
createRowActionRequest(), createRowActionRequest(),
{ status: 400 } { status: 400 }
) )

View File

@ -26,7 +26,7 @@ export async function create(tableId: string, rowAction: { name: string }) {
await db.put(doc) await db.put(doc)
return { return {
actionId: newId, id: newId,
...rowAction, ...rowAction,
} }
} }
@ -62,7 +62,7 @@ export async function update(
await db.put(actionsDoc) await db.put(actionsDoc)
return { return {
actionId: rowActionId, id: rowActionId,
...rowAction, ...rowAction,
} }
} }

View File

@ -1,8 +1,8 @@
export interface CreateRowActionRequest extends RowActionData {} export interface CreateRowActionRequest extends RowActionData {}
export interface RowActionResponse extends RowActionData { export interface RowActionResponse extends RowActionData {
id: string
tableId: string tableId: string
actionId: string
} }
export interface RowActionsResponse { export interface RowActionsResponse {
@ -14,7 +14,4 @@ interface RowActionData {
name: string name: string
} }
export interface UpdateRowActionRequest { export interface UpdateRowActionRequest extends RowActionData {}
id: string
name: string
}