Implement find
This commit is contained in:
parent
fac9c35bce
commit
c565e35b53
|
@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue