Change the default role mapping filter to clients (#29405)
Client roles are more common that realm roles, so we should start the user off looking at a more useful set of options. Signed-off-by: James Hewitt <james.hewitt@uk.ibm.com>
This commit is contained in:
parent
2c8f890251
commit
ee93561706
10 changed files with 54 additions and 19 deletions
|
@ -342,8 +342,14 @@ describe("Client Scopes test", () => {
|
||||||
|
|
||||||
it("Assign and unassign role", () => {
|
it("Assign and unassign role", () => {
|
||||||
const role = "admin";
|
const role = "admin";
|
||||||
|
const roleType = "roles";
|
||||||
listingPage.searchItem(scopeName, false).goToItemDetails(scopeName);
|
listingPage.searchItem(scopeName, false).goToItemDetails(scopeName);
|
||||||
scopeTab.goToScopeTab().assignRole().selectRow(role).assign();
|
scopeTab
|
||||||
|
.goToScopeTab()
|
||||||
|
.assignRole()
|
||||||
|
.changeRoleTypeFilter(roleType)
|
||||||
|
.selectRow(role)
|
||||||
|
.assign();
|
||||||
masthead.checkNotificationMessage("Role mapping updated");
|
masthead.checkNotificationMessage("Role mapping updated");
|
||||||
scopeTab.checkRoles([role]);
|
scopeTab.checkRoles([role]);
|
||||||
scopeTab.hideInheritedRoles().selectRow(role).unAssign();
|
scopeTab.hideInheritedRoles().selectRow(role).unAssign();
|
||||||
|
@ -446,6 +452,7 @@ describe("Client Scopes test", () => {
|
||||||
const predefinedMapper = "Allowed Web Origins";
|
const predefinedMapper = "Allowed Web Origins";
|
||||||
const scopeTab = new RoleMappingTab("client-scope");
|
const scopeTab = new RoleMappingTab("client-scope");
|
||||||
const role = "admin";
|
const role = "admin";
|
||||||
|
const roleType = "roles";
|
||||||
|
|
||||||
listingPage.goToCreateItem();
|
listingPage.goToCreateItem();
|
||||||
createClientScopePage.fillClientScopeData(scopeName).save();
|
createClientScopePage.fillClientScopeData(scopeName).save();
|
||||||
|
@ -475,7 +482,12 @@ describe("Client Scopes test", () => {
|
||||||
cy.checkA11y();
|
cy.checkA11y();
|
||||||
cy.findByTestId("cancel").click();
|
cy.findByTestId("cancel").click();
|
||||||
|
|
||||||
scopeTab.goToScopeTab().assignRole().selectRow(role).assign();
|
scopeTab
|
||||||
|
.goToScopeTab()
|
||||||
|
.assignRole()
|
||||||
|
.changeRoleTypeFilter(roleType)
|
||||||
|
.selectRow(role)
|
||||||
|
.assign();
|
||||||
cy.checkA11y();
|
cy.checkA11y();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -932,6 +932,7 @@ describe("Clients test", () => {
|
||||||
const serviceAccountTab = new RoleMappingTab("user");
|
const serviceAccountTab = new RoleMappingTab("user");
|
||||||
const serviceAccountName = "service-account-client";
|
const serviceAccountName = "service-account-client";
|
||||||
const createRealmRoleName = `create-realm-${uuid()}`;
|
const createRealmRoleName = `create-realm-${uuid()}`;
|
||||||
|
const createRealmRoleType = `roles`;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
await adminClient.inRealm(realmName, () =>
|
await adminClient.inRealm(realmName, () =>
|
||||||
|
@ -1008,6 +1009,7 @@ describe("Clients test", () => {
|
||||||
serviceAccountTab
|
serviceAccountTab
|
||||||
.goToServiceAccountTab()
|
.goToServiceAccountTab()
|
||||||
.assignRole(false)
|
.assignRole(false)
|
||||||
|
.changeRoleTypeFilter(createRealmRoleType)
|
||||||
.selectRow(createRealmRoleName, true)
|
.selectRow(createRealmRoleName, true)
|
||||||
.assign();
|
.assign();
|
||||||
commonPage.masthead().checkNotificationMessage("Role mapping updated");
|
commonPage.masthead().checkNotificationMessage("Role mapping updated");
|
||||||
|
@ -1029,6 +1031,7 @@ describe("Clients test", () => {
|
||||||
commonPage.sidebar().waitForPageLoad();
|
commonPage.sidebar().waitForPageLoad();
|
||||||
|
|
||||||
serviceAccountTab
|
serviceAccountTab
|
||||||
|
.changeRoleTypeFilter("roles")
|
||||||
.selectRow("offline_access", true)
|
.selectRow("offline_access", true)
|
||||||
.selectRow(createRealmRoleName, true)
|
.selectRow(createRealmRoleName, true)
|
||||||
.assign();
|
.assign();
|
||||||
|
|
|
@ -466,8 +466,10 @@ describe("Group test", () => {
|
||||||
|
|
||||||
it("Assign roles from empty state", () => {
|
it("Assign roles from empty state", () => {
|
||||||
roleMappingTab.assignRole();
|
roleMappingTab.assignRole();
|
||||||
groupDetailPage.createRoleMapping();
|
roleMappingTab
|
||||||
roleMappingTab.assign();
|
.changeRoleTypeFilter("roles")
|
||||||
|
.selectRow("default-roles-")
|
||||||
|
.assign();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Show and search roles", () => {
|
it("Show and search roles", () => {
|
||||||
|
|
|
@ -36,9 +36,10 @@ describe("Realm settings - User registration tab", () => {
|
||||||
|
|
||||||
it("Add admin role", () => {
|
it("Add admin role", () => {
|
||||||
const role = "admin";
|
const role = "admin";
|
||||||
|
const roleType = "roles";
|
||||||
userRegistration.addRole();
|
userRegistration.addRole();
|
||||||
sidebarPage.waitForPageLoad();
|
sidebarPage.waitForPageLoad();
|
||||||
userRegistration.selectRow(role).assign();
|
userRegistration.changeRoleTypeFilter(roleType).selectRow(role).assign();
|
||||||
masthead.checkNotificationMessage("Associated roles have been added");
|
masthead.checkNotificationMessage("Associated roles have been added");
|
||||||
listingPage.searchItem(role, false).itemExist(role);
|
listingPage.searchItem(role, false).itemExist(role);
|
||||||
|
|
||||||
|
|
|
@ -490,6 +490,7 @@ describe("User creation", () => {
|
||||||
describe("Accessibility tests for users", () => {
|
describe("Accessibility tests for users", () => {
|
||||||
const a11yUser = "a11y-user";
|
const a11yUser = "a11y-user";
|
||||||
const role = "admin";
|
const role = "admin";
|
||||||
|
const roleType = "roles";
|
||||||
const roleMappingTab = new RoleMappingTab("");
|
const roleMappingTab = new RoleMappingTab("");
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -552,7 +553,7 @@ describe("User creation", () => {
|
||||||
roleMappingTab.goToRoleMappingTab();
|
roleMappingTab.goToRoleMappingTab();
|
||||||
cy.findByTestId("assignRole").click();
|
cy.findByTestId("assignRole").click();
|
||||||
cy.checkA11y();
|
cy.checkA11y();
|
||||||
roleMappingTab.selectRow(role).assign();
|
roleMappingTab.changeRoleTypeFilter(roleType).selectRow(role).assign();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Check a11y violations on user groups tab", () => {
|
it("Check a11y violations on user groups tab", () => {
|
||||||
|
|
|
@ -13,6 +13,7 @@ export default class RoleMappingTab {
|
||||||
#assignedRolesTable = "assigned-roles";
|
#assignedRolesTable = "assigned-roles";
|
||||||
#namesColumn = 'td[data-label="Name"]:visible';
|
#namesColumn = 'td[data-label="Name"]:visible';
|
||||||
#roleMappingTab = "role-mapping-tab";
|
#roleMappingTab = "role-mapping-tab";
|
||||||
|
#filterTypeDropdown = "filter-type-dropdown";
|
||||||
|
|
||||||
constructor(type: string) {
|
constructor(type: string) {
|
||||||
this.#type = type;
|
this.#type = type;
|
||||||
|
@ -60,6 +61,16 @@ export default class RoleMappingTab {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeRoleTypeFilter(filter: string) {
|
||||||
|
// Invert the filter because the testid of the DropdownItem is the current filter
|
||||||
|
const option = filter == "roles" ? "clients" : "roles";
|
||||||
|
|
||||||
|
cy.findByTestId(this.#filterTypeDropdown).click();
|
||||||
|
cy.findByTestId(option).click();
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
selectRow(name: string, modal = false) {
|
selectRow(name: string, modal = false) {
|
||||||
cy.get(modal ? ".pf-v5-c-modal-box " : "" + this.#namesColumn)
|
cy.get(modal ? ".pf-v5-c-modal-box " : "" + this.#namesColumn)
|
||||||
.contains(name)
|
.contains(name)
|
||||||
|
|
|
@ -151,10 +151,6 @@ export default class GroupDetailPage extends GroupPage {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
createRoleMapping() {
|
|
||||||
listingPage.clickItemCheckbox("default-roles-");
|
|
||||||
}
|
|
||||||
|
|
||||||
checkDefaultRole() {
|
checkDefaultRole() {
|
||||||
listingPage.itemExist("default-roles");
|
listingPage.itemExist("default-roles");
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ export default class AssociatedRolesPage {
|
||||||
#addAssociatedRolesModalButton = "assign";
|
#addAssociatedRolesModalButton = "assign";
|
||||||
#compositeRoleBadge = "composite-role-badge";
|
#compositeRoleBadge = "composite-role-badge";
|
||||||
#filterTypeDropdown = "filter-type-dropdown";
|
#filterTypeDropdown = "filter-type-dropdown";
|
||||||
#filterTypeDropdownItem = "roles";
|
#filterTypeDropdownItem = "clients";
|
||||||
#usersPage = "users-page";
|
#usersPage = "users-page";
|
||||||
#removeRolesButton = "unAssignRole";
|
#removeRolesButton = "unAssignRole";
|
||||||
#addRoleTable = '[aria-label="Roles"] td[data-label="Name"]';
|
#addRoleTable = '[aria-label="Roles"] td[data-label="Name"]';
|
||||||
|
@ -15,6 +15,10 @@ export default class AssociatedRolesPage {
|
||||||
|
|
||||||
cy.findByTestId(this.#addRolesDropdownItem).click();
|
cy.findByTestId(this.#addRolesDropdownItem).click();
|
||||||
|
|
||||||
|
cy.findByTestId(this.#filterTypeDropdown).click();
|
||||||
|
|
||||||
|
cy.findByTestId(this.#filterTypeDropdownItem).click();
|
||||||
|
|
||||||
cy.get(this.#addRoleTable)
|
cy.get(this.#addRoleTable)
|
||||||
.contains(roleName)
|
.contains(roleName)
|
||||||
.parent()
|
.parent()
|
||||||
|
@ -36,7 +40,7 @@ export default class AssociatedRolesPage {
|
||||||
addAssociatedRoleFromSearchBar(roleName: string, isClientRole?: boolean) {
|
addAssociatedRoleFromSearchBar(roleName: string, isClientRole?: boolean) {
|
||||||
cy.findByTestId(this.#addRoleToolbarButton).click({ force: true });
|
cy.findByTestId(this.#addRoleToolbarButton).click({ force: true });
|
||||||
|
|
||||||
if (isClientRole) {
|
if (!isClientRole) {
|
||||||
cy.findByTestId(this.#filterTypeDropdown).click();
|
cy.findByTestId(this.#filterTypeDropdown).click();
|
||||||
cy.findByTestId(this.#filterTypeDropdownItem).click();
|
cy.findByTestId(this.#filterTypeDropdownItem).click();
|
||||||
}
|
}
|
||||||
|
@ -59,10 +63,6 @@ export default class AssociatedRolesPage {
|
||||||
addAssociatedClientRole(roleName: string) {
|
addAssociatedClientRole(roleName: string) {
|
||||||
cy.findByTestId(this.#addRoleToolbarButton).click();
|
cy.findByTestId(this.#addRoleToolbarButton).click();
|
||||||
|
|
||||||
cy.findByTestId(this.#filterTypeDropdown).click();
|
|
||||||
|
|
||||||
cy.findByTestId(this.#filterTypeDropdownItem).click();
|
|
||||||
|
|
||||||
cy.findByTestId(".pf-v5-c-spinner__tail-ball").should("not.exist");
|
cy.findByTestId(".pf-v5-c-spinner__tail-ball").should("not.exist");
|
||||||
|
|
||||||
cy.get(this.#addRoleTable)
|
cy.get(this.#addRoleTable)
|
||||||
|
|
|
@ -5,6 +5,7 @@ export default class UserRegistration {
|
||||||
#addDefaultGroupBtn = "no-default-groups-empty-action";
|
#addDefaultGroupBtn = "no-default-groups-empty-action";
|
||||||
#namesColumn = 'tbody td[data-label="Name"]:visible';
|
#namesColumn = 'tbody td[data-label="Name"]:visible';
|
||||||
#addBtn = "assign";
|
#addBtn = "assign";
|
||||||
|
#filterTypeDropdown = "filter-type-dropdown";
|
||||||
|
|
||||||
goToTab() {
|
goToTab() {
|
||||||
cy.findByTestId(this.#userRegistrationTab).click({ force: true });
|
cy.findByTestId(this.#userRegistrationTab).click({ force: true });
|
||||||
|
@ -26,6 +27,16 @@ export default class UserRegistration {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeRoleTypeFilter(filter: string) {
|
||||||
|
// Invert the filter because the testid is the current selection
|
||||||
|
const option = filter == "roles" ? "clients" : "roles";
|
||||||
|
|
||||||
|
cy.findByTestId(this.#filterTypeDropdown).click();
|
||||||
|
cy.findByTestId(option).click();
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
selectRow(name: string) {
|
selectRow(name: string) {
|
||||||
cy.get(this.#namesColumn)
|
cy.get(this.#namesColumn)
|
||||||
.contains(name)
|
.contains(name)
|
||||||
|
|
|
@ -50,9 +50,7 @@ export const AddRoleMappingModal = ({
|
||||||
|
|
||||||
const [searchToggle, setSearchToggle] = useState(false);
|
const [searchToggle, setSearchToggle] = useState(false);
|
||||||
|
|
||||||
const [filterType, setFilterType] = useState<FilterType>(
|
const [filterType, setFilterType] = useState<FilterType>("clients");
|
||||||
canViewRealmRoles ? "roles" : "clients",
|
|
||||||
);
|
|
||||||
const [selectedRows, setSelectedRows] = useState<Row[]>([]);
|
const [selectedRows, setSelectedRows] = useState<Row[]>([]);
|
||||||
const [key, setKey] = useState(0);
|
const [key, setKey] = useState(0);
|
||||||
const refresh = () => setKey(key + 1);
|
const refresh = () => setKey(key + 1);
|
||||||
|
|
Loading…
Reference in a new issue