Add partial user type
This commit is contained in:
parent
6d87a38ab3
commit
b995575189
|
@ -10,7 +10,7 @@ export default class UserManagementApi {
|
|||
this.api = apiClient
|
||||
}
|
||||
|
||||
async searchUsers(): Promise<[Response, User[]]> {
|
||||
async searchUsers(): Promise<[Response, Partial<User>[]]> {
|
||||
const response = await this.api.post(`/global/users/search`, {})
|
||||
const json = await response.json()
|
||||
expect(response).toHaveStatusCode(200)
|
||||
|
@ -18,14 +18,14 @@ export default class UserManagementApi {
|
|||
return [response, json]
|
||||
}
|
||||
|
||||
async getSelf(): Promise<[Response, User]> {
|
||||
async getSelf(): Promise<[Response, Partial<User>]> {
|
||||
const response = await this.api.get(`/global/self`)
|
||||
const json = await response.json()
|
||||
expect(response).toHaveStatusCode(200)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async getAllUsers(): Promise<[Response, User[]]> {
|
||||
async getAllUsers(): Promise<[Response, Partial<User>[]]> {
|
||||
const response = await this.api.get(`/global/users`)
|
||||
const json = await response.json()
|
||||
expect(response).toHaveStatusCode(200)
|
||||
|
@ -33,7 +33,7 @@ export default class UserManagementApi {
|
|||
return [response, json]
|
||||
}
|
||||
|
||||
async addMultipleUsers(userList: User[]): Promise<[Response, any]> {
|
||||
async addMultipleUsers(userList: Partial<User>[]): Promise<[Response, any]> {
|
||||
const body = {
|
||||
create: {
|
||||
users: userList,
|
||||
|
|
|
@ -3,7 +3,7 @@ import { User } from "@budibase/types";
|
|||
import { generateUserMetadataID } from "@budibase/backend-core/src/db";
|
||||
|
||||
|
||||
const generateDeveloper = (): User => {
|
||||
const generateDeveloper = (): Partial<User> => {
|
||||
const randomId = generator.guid();
|
||||
return ({
|
||||
email: `pedro+${randomId}@budibase.com`,
|
||||
|
@ -16,7 +16,7 @@ const generateDeveloper = (): User => {
|
|||
})
|
||||
}
|
||||
|
||||
const generateAdmin = (): User => {
|
||||
const generateAdmin = (): Partial<User> => {
|
||||
const randomId = generator.guid();
|
||||
return ({
|
||||
email: `pedro+${randomId}@budibase.com`,
|
||||
|
@ -31,7 +31,7 @@ const generateAdmin = (): User => {
|
|||
}
|
||||
})
|
||||
}
|
||||
const generateAppUser = (): User => {
|
||||
const generateAppUser = (): Partial<User> => {
|
||||
const randomId = generator.guid();
|
||||
return ({
|
||||
email: `pedro+${randomId}@budibase.com`,
|
||||
|
@ -59,8 +59,8 @@ export const generateInviteUser = (): Object[] => {
|
|||
|
||||
}
|
||||
|
||||
export const generateUser = (amount: number = 1, role?: string): User[] => {
|
||||
const userList: User[] = [];
|
||||
export const generateUser = (amount: number = 1, role?: string): Partial<User>[] => {
|
||||
const userList: Partial<User>[] = [];
|
||||
for (let i = 0; i < amount; i++) {
|
||||
switch (role) {
|
||||
case "admin":
|
||||
|
|
|
@ -135,7 +135,7 @@ describe("Internal API - User Management & Permissions", () => {
|
|||
})
|
||||
|
||||
it("Add POWER user to app", async () => {
|
||||
const powerUser = generateUser(1, 'Developer')
|
||||
const powerUser = generateUser(1, 'developer')
|
||||
expect(powerUser[0].builder?.global).toEqual(true)
|
||||
|
||||
const [createUserResponse, createUserJson] = await config.users.addMultipleUsers(powerUser)
|
||||
|
@ -153,8 +153,8 @@ describe("Internal API - User Management & Permissions", () => {
|
|||
await config.users.changeUserInformation(body)
|
||||
|
||||
const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getUserInformation(createUserJson.created.successful[0]._id)
|
||||
expect(changedUserInfoJson.roles[app.appId?.toString() || ""]).toBeDefined()
|
||||
expect(changedUserInfoJson.roles[app.appId?.toString() || ""]).toEqual("POWER")
|
||||
expect(changedUserInfoJson.roles[<string>app.appId]).toBeDefined()
|
||||
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("POWER")
|
||||
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue