diff --git a/cypress/integration/realm_settings_test.spec.ts b/cypress/integration/realm_settings_test.spec.ts
index 61116f5714..80af0e3003 100644
--- a/cypress/integration/realm_settings_test.spec.ts
+++ b/cypress/integration/realm_settings_test.spec.ts
@@ -492,6 +492,49 @@ describe("Realm settings tests", () => {
realmSettingsPage.shouldCompleteAndCreateNewClientProfile();
realmSettingsPage.shouldNotCreateDuplicateClientProfile();
});
+
+ it("Should edit client profile", () => {
+ realmSettingsPage.shouldEditClientProfile();
+ });
+
+ it("Should check that edited client profile is now listed", () => {
+ sidebarPage.goToRealmSettings();
+ cy.findByTestId("rs-clientPolicies-tab").click();
+ cy.findByTestId("rs-policies-clientProfiles-tab").click();
+ realmSettingsPage.shouldCheckEditedClientProfileListed();
+ });
+
+ it("Should show error when client profile left blank", () => {
+ realmSettingsPage.shouldShowErrorWhenNameBlank();
+ });
+
+ it("Should revert back to the previous profile name", () => {
+ realmSettingsPage.shouldReloadClientProfileEdits();
+ });
+
+ it("Should not have executors configured by default", () => {
+ realmSettingsPage.shouldNotHaveExecutorsConfigured();
+ });
+
+ it("Should cancel adding a new executor to a client profile", () => {
+ realmSettingsPage.shouldCancelAddingExecutor();
+ });
+
+ it("Should add a new executor to a client profile", () => {
+ realmSettingsPage.shouldAddExecutor();
+ });
+
+ it("Should cancel deleting executor from a client profile", () => {
+ realmSettingsPage.shouldCancelDeletingExecutor();
+ });
+
+ it("Should delete executor from a client profile", () => {
+ realmSettingsPage.shouldDeleteExecutor();
+ });
+
+ it("Should delete edited client profile", () => {
+ realmSettingsPage.shouldDeleteEditedProfile();
+ });
});
describe.skip("Realm settings client policies tab tests", () => {
diff --git a/cypress/support/pages/admin_console/manage/realm_settings/RealmSettingsPage.ts b/cypress/support/pages/admin_console/manage/realm_settings/RealmSettingsPage.ts
index 3d511e81c2..e2b8d58d89 100644
--- a/cypress/support/pages/admin_console/manage/realm_settings/RealmSettingsPage.ts
+++ b/cypress/support/pages/admin_console/manage/realm_settings/RealmSettingsPage.ts
@@ -173,6 +173,14 @@ export default class RealmSettingsPage {
private createClientDrpDwn = ".pf-c-dropdown.pf-m-align-right";
private searchFld = "[id^=realm-settings][id$=profilesinput]";
private searchFldPolicies = "[id^=realm-settings][id$=clientPoliciesinput]";
+ private clientProfileOne = 'a[href*="realm-settings/clientPolicies/Test"]';
+ private clientProfileTwo = 'a[href*="realm-settings/clientPolicies/Edit"]';
+ private reloadBtn = "reloadProfile";
+ private addExecutor = "addExecutor";
+ private addExecutorDrpDwn = ".pf-c-select__toggle";
+ private addExecutorDrpDwnOption = "executorType-select";
+ private addExecutorCancelBtn = "addExecutor-cancelBtn";
+ private addExecutorSaveBtn = "addExecutor-saveBtn";
selectLoginThemeType(themeType: string) {
cy.get(this.selectLoginTheme).click();
@@ -578,6 +586,121 @@ export default class RealmSettingsPage {
);
}
+ shouldEditClientProfile() {
+ cy.get(this.clientProfileOne).click();
+ cy.findByTestId(this.newClientProfileNameInput)
+ .click()
+ .clear()
+ .type("Edit");
+ cy.findByTestId(this.newClientProfileDescriptionInput)
+ .click()
+ .clear()
+ .type("Edit Description");
+ cy.findByTestId(this.saveNewClientProfileBtn).click();
+ cy.get(this.alertMessage).should(
+ "be.visible",
+ "Client profile updated successfully"
+ );
+ }
+
+ shouldCheckEditedClientProfileListed() {
+ cy.get("table").should("be.visible").contains("td", "Edit");
+ cy.get("table").should("not.have.text", "Test");
+ }
+
+ shouldShowErrorWhenNameBlank() {
+ cy.get(this.clientProfileTwo).click();
+ cy.findByTestId(this.newClientProfileNameInput).click().clear();
+ cy.get("form").should("not.have.text", "Required field");
+ }
+
+ shouldReloadClientProfileEdits() {
+ cy.get(this.clientProfileTwo).click();
+ cy.findByTestId(this.newClientProfileNameInput).type("Reloading");
+ cy.findByTestId(this.reloadBtn).click();
+ cy.findByTestId(this.newClientProfileNameInput).should(
+ "have.value",
+ "Edit"
+ );
+ }
+
+ shouldNotHaveExecutorsConfigured() {
+ cy.get(this.clientProfileTwo).click();
+ cy.get('h6[class*="kc-emptyExecutors"]').should(
+ "have.text",
+ "No executors configured"
+ );
+ }
+
+ shouldCancelAddingExecutor() {
+ cy.get(this.clientProfileTwo).click();
+ cy.findByTestId(this.addExecutor).click();
+ cy.get(this.addExecutorDrpDwn).click();
+ cy.findByTestId(this.addExecutorDrpDwnOption)
+ .contains("confidential-client")
+ .click();
+ cy.findByTestId(this.addExecutorCancelBtn).click();
+ cy.get('h6[class*="kc-emptyExecutors"]').should(
+ "have.text",
+ "No executors configured"
+ );
+ }
+
+ shouldAddExecutor() {
+ cy.get(this.clientProfileTwo).click();
+ cy.findByTestId(this.addExecutor).click();
+ cy.get(this.addExecutorDrpDwn).click();
+ cy.findByTestId(this.addExecutorDrpDwnOption)
+ .contains("confidential-client")
+ .click();
+ cy.findByTestId(this.addExecutorSaveBtn).click();
+ cy.get(this.alertMessage).should(
+ "be.visible",
+ "Success! Executor created successfully"
+ );
+ cy.get('ul[class*="pf-c-data-list"]').should(
+ "have.text",
+ "confidential-client"
+ );
+ }
+
+ shouldCancelDeletingExecutor() {
+ cy.get(this.clientProfileTwo).click();
+ cy.get('svg[class*="kc-executor-trash-icon"]').click();
+ cy.get(this.deleteDialogTitle).contains("Delete executor?");
+ cy.get(this.deleteDialogBodyText).contains(
+ "The action will permanently delete confidential-client. This cannot be undone."
+ );
+ cy.findByTestId("modalConfirm").contains("Delete");
+ cy.get(this.deleteDialogCancelBtn).contains("Cancel").click();
+ cy.get('ul[class*="pf-c-data-list"]').should(
+ "have.text",
+ "confidential-client"
+ );
+ }
+
+ shouldDeleteExecutor() {
+ cy.get(this.clientProfileTwo).click();
+ cy.get('svg[class*="kc-executor-trash-icon"]').click();
+ cy.get(this.deleteDialogTitle).contains("Delete executor?");
+ cy.get(this.deleteDialogBodyText).contains(
+ "The action will permanently delete confidential-client. This cannot be undone."
+ );
+ cy.findByTestId("modalConfirm").contains("Delete").click();
+ cy.get('h6[class*="kc-emptyExecutors"]').should(
+ "have.text",
+ "No executors configured"
+ );
+ }
+
+ shouldDeleteEditedProfile() {
+ cy.get(this.moreDrpDwn).last().click();
+ cy.get(this.moreDrpDwnItems).click();
+ cy.findByTestId("modalConfirm").contains("Delete").click();
+ cy.get(this.alertMessage).should("be.visible", "Client profile deleted");
+ cy.get("table").should("not.have.text", "Edit");
+ }
+
shouldNotCreateDuplicateClientPolicy() {
cy.get(this.alertMessage).should(
"be.visible",
diff --git a/src/realm-settings/ClientProfileForm.tsx b/src/realm-settings/ClientProfileForm.tsx
index 63a4a54c87..b5cc2adebb 100644
--- a/src/realm-settings/ClientProfileForm.tsx
+++ b/src/realm-settings/ClientProfileForm.tsx
@@ -321,7 +321,7 @@ export default function ClientProfileForm() {
)}
variant="link"
className="kc-addExecutor"
- data-testid="cancelCreateProfile"
+ data-testid="addExecutor"
icon={}
>
{t("realm-settings:addExecutor")}
diff --git a/src/realm-settings/ExecutorForm.tsx b/src/realm-settings/ExecutorForm.tsx
index 278ab46020..f856e212af 100644
--- a/src/realm-settings/ExecutorForm.tsx
+++ b/src/realm-settings/ExecutorForm.tsx
@@ -183,7 +183,7 @@ export default function ExecutorForm() {
@@ -195,7 +195,7 @@ export default function ExecutorForm() {
to={`/${realm}/realm-settings/clientPolicies/${profileName}`}
/>
)}
- data-testid="realm-settings-add-executor-cancel-button"
+ data-testid="addExecutor-cancelBtn"
>
{t("common:cancel")}
diff --git a/src/realm-settings/routes/ClientProfile.ts b/src/realm-settings/routes/ClientProfile.ts
index 5b1ece3520..54e6aa60c8 100644
--- a/src/realm-settings/routes/ClientProfile.ts
+++ b/src/realm-settings/routes/ClientProfile.ts
@@ -9,7 +9,7 @@ export type ClientProfileParams = {
};
export const ClientProfileRoute: RouteDef = {
- path: "/:realm/realm-settings/clientPolicies/:profileName/edit-profile",
+ path: "/:realm/realm-settings/clientPolicies/:profileName",
component: lazy(() => import("../ClientProfileForm")),
breadcrumb: (t) => t("realm-settings:clientProfile"),
access: ["view-realm", "view-users"],