Updating test case which has been occasionally throwing 409 issues.
This commit is contained in:
parent
0c80ea2083
commit
7def2059f7
|
@ -1,4 +1,4 @@
|
|||
const { roles } = require("@budibase/backend-core")
|
||||
const { roles, utils } = require("@budibase/backend-core")
|
||||
const { checkPermissionsEndpoint } = require("./utilities/TestFunctions")
|
||||
const setup = require("./utilities")
|
||||
const { BUILTIN_ROLE_IDS } = roles
|
||||
|
@ -28,8 +28,8 @@ describe("/users", () => {
|
|||
|
||||
describe("fetch", () => {
|
||||
it("returns a list of users from an instance db", async () => {
|
||||
await config.createUser("uuidx")
|
||||
await config.createUser("uuidy")
|
||||
await config.createUser({ id: "uuidx" })
|
||||
await config.createUser({ id: "uuidy" })
|
||||
const res = await request
|
||||
.get(`/api/users/metadata`)
|
||||
.set(config.defaultHeaders())
|
||||
|
@ -56,7 +56,7 @@ describe("/users", () => {
|
|||
|
||||
describe("update", () => {
|
||||
it("should be able to update the user", async () => {
|
||||
const user = await config.createUser()
|
||||
const user = await config.createUser({ id: `us_update${Math.random()}` })
|
||||
user.roleId = BUILTIN_ROLE_IDS.BASIC
|
||||
const res = await request
|
||||
.put(`/api/users/metadata`)
|
||||
|
@ -180,14 +180,11 @@ describe("/users", () => {
|
|||
const app1 = await config.createApp('App 1')
|
||||
const app2 = await config.createApp('App 2')
|
||||
|
||||
let user = await config.createUser(
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
false,
|
||||
true,
|
||||
{ [app1.appId]: 'ADMIN' })
|
||||
let user = await config.createUser({
|
||||
builder: false,
|
||||
admin: true,
|
||||
roles: { [app1.appId]: 'ADMIN' }
|
||||
})
|
||||
let res = await request
|
||||
.post(`/api/users/metadata/sync/${user._id}`)
|
||||
.set(config.defaultHeaders())
|
||||
|
|
|
@ -93,24 +93,16 @@ describe("migrations", () => {
|
|||
await clearMigrations()
|
||||
const appId = config.prodAppId
|
||||
const roles = { [appId]: "role_12345" }
|
||||
await config.createUser(
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
false,
|
||||
true,
|
||||
roles
|
||||
) // admin only
|
||||
await config.createUser(
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
false,
|
||||
false,
|
||||
roles
|
||||
) // non admin non builder
|
||||
await config.createUser({
|
||||
builder: false,
|
||||
admin: true,
|
||||
roles,
|
||||
}) // admin only
|
||||
await config.createUser({
|
||||
builder: false,
|
||||
admin: false,
|
||||
roles,
|
||||
}) // non admin non builder
|
||||
await config.createTable()
|
||||
await config.createRow()
|
||||
await config.createRow()
|
||||
|
|
|
@ -275,14 +275,24 @@ class TestConfiguration {
|
|||
}
|
||||
|
||||
async createUser(
|
||||
id = null,
|
||||
firstName = this.defaultUserValues.firstName,
|
||||
lastName = this.defaultUserValues.lastName,
|
||||
email = this.defaultUserValues.email,
|
||||
builder = true,
|
||||
admin = false,
|
||||
roles = {}
|
||||
user: {
|
||||
id?: string
|
||||
firstName?: string
|
||||
lastName?: string
|
||||
email?: string
|
||||
builder?: boolean
|
||||
admin?: boolean
|
||||
roles?: any
|
||||
} = {}
|
||||
) {
|
||||
let { id, firstName, lastName, email, builder, admin, roles } = user
|
||||
firstName = firstName || this.defaultUserValues.firstName
|
||||
lastName = lastName || this.defaultUserValues.lastName
|
||||
email = email || this.defaultUserValues.email
|
||||
roles = roles || {}
|
||||
if (builder == null) {
|
||||
builder = true
|
||||
}
|
||||
const globalId = !id ? `us_${Math.random()}` : `us_${id}`
|
||||
const resp = await this.globalUser({
|
||||
id: globalId,
|
||||
|
|
Loading…
Reference in New Issue