Filter dedicated client scopes when searching (#28433)

Closes #28431

Signed-off-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
Jon Koops 2024-04-04 13:28:09 +02:00 committed by GitHub
parent 71eacdc1c5
commit 7cbe609571
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 22 additions and 18 deletions

View file

@ -102,7 +102,7 @@ describe("Clients test", () => {
commonPage
.tableUtils()
.checkRowItemExists(clientScopeName + 0)
.checkRowItemsEqualTo(2);
.checkRowItemsEqualTo(1);
});
it("Should search non-existent client scope by name", () => {
@ -187,7 +187,7 @@ describe("Clients test", () => {
commonPage.modalUtils().confirmModal();
commonPage.masthead().checkNotificationMessage(msgScopeMappingRemoved);
commonPage.tableToolbarUtils().searchItem(itemName, false);
commonPage.tableUtils().checkRowItemExists(itemName, false);
listingPage.assertNoResults();
});
it("Should remove multiple client scopes from search bar", () => {

View file

@ -151,7 +151,7 @@ describe("Realm roles test", () => {
it("Should search non-existent associated role by name", () => {
const itemName = "non-existent-associated-role";
listingPage.searchItem(itemName, false);
cy.findByTestId(listingPage.emptyState).should("exist");
listingPage.assertNoResults();
});
it("Should hide inherited roles test", () => {

View file

@ -264,7 +264,7 @@ describe("User Fed LDAP mapper tests", () => {
providersPage.clickExistingCard(ldapName);
providersPage.goToMappers();
listingPage.searchItem(nonexistingSearchTerm, false);
cy.findByTestId(listingPage.emptyState).should("exist");
listingPage.assertNoResults();
});
// *** test cleanup ***

View file

@ -127,7 +127,7 @@ describe("User creation", () => {
it("Search non-existing user test", () => {
listingPage.searchItem("user_DNE");
cy.findByTestId(listingPage.emptyState).should("exist");
listingPage.assertNoResults();
});
it("User details test", () => {

View file

@ -34,7 +34,7 @@ export default class ListingPage extends CommonElements {
#itemsRows = "table:visible";
#deleteUserButton = "delete-user-btn";
#emptyListImg = '[role="tabpanel"]:not([hidden]) [data-testid="empty-state"]';
public emptyState = "empty-state";
#emptyState = "empty-state";
#itemRowDrpDwn = ".pf-c-dropdown__toggle";
#itemRowSelect = ".pf-c-select__toggle:nth-child(1)";
#itemRowSelectItem = ".pf-c-select__menu-item";
@ -401,6 +401,10 @@ export default class ListingPage extends CommonElements {
return this;
}
assertNoResults() {
cy.findByTestId(this.#emptyState).should("exist");
}
assertDefaultResource() {
this.assertResource("Default Resource");
return this;

View file

@ -5,14 +5,12 @@ export default class TablePage extends CommonElements {
#tableRowItemChckBx: string;
#tableHeaderRowItem: string;
#tableInModal: boolean;
static tableSelector = "table[aria-label]";
static tableSelector = ".pf-c-table";
constructor(parentElement?: string) {
super(parentElement ?? TablePage.tableSelector + ":visible");
this.#tableRowItem =
this.parentSelector + "tbody tr[data-ouia-component-type]";
this.#tableHeaderRowItem =
this.parentSelector + "thead tr[data-ouia-component-type]";
this.#tableRowItem = this.parentSelector + "tbody tr";
this.#tableHeaderRowItem = this.parentSelector + "thead tr";
this.#tableRowItemChckBx = ".pf-c-table__check";
this.#tableInModal = false;
}

View file

@ -165,21 +165,19 @@ export const ClientScopes = ({
return row;
});
const rows = [...optional, ...defaultScopes];
let rows = [...optional, ...defaultScopes];
const names = rows.map((row) => row.name);
setRest(
clientScopes
.filter((scope) => !names.includes(scope.name))
.filter((scope) => scope.protocol === protocol),
);
const filter =
searchType === "name" ? nameFilter(search) : typeFilter(searchTypeType);
const firstNum = Number(first);
const page = localeSort(rows.filter(filter), mapByKey("name"));
rows = localeSort(rows, mapByKey("name"));
if (isViewer) {
page.unshift({
rows.unshift({
id: DEDICATED_ROW,
name: t("dedicatedScopeName", { clientName }),
type: AllClientScopes.none,
@ -187,7 +185,11 @@ export const ClientScopes = ({
});
}
return page.slice(firstNum, firstNum + Number(max));
const filter =
searchType === "name" ? nameFilter(search) : typeFilter(searchTypeType);
const firstNum = Number(first);
return rows.filter(filter).slice(firstNum, firstNum + Number(max));
};
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({