Fix viewV2.spec.ts for sqs
This commit is contained in:
parent
b93e6cb986
commit
0ef633b87a
|
@ -1653,7 +1653,7 @@ describe.each([
|
|||
})
|
||||
|
||||
describe("search", () => {
|
||||
it.only("returns empty rows from view when no schema is passed", async () => {
|
||||
it("returns empty rows from view when no schema is passed", async () => {
|
||||
const rows = await Promise.all(
|
||||
Array.from({ length: 10 }, () => config.api.row.save(table._id!, {}))
|
||||
)
|
||||
|
@ -2197,28 +2197,6 @@ describe.each([
|
|||
expect(response.rows).toHaveLength(0)
|
||||
})
|
||||
|
||||
it("queries the row api passing the view fields only", async () => {
|
||||
const searchSpy = jest.spyOn(sdk.rows, "search")
|
||||
|
||||
const view = await config.api.viewV2.create({
|
||||
tableId: table._id!,
|
||||
name: generator.guid(),
|
||||
schema: {
|
||||
id: { visible: true },
|
||||
one: { visible: false },
|
||||
},
|
||||
})
|
||||
|
||||
await config.api.viewV2.search(view.id, { query: {} })
|
||||
expect(searchSpy).toHaveBeenCalledTimes(1)
|
||||
|
||||
expect(searchSpy).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
fields: ["id"],
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
describe("foreign relationship columns", () => {
|
||||
let envCleanup: () => void
|
||||
beforeAll(() => {
|
||||
|
|
|
@ -463,11 +463,13 @@ export async function search(
|
|||
aggregations,
|
||||
})
|
||||
|
||||
// check if we need to pick specific rows out
|
||||
if (options.fields) {
|
||||
const fields = [...options.fields, ...PROTECTED_INTERNAL_COLUMNS]
|
||||
finalRows = finalRows.map((r: any) => pick(r, fields))
|
||||
}
|
||||
const visibleFields =
|
||||
options.fields ||
|
||||
Object.keys(source.schema || {}).filter(
|
||||
key => source.schema?.[key].visible !== false
|
||||
)
|
||||
const allowedFields = [...visibleFields, ...PROTECTED_INTERNAL_COLUMNS]
|
||||
finalRows = finalRows.map((r: any) => pick(r, allowedFields))
|
||||
|
||||
const response: SearchResponse<Row> = {
|
||||
rows: finalRows,
|
||||
|
|
Loading…
Reference in New Issue