Dynamic groups for testing

This commit is contained in:
Adria Navarro 2023-05-10 12:31:09 +02:00
parent e318eda5f4
commit 8bbfa7e0ab
1 changed files with 19 additions and 4 deletions

View File

@ -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 = () => { 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 = { let group = {
apps: [], apps: [],
color: "var(--spectrum-global-color-blue-600)", color: generator.color(),
icon: "UserGroup", icon: generator.word(),
name: "New group", name: generator.word({ length: 2 }),
roles: { app_uuid1: "ADMIN", app_uuid2: "POWER" }, roles: roles,
users: [], users: [],
} }
return group return group