From 37450823bba30ee0c715e83fe2592c26cffd73f2 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 11 Oct 2024 12:25:10 +0200 Subject: [PATCH] More tests --- .../src/api/routes/tests/search.spec.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 3b3492e74c..1ed2f66676 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -2369,6 +2369,45 @@ describe.each([ }, }).toContainExactly([]) }) + + it("should allow nested ands with multiple conditions", async () => { + await expectQuery({ + $and: { + conditions: [ + { + $and: { + conditions: [ + { + equal: { ["productCat.name"]: "foo" }, + }, + ], + }, + notEqual: { ["productCat.name"]: "foo" }, + }, + ], + }, + }).toContainExactly([]) + }) + + it("should allow nesting or under and with single conditions", async () => { + await expectQuery({ + $and: { + conditions: [ + { + $or: { + conditions: [ + { + equal: { ["productCat.name"]: "foo" }, + }, + ], + }, + }, + ], + }, + }).toContainExactly([ + { name: "foo", productCat: [{ _id: productCatRows[0]._id }] }, + ]) + }) }) })