2021-03-04 14:26:21 +00:00
|
|
|
export default class CreateUserPage {
|
|
|
|
usernameInput: string;
|
2021-03-04 18:49:05 +00:00
|
|
|
usersEmptyState: string;
|
|
|
|
emptyStateCreateUserBtn: string;
|
|
|
|
searchPgCreateUserBtn: string;
|
2021-03-04 14:26:21 +00:00
|
|
|
saveBtn: string;
|
|
|
|
cancelBtn: string;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
this.usernameInput = "#kc-username";
|
|
|
|
|
2021-03-04 18:49:05 +00:00
|
|
|
this.usersEmptyState = "[data-testid=empty-state]";
|
|
|
|
this.emptyStateCreateUserBtn = "[data-testid=empty-primary-action]";
|
|
|
|
this.searchPgCreateUserBtn = "[data-testid=create-new-user]";
|
2021-03-04 14:26:21 +00:00
|
|
|
this.saveBtn = "[data-testid=create-user]";
|
|
|
|
this.cancelBtn = "[data-testid=cancel-create-user]";
|
|
|
|
}
|
|
|
|
|
|
|
|
//#region General Settings
|
|
|
|
fillRealmRoleData(username: string) {
|
|
|
|
cy.get(this.usernameInput).clear();
|
|
|
|
|
|
|
|
if (username) {
|
|
|
|
cy.get(this.usernameInput).type(username);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
goToCreateUser() {
|
2021-03-04 18:49:05 +00:00
|
|
|
cy.wait(100);
|
|
|
|
cy.get("body").then((body) => {
|
|
|
|
if (body.find(this.usersEmptyState).length > 0) {
|
|
|
|
cy.get(this.emptyStateCreateUserBtn).click();
|
|
|
|
} else if (body.find("[data-testid=search-users-title]").length > 0) {
|
|
|
|
cy.get(this.searchPgCreateUserBtn).click();
|
|
|
|
} else {
|
|
|
|
cy.get("[data-testid=add-user]").click();
|
|
|
|
}
|
|
|
|
});
|
2021-03-04 14:26:21 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
save() {
|
|
|
|
cy.get(this.saveBtn).click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
cancel() {
|
|
|
|
cy.get(this.cancelBtn).click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|