From bf62153b8b28b4688e4ee777c312561d881a9cfb Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 9 Oct 2024 10:16:32 +0200 Subject: [PATCH] Add test with conditions --- .../src/api/routes/global/tests/users.spec.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/worker/src/api/routes/global/tests/users.spec.ts b/packages/worker/src/api/routes/global/tests/users.spec.ts index a654c42359..c8e71f7eb4 100644 --- a/packages/worker/src/api/routes/global/tests/users.spec.ts +++ b/packages/worker/src/api/routes/global/tests/users.spec.ts @@ -741,6 +741,25 @@ describe("/api/global/users", () => { it("should throw an error if public query performed", async () => { await config.api.users.searchUsers({}, { status: 403, noHeaders: true }) }) + + it("should be able to search using logical conditions", async () => { + const user = await config.createUser() + const response = await config.api.users.searchUsers({ + query: { + $and: { + conditions: [ + { + $and: { + conditions: [{ string: { email: user.email } }], + }, + }, + ], + }, + }, + }) + expect(response.body.data.length).toBe(1) + expect(response.body.data[0].email).toBe(user.email) + }) }) describe("DELETE /api/global/users/:userId", () => {