This commit is contained in:
Adria Navarro 2024-08-07 13:21:28 +02:00
parent 28f11a5765
commit 00cf4e48e3
1 changed files with 60 additions and 60 deletions

View File

@ -1528,76 +1528,76 @@ describe.each([
}) })
!isLucene && !isLucene &&
it("can filter a view without a view filter", async () => { it("can filter a view without a view filter", async () => {
const one = await config.api.row.save(table._id!, { const one = await config.api.row.save(table._id!, {
one: "foo", one: "foo",
two: "bar", two: "bar",
}) })
await config.api.row.save(table._id!, { await config.api.row.save(table._id!, {
one: "foo2", one: "foo2",
two: "bar2", two: "bar2",
}) })
const view = await config.api.viewV2.create({ const view = await config.api.viewV2.create({
tableId: table._id!, tableId: table._id!,
name: generator.guid(), name: generator.guid(),
schema: { schema: {
id: { visible: true }, id: { visible: true },
one: { visible: false }, one: { visible: false },
two: { visible: true }, two: { visible: true },
},
})
const response = await config.api.viewV2.search(view.id, {
query: {
equal: {
two: "bar",
}, },
}, })
const response = await config.api.viewV2.search(view.id, {
query: {
equal: {
two: "bar",
},
},
})
expect(response.rows).toHaveLength(1)
expect(response.rows).toEqual([
expect.objectContaining({ _id: one._id }),
])
}) })
expect(response.rows).toHaveLength(1)
expect(response.rows).toEqual([
expect.objectContaining({ _id: one._id }),
])
})
!isLucene && !isLucene &&
it("cannot bypass a view filter", async () => { it("cannot bypass a view filter", async () => {
await config.api.row.save(table._id!, { await config.api.row.save(table._id!, {
one: "foo", one: "foo",
two: "bar", two: "bar",
}) })
await config.api.row.save(table._id!, { await config.api.row.save(table._id!, {
one: "foo2", one: "foo2",
two: "bar2", two: "bar2",
}) })
const view = await config.api.viewV2.create({ const view = await config.api.viewV2.create({
tableId: table._id!, tableId: table._id!,
name: generator.guid(), name: generator.guid(),
query: [ query: [
{ {
operator: BasicOperator.EQUAL, operator: BasicOperator.EQUAL,
field: "two", field: "two",
value: "bar2", value: "bar2",
},
],
schema: {
id: { visible: true },
one: { visible: false },
two: { visible: true },
}, },
], })
schema: {
id: { visible: true },
one: { visible: false },
two: { visible: true },
},
})
const response = await config.api.viewV2.search(view.id, { const response = await config.api.viewV2.search(view.id, {
query: { query: {
equal: { equal: {
two: "bar", two: "bar",
},
}, },
}, })
expect(response.rows).toHaveLength(0)
}) })
expect(response.rows).toHaveLength(0)
})
}) })
describe("permissions", () => { describe("permissions", () => {