From d390fe7d8d83aebdf607948cd80b062218639681 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Fri, 9 Dec 2022 18:00:13 +0000 Subject: [PATCH] Rename users methods --- .../TestConfiguration/userManagement.ts | 16 +++--- .../internal-api/fixtures/userManagement.ts | 4 +- .../userManagement/userManagement.spec.ts | 50 +++++++++---------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/qa-core/src/config/internal-api/TestConfiguration/userManagement.ts b/qa-core/src/config/internal-api/TestConfiguration/userManagement.ts index 4a6dbfd1e1..e323c3a098 100644 --- a/qa-core/src/config/internal-api/TestConfiguration/userManagement.ts +++ b/qa-core/src/config/internal-api/TestConfiguration/userManagement.ts @@ -10,7 +10,7 @@ export default class UserManagementApi { this.api = apiClient } - async searchUsers(): Promise<[Response, Partial[]]> { + async search(): Promise<[Response, Partial[]]> { const response = await this.api.post(`/global/users/search`, {}) const json = await response.json() expect(response).toHaveStatusCode(200) @@ -25,7 +25,7 @@ export default class UserManagementApi { return [response, json] } - async getAllUsers(): Promise<[Response, Partial[]]> { + async getAll(): Promise<[Response, Partial[]]> { 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: Partial[]): Promise<[Response, any]> { + async addMultiple(userList: Partial[]): Promise<[Response, any]> { const body = { create: { users: userList, @@ -48,7 +48,7 @@ export default class UserManagementApi { return [response, json] } - async deleteMultipleUsers(userId: string[]): Promise<[Response, responseMessage]> { + async deleteMultiple(userId: string[]): Promise<[Response, responseMessage]> { const body = { delete: { userIds: [ @@ -64,7 +64,7 @@ export default class UserManagementApi { expect(json.deleted.successful[0].userId).toEqual(userId) return [response, json] } - async deleteUser(userId: string): Promise<[Response, UserDeletedEvent]> { + async delete(userId: string): Promise<[Response, UserDeletedEvent]> { const response = await this.api.del(`/global/users/${userId}`) const json = await response.json() expect(response).toHaveStatusCode(200) @@ -72,7 +72,7 @@ export default class UserManagementApi { return [response, json] } - async inviteUser(body: any): Promise<[Response, responseMessage]> { + async invite(body: any): Promise<[Response, responseMessage]> { const response = await this.api.post(`/global/users/multi/invite`, { body }) const json = await response.json() expect(response).toHaveStatusCode(200) @@ -90,7 +90,7 @@ export default class UserManagementApi { return [response, json] } - async changeUserInformation(body: any): Promise<[Response, User]> { + async updateInfo(body: any): Promise<[Response, User]> { const response = await this.api.post(`/global/users/`, { body }) const json = await response.json() expect(response).toHaveStatusCode(200) @@ -108,7 +108,7 @@ export default class UserManagementApi { return [response, json] } - async getUserInformation(userId: string): Promise<[Response, User]> { + async getInfo(userId: string): Promise<[Response, User]> { const response = await this.api.get(`/global/users/${userId}`) const json = await response.json() expect(response).toHaveStatusCode(200) diff --git a/qa-core/src/config/internal-api/fixtures/userManagement.ts b/qa-core/src/config/internal-api/fixtures/userManagement.ts index 077f42ae57..446ae3b0c5 100644 --- a/qa-core/src/config/internal-api/fixtures/userManagement.ts +++ b/qa-core/src/config/internal-api/fixtures/userManagement.ts @@ -49,9 +49,9 @@ const generateAppUser = (): Partial => { } export const generateInviteUser = (): Object[] => { - //const randomId = generator.guid(); + const randomId = generator.guid(); return [{ - email: `pedro+test@budibase.com`, + email: `pedro+${randomId}@budibase.com`, userInfo: { userGroups: [] } diff --git a/qa-core/src/tests/internal-api/userManagement/userManagement.spec.ts b/qa-core/src/tests/internal-api/userManagement/userManagement.spec.ts index 4f6eefc247..92ecf96258 100644 --- a/qa-core/src/tests/internal-api/userManagement/userManagement.spec.ts +++ b/qa-core/src/tests/internal-api/userManagement/userManagement.spec.ts @@ -18,7 +18,7 @@ describe("Internal API - User Management & Permissions", () => { }) it("Add Users with different roles", async () => { - await config.users.searchUsers() + await config.users.search() await config.users.getRoles() // These need to be saved to the context so the passwords can be used to login @@ -31,11 +31,11 @@ describe("Internal API - User Management & Permissions", () => { expect(appUser[0].builder?.global).toEqual(false) expect(appUser[0].admin?.global).toEqual(false) - await config.users.addMultipleUsers(admin) - await config.users.addMultipleUsers(developer) - await config.users.addMultipleUsers(appUser) + await config.users.addMultiple(admin) + await config.users.addMultiple(developer) + await config.users.addMultiple(appUser) - const [allUsersResponse, allUsersJson] = await config.users.getAllUsers() + const [allUsersResponse, allUsersJson] = await config.users.getAll() expect(allUsersJson.length).toBeGreaterThan(0) @@ -46,17 +46,17 @@ describe("Internal API - User Management & Permissions", () => { const appUser = generateUser() expect(appUser[0].builder?.global).toEqual(false) expect(appUser[0].admin?.global).toEqual(false) - const [userResponse, userJson] = await config.users.addMultipleUsers(appUser) + const [userResponse, userJson] = await config.users.addMultiple(appUser) const userId = userJson.created.successful[0]._id - await config.users.deleteUser(userId) + await config.users.delete(userId) }) it("Reset Password", async () => { const appUser = generateUser() expect(appUser[0].builder?.global).toEqual(false) expect(appUser[0].admin?.global).toEqual(false) - const [userResponse, userJson] = await config.users.addMultipleUsers(appUser) - const [userInfoResponse, userInfoJson] = await config.users.getUserInformation(userJson.created.successful[0]._id) + const [userResponse, userJson] = await config.users.addMultiple(appUser) + const [userInfoResponse, userInfoJson] = await config.users.getInfo(userJson.created.successful[0]._id) const body: User = { ...userInfoJson, password: "newPassword" @@ -69,8 +69,8 @@ describe("Internal API - User Management & Permissions", () => { const appUser = generateUser() expect(appUser[0].builder?.global).toEqual(false) expect(appUser[0].admin?.global).toEqual(false) - const [userResponse, userJson] = await config.users.addMultipleUsers(appUser) - const [userInfoResponse, userInfoJson] = await config.users.getUserInformation(userJson.created.successful[0]._id) + const [userResponse, userJson] = await config.users.addMultiple(appUser) + const [userInfoResponse, userInfoJson] = await config.users.getInfo(userJson.created.successful[0]._id) const body: User = { ...userInfoJson, firstName: "newFirstName", @@ -79,9 +79,9 @@ describe("Internal API - User Management & Permissions", () => { global: true } } - await config.users.changeUserInformation(body) + await config.users.updateInfo(body) - const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getUserInformation(userJson.created.successful[0]._id) + const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(userJson.created.successful[0]._id) expect(changedUserInfoJson.builder?.global).toBeDefined() expect(changedUserInfoJson.builder?.global).toEqual(true) }) @@ -90,21 +90,21 @@ describe("Internal API - User Management & Permissions", () => { const appUser = generateUser() expect(appUser[0].builder?.global).toEqual(false) expect(appUser[0].admin?.global).toEqual(false) - const [createUserResponse, createUserJson] = await config.users.addMultipleUsers(appUser) + const [createUserResponse, createUserJson] = await config.users.addMultiple(appUser) const app = await config.applications.create(generateApp()) config.applications.api.appId = app.appId - const [userInfoResponse, userInfoJson] = await config.users.getUserInformation(createUserJson.created.successful[0]._id) + const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) const body: User = { ...userInfoJson, roles: { [app.appId?.toString() || ""]: "BASIC", } } - await config.users.changeUserInformation(body) + await config.users.updateInfo(body) - const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getUserInformation(createUserJson.created.successful[0]._id) + const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) expect(changedUserInfoJson.roles[app.appId]).toBeDefined() expect(changedUserInfoJson.roles[app.appId]).toEqual("BASIC") @@ -114,21 +114,21 @@ describe("Internal API - User Management & Permissions", () => { const adminUser = generateUser(1, "admin") expect(adminUser[0].builder?.global).toEqual(true) expect(adminUser[0].admin?.global).toEqual(true) - const [createUserResponse, createUserJson] = await config.users.addMultipleUsers(adminUser) + const [createUserResponse, createUserJson] = await config.users.addMultiple(adminUser) const app = await config.applications.create(generateApp()) config.applications.api.appId = app.appId - const [userInfoResponse, userInfoJson] = await config.users.getUserInformation(createUserJson.created.successful[0]._id) + const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) const body: User = { ...userInfoJson, roles: { [app.appId?.toString() || ""]: "ADMIN", } } - await config.users.changeUserInformation(body) + await config.users.updateInfo(body) - const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getUserInformation(createUserJson.created.successful[0]._id) + const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) expect(changedUserInfoJson.roles[app.appId]).toBeDefined() expect(changedUserInfoJson.roles[app.appId]).toEqual("ADMIN") @@ -138,21 +138,21 @@ describe("Internal API - User Management & Permissions", () => { const powerUser = generateUser(1, 'developer') expect(powerUser[0].builder?.global).toEqual(true) - const [createUserResponse, createUserJson] = await config.users.addMultipleUsers(powerUser) + const [createUserResponse, createUserJson] = await config.users.addMultiple(powerUser) const app = await config.applications.create(generateApp()) config.applications.api.appId = app.appId - const [userInfoResponse, userInfoJson] = await config.users.getUserInformation(createUserJson.created.successful[0]._id) + const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) const body: User = { ...userInfoJson, roles: { [app.appId?.toString() || ""]: "POWER", } } - await config.users.changeUserInformation(body) + await config.users.updateInfo(body) - const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getUserInformation(createUserJson.created.successful[0]._id) + const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) expect(changedUserInfoJson.roles[app.appId]).toBeDefined() expect(changedUserInfoJson.roles[app.appId]).toEqual("POWER")