From df5a06a3bef44be42e57ab915d8bc65c123b3f21 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Wed, 26 May 2021 10:05:53 +0200 Subject: [PATCH 1/2] makes client scope test more reliable --- cypress/integration/client_scopes_test.spec.ts | 4 ++-- cypress/support/pages/admin_console/ListingPage.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cypress/integration/client_scopes_test.spec.ts b/cypress/integration/client_scopes_test.spec.ts index 7f340c3c84..2b23f3b607 100644 --- a/cypress/integration/client_scopes_test.spec.ts +++ b/cypress/integration/client_scopes_test.spec.ts @@ -50,6 +50,7 @@ describe("Client Scopes test", function () { masthead.checkNotificationMessage("Client scope created"); sidebarPage.goToClientScopes(); + cy.get(".pf-c-spinner__tail-ball").should("not.exist"); // Delete listingPage.itemExist(itemId).deleteItem(itemId); @@ -59,8 +60,7 @@ describe("Client Scopes test", function () { masthead.checkNotificationMessage("The client scope has been deleted"); - listingPage // It is not refreshing after delete - .itemExist(itemId, false); + listingPage.itemExist(itemId, false); }); }); diff --git a/cypress/support/pages/admin_console/ListingPage.ts b/cypress/support/pages/admin_console/ListingPage.ts index d6d3544542..f50031e1a0 100644 --- a/cypress/support/pages/admin_console/ListingPage.ts +++ b/cypress/support/pages/admin_console/ListingPage.ts @@ -50,7 +50,7 @@ export default class ListingPage { clickRowDetails(itemName: string) { cy.get(this.itemsRows) .contains(itemName) - .parentsUntil("tbody") + .parentsUntil("tr") .find(this.itemRowDrpDwn) .click(); return this; From bb090200fe38dffedd9f1aabaf62c298578492f1 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Thu, 27 May 2021 13:41:29 +0200 Subject: [PATCH 2/2] catch errors when removing scope type --- .../pages/admin_console/ListingPage.ts | 35 +++++++------------ src/client-scopes/ClientScopesSection.tsx | 9 ++++- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/cypress/support/pages/admin_console/ListingPage.ts b/cypress/support/pages/admin_console/ListingPage.ts index f50031e1a0..2b48326884 100644 --- a/cypress/support/pages/admin_console/ListingPage.ts +++ b/cypress/support/pages/admin_console/ListingPage.ts @@ -1,26 +1,15 @@ export default class ListingPage { - searchInput: string; - itemsRows: string; - itemRowDrpDwn: string; - exportBtn: string; - deleteBtn: string; - searchBtn: string; - createBtn: string; - importBtn: string; - - constructor() { - this.searchInput = '.pf-c-toolbar__item [type="search"]:visible'; - this.itemsRows = "table"; - this.itemRowDrpDwn = ".pf-c-dropdown > button"; - this.exportBtn = '[role="menuitem"]:nth-child(1)'; - this.deleteBtn = '[role="menuitem"]:nth-child(2)'; - this.searchBtn = - ".pf-c-page__main .pf-c-toolbar__content-section button.pf-m-control:visible"; - this.createBtn = - ".pf-c-page__main .pf-c-toolbar__content-section button.pf-m-primary:visible"; - this.importBtn = - ".pf-c-page__main .pf-c-toolbar__content-section button.pf-m-link"; - } + private searchInput = '.pf-c-toolbar__item [type="search"]:visible'; + private itemsRows = "table"; + private itemRowDrpDwn = ".pf-c-dropdown__toggle"; + public exportBtn = '[role="menuitem"]:nth-child(1)'; + public deleteBtn = '[role="menuitem"]:nth-child(2)'; + private searchBtn = + ".pf-c-page__main .pf-c-toolbar__content-section button.pf-m-control:visible"; + private createBtn = + ".pf-c-page__main .pf-c-toolbar__content-section button.pf-m-primary:visible"; + private importBtn = + ".pf-c-page__main .pf-c-toolbar__content-section button.pf-m-link"; goToCreateItem() { cy.get(this.createBtn).click(); @@ -50,7 +39,7 @@ export default class ListingPage { clickRowDetails(itemName: string) { cy.get(this.itemsRows) .contains(itemName) - .parentsUntil("tr") + .parentsUntil("tbody") .find(this.itemRowDrpDwn) .click(); return this; diff --git a/src/client-scopes/ClientScopesSection.tsx b/src/client-scopes/ClientScopesSection.tsx index 94a3350667..0d44bb0197 100644 --- a/src/client-scopes/ClientScopesSection.tsx +++ b/src/client-scopes/ClientScopesSection.tsx @@ -83,7 +83,14 @@ export const ClientScopesSection = () => { onConfirm: async () => { try { for (const scope of selectedScopes) { - await removeScope(adminClient, scope); + try { + await removeScope(adminClient, scope); + } catch (error) { + console.warn( + "could not remove scope", + error.response?.data?.errorMessage || error + ); + } await adminClient.clientScopes.del({ id: scope.id! }); } addAlert(t("deletedSuccess"), AlertVariant.success);