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 table = await config.createTable(await userTable())
const rows = [] const rows = []
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
@ -1135,7 +1135,17 @@ describe.each([
expect(response.body.rows).toHaveLength(10) expect(response.body.rows).toHaveLength(10)
expect(response.body).toEqual({ 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<{ export async function search(options: SearchParams): Promise<{
rows: any[] rows: any[]
hasNextPage?: boolean hasNextPage?: boolean
bookmark?: number | null bookmark?: number | string | null
}> { }> {
return pickApi(options.tableId).search(options) return pickApi(options.tableId).search(options)
} }

View File

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