Implement find

This commit is contained in:
Adria Navarro 2024-07-11 10:59:11 +02:00
parent fac9c35bce
commit c565e35b53
2 changed files with 15 additions and 9 deletions

View File

@ -17,11 +17,11 @@ async function getTable(ctx: Ctx) {
export async function find(ctx: Ctx<void, RowActionsResponse>) { export async function find(ctx: Ctx<void, RowActionsResponse>) {
const table = await getTable(ctx) const table = await getTable(ctx)
// TODO const actions = await sdk.rowActions.get(table._id!)
ctx.body = { ctx.body = {
tableId: table._id!, tableId: table._id!,
actions: [], ...actions,
} }
} }

View File

@ -162,13 +162,7 @@ describe("/rowsActions", () => {
describe("find", () => { describe("find", () => {
unauthorisedTests() unauthorisedTests()
it("returns empty for tables without row actions", async () => { it("returns only the actions for the requested table", async () => {
const res = await config.api.rowAction.find(tableId)
expect(res).toEqual({ tableId, actions: [] })
})
it("returns only the", async () => {
const rowActions = generator.unique(() => createRowActionRequest(), 5) const rowActions = generator.unique(() => createRowActionRequest(), 5)
for (const rowAction of rowActions) { for (const rowAction of rowActions) {
await createRowAction(tableId, rowAction) await createRowAction(tableId, rowAction)
@ -179,6 +173,18 @@ describe("/rowsActions", () => {
) )
const otherTableId = otherTable._id! const otherTableId = otherTable._id!
await createRowAction(otherTableId, createRowActionRequest()) await createRowAction(otherTableId, createRowActionRequest())
const response = await config.api.rowAction.find(tableId)
expect(response).toEqual(
expect.objectContaining({
tableId,
actions: rowActions,
})
)
})
it("returns 404 for tables without row actions", async () => {
await config.api.rowAction.find(tableId, { status: 404 })
}) })
}) })
}) })