Run tests for lucene as well

This commit is contained in:
Adria Navarro 2024-08-21 13:40:17 +02:00
parent 8c3f1c39c8
commit 7c06f1a407
1 changed files with 93 additions and 97 deletions

View File

@ -1492,108 +1492,104 @@ describe.each([
) )
}) })
!isLucene && it("can query on top of the view filters", async () => {
it("can query on top of the view filters", 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 three = await config.api.row.save(table._id!, {
const three = await config.api.row.save(table._id!, { one: "foo3",
one: "foo3", two: "bar3",
two: "bar3",
})
const view = await config.api.viewV2.create({
tableId: table._id!,
name: generator.guid(),
query: [
{
operator: BasicOperator.NOT_EQUAL,
field: "two",
value: "bar2",
},
],
schema: {
id: { visible: true },
one: { visible: false },
two: { visible: true },
},
})
const response = await config.api.viewV2.search(view.id, {
query: {
[BasicOperator.NOT_EQUAL]: {
two: "bar",
},
[BasicOperator.NOT_EMPTY]: {
two: null,
},
},
})
expect(response.rows).toHaveLength(1)
expect(response.rows).toEqual(
expect.arrayContaining([
expect.objectContaining({ _id: three._id }),
])
)
}) })
!isLucene && const view = await config.api.viewV2.create({
it("can query on top of the view filters (using or filters)", async () => { tableId: table._id!,
const one = await config.api.row.save(table._id!, { name: generator.guid(),
one: "foo", query: [
two: "bar", {
}) operator: BasicOperator.NOT_EQUAL,
await config.api.row.save(table._id!, { field: "one",
one: "foo2", value: "foo2",
two: "bar2",
})
const three = await config.api.row.save(table._id!, {
one: "foo3",
two: "bar3",
})
const view = await config.api.viewV2.create({
tableId: table._id!,
name: generator.guid(),
query: [
{
operator: BasicOperator.NOT_EQUAL,
field: "two",
value: "bar2",
},
],
schema: {
id: { visible: true },
one: { visible: false },
two: { visible: true },
}, },
}) ],
schema: {
const response = await config.api.viewV2.search(view.id, { id: { visible: true },
query: { one: { visible: true },
allOr: true, two: { visible: true },
[BasicOperator.NOT_EQUAL]: { },
two: "bar",
},
[BasicOperator.NOT_EMPTY]: {
two: null,
},
},
})
expect(response.rows).toHaveLength(2)
expect(response.rows).toEqual(
expect.arrayContaining([
expect.objectContaining({ _id: one._id }),
expect.objectContaining({ _id: three._id }),
])
)
}) })
const response = await config.api.viewV2.search(view.id, {
query: {
[BasicOperator.EQUAL]: {
two: "bar3",
},
[BasicOperator.NOT_EMPTY]: {
two: null,
},
},
})
expect(response.rows).toHaveLength(1)
expect(response.rows).toEqual(
expect.arrayContaining([expect.objectContaining({ _id: three._id })])
)
})
it("can query on top of the view filters (using or filters)", 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",
})
const three = await config.api.row.save(table._id!, {
one: "foo3",
two: "bar3",
})
const view = await config.api.viewV2.create({
tableId: table._id!,
name: generator.guid(),
query: [
{
operator: BasicOperator.NOT_EQUAL,
field: "two",
value: "bar2",
},
],
schema: {
id: { visible: true },
one: { visible: false },
two: { visible: true },
},
})
const response = await config.api.viewV2.search(view.id, {
query: {
allOr: true,
[BasicOperator.NOT_EQUAL]: {
two: "bar",
},
[BasicOperator.NOT_EMPTY]: {
two: null,
},
},
})
expect(response.rows).toHaveLength(2)
expect(response.rows).toEqual(
expect.arrayContaining([
expect.objectContaining({ _id: one._id }),
expect.objectContaining({ _id: three._id }),
])
)
})
isLucene && isLucene &&
it.each([true, false])( it.each([true, false])(
"in lucene, cannot override a view filter", "in lucene, cannot override a view filter",