From bd82872282a65c597346aa8b84318bd724bd0b8e Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Fri, 25 Mar 2022 12:19:15 +0100 Subject: [PATCH] Make the export tab tests more stable (#2339) --- cypress/integration/client_authorization_test.spec.ts | 1 - .../admin_console/manage/clients/AuthorizationTab.ts | 4 ++++ src/clients/authorization/AuthorizationExport.tsx | 8 +++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cypress/integration/client_authorization_test.spec.ts b/cypress/integration/client_authorization_test.spec.ts index bb01fb27ba..dc2cb81d5c 100644 --- a/cypress/integration/client_authorization_test.spec.ts +++ b/cypress/integration/client_authorization_test.spec.ts @@ -152,7 +152,6 @@ describe("Client authentication subtab", () => { it("Should copy auth details", () => { authenticationTab.goToExportSubTab(); authenticationTab.copy(); - masthead.checkNotificationMessage("Authorization details copied.", true); }); diff --git a/cypress/support/pages/admin_console/manage/clients/AuthorizationTab.ts b/cypress/support/pages/admin_console/manage/clients/AuthorizationTab.ts index 8577e4b686..5b6cfdf3aa 100644 --- a/cypress/support/pages/admin_console/manage/clients/AuthorizationTab.ts +++ b/cypress/support/pages/admin_console/manage/clients/AuthorizationTab.ts @@ -48,7 +48,11 @@ export default class AuthorizationTab { } goToExportSubTab() { + cy.intercept( + "/admin/realms/master/clients/*/authz/resource-server/settings" + ).as("export-load"); cy.findByTestId(this.exportTabName).click(); + cy.wait(["@export-load"]); return this; } diff --git a/src/clients/authorization/AuthorizationExport.tsx b/src/clients/authorization/AuthorizationExport.tsx index b1d7ad1c25..1faff7cf17 100644 --- a/src/clients/authorization/AuthorizationExport.tsx +++ b/src/clients/authorization/AuthorizationExport.tsx @@ -15,10 +15,12 @@ import { useAdminClient, useFetch } from "../../context/auth/AdminClient"; import { useParams } from "react-router-dom"; import FileSaver from "file-saver"; import { prettyPrintJSON } from "../../util"; -import "./authorization-details.css"; import { useAlerts } from "../../components/alert/Alerts"; import type { ClientParams } from "../routes/Client"; import type ResourceServerRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceServerRepresentation"; +import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner"; + +import "./authorization-details.css"; export const AuthorizationExport = () => { const { t } = useTranslation("clients"); @@ -57,6 +59,10 @@ export const AuthorizationExport = () => { } }; + if (!code) { + return ; + } + return (