From 8bbfa7e0ab09e053bc2c2ab4a5823e1a75dca534 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 May 2023 12:31:09 +0200 Subject: [PATCH] Dynamic groups for testing --- .../worker/src/tests/structures/groups.ts | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/worker/src/tests/structures/groups.ts b/packages/worker/src/tests/structures/groups.ts index 0f7e518895..33af533bd4 100644 --- a/packages/worker/src/tests/structures/groups.ts +++ b/packages/worker/src/tests/structures/groups.ts @@ -1,10 +1,25 @@ +import { generator } from "@budibase/backend-core/tests" +import { db } from "@budibase/backend-core" +import { UserGroupRoles } from "@budibase/types" + export const UserGroup = () => { + const appsCount = generator.integer({ min: 0, max: 3 }) + const roles = Array.from({ length: appsCount }).reduce( + (p: UserGroupRoles, v) => { + return { + ...p, + [db.generateAppID()]: generator.pickone(["ADMIN", "POWER", "BASIC"]), + } + }, + {} + ) + let group = { apps: [], - color: "var(--spectrum-global-color-blue-600)", - icon: "UserGroup", - name: "New group", - roles: { app_uuid1: "ADMIN", app_uuid2: "POWER" }, + color: generator.color(), + icon: generator.word(), + name: generator.word({ length: 2 }), + roles: roles, users: [], } return group