Test both allOr and allAnd
This commit is contained in:
parent
53e01aa241
commit
c5476ce3b3
|
@ -1493,82 +1493,90 @@ describe.each([
|
|||
})
|
||||
|
||||
isLucene &&
|
||||
it("in lucene, cannot override a view filter", async () => {
|
||||
await config.api.row.save(table._id!, {
|
||||
one: "foo",
|
||||
two: "bar",
|
||||
})
|
||||
const two = await config.api.row.save(table._id!, {
|
||||
one: "foo2",
|
||||
two: "bar2",
|
||||
})
|
||||
it.each([true, false])(
|
||||
"in lucene, cannot override a view filter",
|
||||
async allOr => {
|
||||
await config.api.row.save(table._id!, {
|
||||
one: "foo",
|
||||
two: "bar",
|
||||
})
|
||||
const two = await config.api.row.save(table._id!, {
|
||||
one: "foo2",
|
||||
two: "bar2",
|
||||
})
|
||||
|
||||
const view = await config.api.viewV2.create({
|
||||
tableId: table._id!,
|
||||
name: generator.guid(),
|
||||
query: [
|
||||
{
|
||||
operator: BasicOperator.EQUAL,
|
||||
field: "two",
|
||||
value: "bar2",
|
||||
const view = await config.api.viewV2.create({
|
||||
tableId: table._id!,
|
||||
name: generator.guid(),
|
||||
query: [
|
||||
{
|
||||
operator: BasicOperator.EQUAL,
|
||||
field: "two",
|
||||
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, {
|
||||
query: {
|
||||
equal: {
|
||||
two: "bar",
|
||||
const response = await config.api.viewV2.search(view.id, {
|
||||
query: {
|
||||
allOr,
|
||||
equal: {
|
||||
two: "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(response.rows).toHaveLength(1)
|
||||
expect(response.rows).toEqual([
|
||||
expect.objectContaining({ _id: two._id }),
|
||||
])
|
||||
})
|
||||
})
|
||||
expect(response.rows).toHaveLength(1)
|
||||
expect(response.rows).toEqual([
|
||||
expect.objectContaining({ _id: two._id }),
|
||||
])
|
||||
}
|
||||
)
|
||||
|
||||
!isLucene &&
|
||||
it("can filter a view without a view filter", async () => {
|
||||
const one = await config.api.row.save(table._id!, {
|
||||
one: "foo",
|
||||
two: "bar",
|
||||
})
|
||||
await config.api.row.save(table._id!, {
|
||||
one: "foo2",
|
||||
two: "bar2",
|
||||
})
|
||||
it.each([true, false])(
|
||||
"can filter a view without a view filter",
|
||||
async allOr => {
|
||||
const one = await config.api.row.save(table._id!, {
|
||||
one: "foo",
|
||||
two: "bar",
|
||||
})
|
||||
await config.api.row.save(table._id!, {
|
||||
one: "foo2",
|
||||
two: "bar2",
|
||||
})
|
||||
|
||||
const view = await config.api.viewV2.create({
|
||||
tableId: table._id!,
|
||||
name: generator.guid(),
|
||||
schema: {
|
||||
id: { visible: true },
|
||||
one: { visible: false },
|
||||
two: { visible: true },
|
||||
},
|
||||
})
|
||||
|
||||
const response = await config.api.viewV2.search(view.id, {
|
||||
query: {
|
||||
equal: {
|
||||
two: "bar",
|
||||
const view = await config.api.viewV2.create({
|
||||
tableId: table._id!,
|
||||
name: generator.guid(),
|
||||
schema: {
|
||||
id: { visible: true },
|
||||
one: { visible: false },
|
||||
two: { visible: true },
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(response.rows).toHaveLength(1)
|
||||
expect(response.rows).toEqual([
|
||||
expect.objectContaining({ _id: one._id }),
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
const response = await config.api.viewV2.search(view.id, {
|
||||
query: {
|
||||
allOr,
|
||||
equal: {
|
||||
two: "bar",
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(response.rows).toHaveLength(1)
|
||||
expect(response.rows).toEqual([
|
||||
expect.objectContaining({ _id: one._id }),
|
||||
])
|
||||
}
|
||||
)
|
||||
|
||||
!isLucene &&
|
||||
it("cannot bypass a view filter", async () => {
|
||||
it.each([true, false])("cannot bypass a view filter", async allOr => {
|
||||
await config.api.row.save(table._id!, {
|
||||
one: "foo",
|
||||
two: "bar",
|
||||
|
@ -1597,6 +1605,7 @@ describe.each([
|
|||
|
||||
const response = await config.api.viewV2.search(view.id, {
|
||||
query: {
|
||||
allOr,
|
||||
equal: {
|
||||
two: "bar",
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue