Merge pull request #10824 from Budibase/test/qa-18-api-automation-testing-permissionsuser-settings
Add more tests for user settings
This commit is contained in:
commit
d1622f0d33
|
@ -14,10 +14,11 @@ export default class SelfAPI extends BaseAPI {
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
|
||||||
async changeSelfPassword(body: Partial<User>): Promise<[Response, User]> {
|
async changeSelfPassword(): Promise<[Response, User]> {
|
||||||
|
const body = {
|
||||||
|
password: "newPassword",
|
||||||
|
}
|
||||||
const [response, json] = await this.post(`/global/self`, body)
|
const [response, json] = await this.post(`/global/self`, body)
|
||||||
expect(json._id).toEqual(body._id)
|
|
||||||
expect(json._rev).not.toEqual(body._rev)
|
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,4 +27,15 @@ export default class SelfAPI extends BaseAPI {
|
||||||
expect(json).toHaveProperty("apiKey")
|
expect(json).toHaveProperty("apiKey")
|
||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async changeUserInfo(body: Partial<User>): Promise<[Response, User]> {
|
||||||
|
const [response, json] = await this.post(`/global/self`, body)
|
||||||
|
return [response, json]
|
||||||
|
}
|
||||||
|
|
||||||
|
async generateApiKey(): Promise<[Response, ApiKeyResponse]> {
|
||||||
|
const [response, json] = await this.post(`/global/self/api_key`)
|
||||||
|
expect(json).toHaveProperty("apiKey")
|
||||||
|
return [response, json]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,4 +87,29 @@ describe("Internal API - User Management & Permissions", () => {
|
||||||
expect(changedUserInfoJson.builder?.global).toBeDefined()
|
expect(changedUserInfoJson.builder?.global).toBeDefined()
|
||||||
expect(changedUserInfoJson.builder?.global).toEqual(true)
|
expect(changedUserInfoJson.builder?.global).toEqual(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("Set First and Last Name", async () => {
|
||||||
|
const body: Partial<User> = {
|
||||||
|
firstName: "newFirstName",
|
||||||
|
lastName: "newLastName",
|
||||||
|
}
|
||||||
|
await config.api.self.changeUserInfo(body)
|
||||||
|
|
||||||
|
const [changedUserInfoResponse, changedUserInfoJson] =
|
||||||
|
await config.api.self.getSelf()
|
||||||
|
expect(changedUserInfoJson.firstName).toEqual("newFirstName")
|
||||||
|
expect(changedUserInfoJson.lastName).toEqual("newLastName")
|
||||||
|
})
|
||||||
|
|
||||||
|
it("Generate API key", async () => {
|
||||||
|
await config.api.self.generateApiKey()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("Change Password", async () => {
|
||||||
|
await config.api.self.changeSelfPassword()
|
||||||
|
const [changedUserInfoResponse, changedUserInfoJson] =
|
||||||
|
await config.api.self.getSelf()
|
||||||
|
|
||||||
|
await config.login(changedUserInfoJson.email!, "newPassword")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue