From 63244e1dde6f630720b7941c2df7e840990c9053 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 8 May 2023 15:16:41 +0200 Subject: [PATCH] Add test --- packages/pro | 2 +- .../api/routes/global/tests/groups.spec.ts | 22 +++++++++++++++++++ packages/worker/src/tests/api/groups.ts | 8 +++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index a0a7b5e156..ae1dd6f353 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit a0a7b5e1566467cc0625fb69309364c750847962 +Subproject commit ae1dd6f353cb8a124e3738fb1a58214db6b2df08 diff --git a/packages/worker/src/api/routes/global/tests/groups.spec.ts b/packages/worker/src/api/routes/global/tests/groups.spec.ts index 5b7fb9db9e..c93f7a76e4 100644 --- a/packages/worker/src/api/routes/global/tests/groups.spec.ts +++ b/packages/worker/src/api/routes/global/tests/groups.spec.ts @@ -1,5 +1,8 @@ import { events } from "@budibase/backend-core" import { structures, TestConfiguration, mocks } from "../../../../tests" +import { UserGroup } from "@budibase/types" + +mocks.licenses.useGroups() describe("/api/global/groups", () => { const config = new TestConfiguration() @@ -113,4 +116,23 @@ describe("/api/global/groups", () => { }) }) }) + + describe("find users", () => { + describe("without users", () => { + let group: UserGroup + beforeAll(async () => { + group = structures.groups.UserGroup() + await config.api.groups.saveGroup(group) + }) + + it("should return empty", async () => { + const result = await config.api.groups.searchUsers(group._id!) + expect(result.body).toEqual({ + users: [], + bookmark: undefined, + hasNextPage: false, + }) + }) + }) + }) }) diff --git a/packages/worker/src/tests/api/groups.ts b/packages/worker/src/tests/api/groups.ts index 5524d2a811..a0d7184360 100644 --- a/packages/worker/src/tests/api/groups.ts +++ b/packages/worker/src/tests/api/groups.ts @@ -23,4 +23,12 @@ export class GroupsAPI extends TestAPI { .expect("Content-Type", /json/) .expect(200) } + + searchUsers = (id: string) => { + return this.request + .get(`/api/global/groups/${id}/users`) + .set(this.config.defaultHeaders()) + .expect("Content-Type", /json/) + .expect(200) + } }