1
0
Fork 0
mirror of synced 2024-09-08 21:51:58 +12:00

Fix view test

This commit is contained in:
Adria Navarro 2023-09-08 16:23:34 +02:00
parent b63b61655b
commit 1a7a1cdd1b
3 changed files with 18 additions and 4 deletions

View file

@ -1123,7 +1123,7 @@ describe.each([
}
}
it.only("returns table rows from view", async () => {
it("returns empty rows from view when no schema is passed", async () => {
const table = await config.createTable(await userTable())
const rows = []
for (let i = 0; i < 10; i++) {
@ -1135,7 +1135,17 @@ describe.each([
expect(response.body.rows).toHaveLength(10)
expect(response.body).toEqual({
rows: expect.arrayContaining(rows.map(expect.objectContaining)),
rows: expect.arrayContaining(
rows.map(r => ({
_viewId: createViewResponse.id,
tableId: table._id,
_id: r._id,
_rev: r._rev,
...defaultRowFields,
}))
),
hasNextPage: false,
bookmark: null,
})
})

View file

@ -20,7 +20,7 @@ function pickApi(tableId: any) {
export async function search(options: SearchParams): Promise<{
rows: any[]
hasNextPage?: boolean
bookmark?: number | null
bookmark?: number | string | null
}> {
return pickApi(options.tableId).search(options)
}

View file

@ -59,7 +59,11 @@ export async function search(options: SearchParams) {
if (paginate) {
response = await paginatedSearch(query, params)
} else {
response = await fullSearch(query, params)
response = {
...(await fullSearch(query, params)),
hasNextPage: false,
bookmark: null,
}
}
// Enrich search results with relationships