add create client policy form; WIP (#1312)
add client policy tests checkout realm settings test from master RealmSettingsPage.ts master remove comment and add missing translation fix tests PR feedback from Jon and Erik rebase update test file replace hardcoded URL with path fix tests correct tab name fix duplicates test add create client policy form; WIP add client policy tests tests createClientPolicyFormTests lint tests remove comments comment out json test add empty state test check reloading json policies client policy tests are passing all client policy tests passing locally
This commit is contained in:
parent
740c267a00
commit
8ccc488bac
5 changed files with 280 additions and 61 deletions
|
@ -11,5 +11,6 @@
|
||||||
},
|
},
|
||||||
"defaultCommandTimeout": 10000,
|
"defaultCommandTimeout": 10000,
|
||||||
"videoCompression": false,
|
"videoCompression": false,
|
||||||
|
"numTestsKeptInMemory": 0,
|
||||||
"videoUploadOnPasses": false
|
"videoUploadOnPasses": false
|
||||||
}
|
}
|
||||||
|
|
|
@ -435,7 +435,6 @@ describe("Realm settings tests", () => {
|
||||||
9
|
9
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe("Realm settings client profiles tab tests", () => {
|
describe("Realm settings client profiles tab tests", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -491,12 +490,75 @@ describe("Realm settings tests", () => {
|
||||||
realmSettingsPage.shouldNotCreateDuplicateClientProfile();
|
realmSettingsPage.shouldNotCreateDuplicateClientProfile();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Check deleting newly created client profile from create view via dropdown", () => {
|
describe("Realm settings client policies tab tests", () => {
|
||||||
realmSettingsPage.shouldRemoveClientFromCreateView();
|
beforeEach(() => {
|
||||||
|
keycloakBefore();
|
||||||
|
loginPage.logIn();
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
cy.findByTestId("rs-clientPolicies-tab").click();
|
||||||
|
cy.findByTestId("rs-policies-clientPolicies-tab").click();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Check reloading JSON profiles", () => {
|
it("Go to client policies tab", () => {
|
||||||
realmSettingsPage.shouldReloadJSONProfiles();
|
realmSettingsPage.shouldDisplayPoliciesTab();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Check new client form is displaying", () => {
|
||||||
|
realmSettingsPage.shouldDisplayNewClientPolicyForm();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Complete new client form and cancel", () => {
|
||||||
|
realmSettingsPage.shouldCompleteAndCancelCreateNewClientPolicy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Complete new client form and submit", () => {
|
||||||
|
realmSettingsPage.shouldCompleteAndCreateNewClientPolicyFromEmptyState();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should perform client profile search by profile name", () => {
|
||||||
|
realmSettingsPage.shouldSearchClientPolicy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Check cancelling the client policy deletion", () => {
|
||||||
|
realmSettingsPage.shouldDisplayDeleteClientPolicyDialog();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Check deleting the client policy", () => {
|
||||||
|
realmSettingsPage.shouldDeleteClientPolicyDialog();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Check navigating between Form View and JSON editor", () => {
|
||||||
|
realmSettingsPage.shouldNavigateBetweenFormAndJSONViewPolicies();
|
||||||
|
});
|
||||||
|
|
||||||
|
/* it("Check saving changed JSON policies", () => {
|
||||||
|
realmSettingsPage.shouldSaveChangedJSONPolicies();
|
||||||
|
realmSettingsPage.shouldDeleteClientPolicyDialog();
|
||||||
|
}); */
|
||||||
|
|
||||||
|
it("Should not create duplicate client profile", () => {
|
||||||
|
realmSettingsPage.shouldCompleteAndCreateNewClientPolicyFromEmptyState();
|
||||||
|
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
cy.findByTestId("rs-clientPolicies-tab").click();
|
||||||
|
cy.findByTestId("rs-policies-clientPolicies-tab").click();
|
||||||
|
realmSettingsPage.shouldCompleteAndCreateNewClientPolicy();
|
||||||
|
realmSettingsPage.shouldNotCreateDuplicateClientPolicy();
|
||||||
|
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
cy.findByTestId("rs-clientPolicies-tab").click();
|
||||||
|
cy.findByTestId("rs-policies-clientPolicies-tab").click();
|
||||||
|
realmSettingsPage.shouldDeleteClientProfileDialog();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Check deleting newly created client policy from create view via dropdown", () => {
|
||||||
|
realmSettingsPage.shouldRemoveClientPolicyFromCreateView();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Check reloading JSON policies", () => {
|
||||||
|
realmSettingsPage.shouldReloadJSONPolicies();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -148,10 +148,18 @@ export default class RealmSettingsPage {
|
||||||
private createProfileBtn = "createProfile";
|
private createProfileBtn = "createProfile";
|
||||||
private formViewSelect = "formView-profilesView";
|
private formViewSelect = "formView-profilesView";
|
||||||
private jsonEditorSelect = "jsonEditor-profilesView";
|
private jsonEditorSelect = "jsonEditor-profilesView";
|
||||||
|
private formViewSelectPolicies = "formView-policiesView";
|
||||||
|
private jsonEditorSelectPolicies = "jsonEditor-policiesView";
|
||||||
private newClientProfileNameInput = "client-profile-name";
|
private newClientProfileNameInput = "client-profile-name";
|
||||||
private newClientProfileDescriptionInput = "client-profile-description";
|
private newClientProfileDescriptionInput = "client-profile-description";
|
||||||
private saveNewClientProfileBtn = "saveCreateProfile";
|
private saveNewClientProfileBtn = "saveCreateProfile";
|
||||||
private cancelNewClientProfile = "cancelCreateProfile";
|
private cancelNewClientProfile = "cancelCreateProfile";
|
||||||
|
private createPolicyEmptyStateBtn = "no-client-policies-empty-action";
|
||||||
|
private createPolicyBtn = "createPolicy";
|
||||||
|
private newClientPolicyNameInput = "client-policy-name";
|
||||||
|
private newClientPolicyDescriptionInput = "client-policy-description";
|
||||||
|
private saveNewClientPolicyBtn = "saveCreatePolicy";
|
||||||
|
private cancelNewClientPolicyBtn = "cancelCreatePolicy";
|
||||||
private alertMessage = ".pf-c-alert__title";
|
private alertMessage = ".pf-c-alert__title";
|
||||||
private moreDrpDwn = ".pf-c-dropdown__toggle.pf-m-plain";
|
private moreDrpDwn = ".pf-c-dropdown__toggle.pf-m-plain";
|
||||||
private moreDrpDwnItems = ".pf-c-dropdown__menu-item";
|
private moreDrpDwnItems = ".pf-c-dropdown__menu-item";
|
||||||
|
@ -159,10 +167,12 @@ export default class RealmSettingsPage {
|
||||||
private deleteDialogBodyText = ".pf-c-modal-box__body";
|
private deleteDialogBodyText = ".pf-c-modal-box__body";
|
||||||
private deleteDialogCancelBtn = ".pf-c-button.pf-m-link";
|
private deleteDialogCancelBtn = ".pf-c-button.pf-m-link";
|
||||||
private jsonEditorSaveBtn = "jsonEditor-saveBtn";
|
private jsonEditorSaveBtn = "jsonEditor-saveBtn";
|
||||||
|
private jsonEditorSavePoliciesBtn = "jsonEditor-policies-saveBtn";
|
||||||
private jsonEditorReloadBtn = "jsonEditor-reloadBtn";
|
private jsonEditorReloadBtn = "jsonEditor-reloadBtn";
|
||||||
private jsonEditor = ".monaco-scrollable-element.editor-scrollable.vs";
|
private jsonEditor = ".monaco-scrollable-element.editor-scrollable.vs";
|
||||||
private createClientDrpDwn = ".pf-c-dropdown.pf-m-align-right";
|
private createClientDrpDwn = ".pf-c-dropdown.pf-m-align-right";
|
||||||
private searchFld = "[id^=realm-settings][id$=profilesinput]";
|
private searchFld = "[id^=realm-settings][id$=profilesinput]";
|
||||||
|
private searchFldPolicies = "[id^=realm-settings][id$=clientPoliciesinput]";
|
||||||
|
|
||||||
selectLoginThemeType(themeType: string) {
|
selectLoginThemeType(themeType: string) {
|
||||||
cy.get(this.selectLoginTheme).click();
|
cy.get(this.selectLoginTheme).click();
|
||||||
|
@ -516,12 +526,12 @@ export default class RealmSettingsPage {
|
||||||
cy.get(this.searchFld).click({ force: true }).clear();
|
cy.get(this.searchFld).click({ force: true }).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldDisplayDeleteClientProfileDialog() {
|
shouldDisplayDeleteClientPolicyDialog() {
|
||||||
cy.get(this.moreDrpDwn).last().click();
|
cy.get(this.moreDrpDwn).last().click();
|
||||||
cy.get(this.moreDrpDwnItems).click();
|
cy.get(this.moreDrpDwnItems).click();
|
||||||
cy.get(this.deleteDialogTitle).contains("Delete profile?");
|
cy.get(this.deleteDialogTitle).contains("Delete policy?");
|
||||||
cy.get(this.deleteDialogBodyText).contains(
|
cy.get(this.deleteDialogBodyText).contains(
|
||||||
"This action will permanently delete the profile custom-profile. This cannot be undone."
|
"This action will permanently delete the policy Test. This cannot be undone."
|
||||||
);
|
);
|
||||||
cy.findByTestId("modalConfirm").contains("Delete");
|
cy.findByTestId("modalConfirm").contains("Delete");
|
||||||
cy.get(this.deleteDialogCancelBtn).contains("Cancel").click();
|
cy.get(this.deleteDialogCancelBtn).contains("Cancel").click();
|
||||||
|
@ -568,6 +578,13 @@ export default class RealmSettingsPage {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shouldNotCreateDuplicateClientPolicy() {
|
||||||
|
cy.get(this.alertMessage).should(
|
||||||
|
"be.visible",
|
||||||
|
"Could not create client policy: 'proposed client policy name duplicated.'"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
shouldRemoveClientFromCreateView() {
|
shouldRemoveClientFromCreateView() {
|
||||||
cy.findByTestId(this.createProfileBtn).click();
|
cy.findByTestId(this.createProfileBtn).click();
|
||||||
cy.findByTestId(this.newClientProfileNameInput).type("Test again");
|
cy.findByTestId(this.newClientProfileNameInput).type("Test again");
|
||||||
|
@ -592,4 +609,140 @@ export default class RealmSettingsPage {
|
||||||
cy.findByTestId(this.jsonEditorSaveBtn).contains("Save");
|
cy.findByTestId(this.jsonEditorSaveBtn).contains("Save");
|
||||||
cy.findByTestId(this.jsonEditorReloadBtn).contains("Reload");
|
cy.findByTestId(this.jsonEditorReloadBtn).contains("Reload");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shouldSaveChangedJSONPolicies() {
|
||||||
|
cy.findByTestId(this.jsonEditorSelectPolicies).check();
|
||||||
|
cy.findByTestId(this.jsonEditorReloadBtn).click();
|
||||||
|
|
||||||
|
cy.get(this.jsonEditor).type(`{pageup}{del} [{
|
||||||
|
"name": "Reload",
|
||||||
|
}, {downarrow}{end}{backspace}{backspace}{backspace}{backspace}`);
|
||||||
|
|
||||||
|
cy.findByTestId(this.jsonEditorReloadBtn).click();
|
||||||
|
|
||||||
|
cy.get(this.jsonEditor).type(`{pageup}{del} [{
|
||||||
|
"name": "Test",
|
||||||
|
"description": "Test Description",
|
||||||
|
"enabled": false,
|
||||||
|
"conditions": [],
|
||||||
|
"profiles": [],
|
||||||
|
}, {downarrow}{end}{backspace}{backspace}{backspace}{backspace}`);
|
||||||
|
|
||||||
|
cy.findByTestId(this.jsonEditorSavePoliciesBtn).click();
|
||||||
|
|
||||||
|
cy.get(this.alertMessage).should(
|
||||||
|
"be.visible",
|
||||||
|
"The client policy configuration was updated"
|
||||||
|
);
|
||||||
|
cy.findByTestId(this.formViewSelectPolicies).check();
|
||||||
|
cy.get("table").should("be.visible").contains("td", "Test");
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldNavigateBetweenFormAndJSONViewPolicies() {
|
||||||
|
cy.findByTestId(this.jsonEditorSelectPolicies).check();
|
||||||
|
cy.findByTestId(this.jsonEditorSavePoliciesBtn).contains("Save");
|
||||||
|
cy.findByTestId(this.jsonEditorReloadBtn).contains("Reload");
|
||||||
|
cy.findByTestId(this.formViewSelectPolicies).check();
|
||||||
|
cy.findByTestId(this.createPolicyEmptyStateBtn).contains(
|
||||||
|
"Create client policy"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldDisplayPoliciesTab() {
|
||||||
|
cy.findByTestId(this.createPolicyEmptyStateBtn).should("exist");
|
||||||
|
cy.findByTestId(this.formViewSelectPolicies).should("exist");
|
||||||
|
cy.findByTestId(this.jsonEditorSelectPolicies).should("exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldDisplayNewClientPolicyForm() {
|
||||||
|
cy.findByTestId(this.createPolicyEmptyStateBtn).click();
|
||||||
|
cy.findByTestId(this.newClientPolicyNameInput).should("exist");
|
||||||
|
cy.findByTestId(this.newClientPolicyDescriptionInput).should("exist");
|
||||||
|
cy.findByTestId(this.saveNewClientPolicyBtn).should("exist");
|
||||||
|
cy.findByTestId(this.cancelNewClientPolicyBtn).should("exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldCompleteAndCancelCreateNewClientPolicy() {
|
||||||
|
cy.findByTestId(this.createPolicyEmptyStateBtn).click();
|
||||||
|
cy.findByTestId(this.newClientPolicyNameInput).type("Test");
|
||||||
|
cy.findByTestId(this.newClientPolicyDescriptionInput).type(
|
||||||
|
"Test Description"
|
||||||
|
);
|
||||||
|
cy.findByTestId(this.cancelNewClientPolicyBtn).click();
|
||||||
|
cy.get("table").should("not.have.text", "Test");
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldCompleteAndCreateNewClientPolicy() {
|
||||||
|
cy.findByTestId(this.createPolicyBtn).click();
|
||||||
|
cy.findByTestId(this.newClientPolicyNameInput).type("Test");
|
||||||
|
cy.findByTestId(this.newClientPolicyDescriptionInput).type(
|
||||||
|
"Test Description"
|
||||||
|
);
|
||||||
|
cy.findByTestId(this.saveNewClientPolicyBtn).click();
|
||||||
|
cy.get(this.alertMessage).should(
|
||||||
|
"be.visible",
|
||||||
|
"New client profile created"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldCompleteAndCreateNewClientPolicyFromEmptyState() {
|
||||||
|
cy.findByTestId(this.createPolicyEmptyStateBtn).click();
|
||||||
|
cy.findByTestId(this.newClientPolicyNameInput).type("Test");
|
||||||
|
cy.findByTestId(this.newClientPolicyDescriptionInput).type(
|
||||||
|
"Test Description"
|
||||||
|
);
|
||||||
|
cy.findByTestId(this.saveNewClientPolicyBtn).click();
|
||||||
|
cy.get(this.alertMessage).should(
|
||||||
|
"be.visible",
|
||||||
|
"New client profile created"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldSearchClientPolicy() {
|
||||||
|
cy.get(this.searchFldPolicies).click({ force: true }).type("Test").click();
|
||||||
|
cy.get("table").should("be.visible").contains("td", "Test");
|
||||||
|
cy.get(this.searchFldPolicies).click({ force: true }).clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldDisplayDeleteClientProfileDialog() {
|
||||||
|
cy.get(this.moreDrpDwn).last().click();
|
||||||
|
cy.get(this.moreDrpDwnItems).click();
|
||||||
|
cy.get(this.deleteDialogTitle).contains("Delete profile?");
|
||||||
|
cy.get(this.deleteDialogBodyText).contains(
|
||||||
|
"This action will permanently delete the profile custom-profile. This cannot be undone."
|
||||||
|
);
|
||||||
|
cy.findByTestId("modalConfirm").contains("Delete");
|
||||||
|
cy.get(this.deleteDialogCancelBtn).contains("Cancel").click();
|
||||||
|
cy.get("table").should("not.have.text", "Test");
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldDeleteClientPolicyDialog() {
|
||||||
|
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", "Test");
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldRemoveClientPolicyFromCreateView() {
|
||||||
|
cy.findByTestId(this.createPolicyEmptyStateBtn).click();
|
||||||
|
cy.findByTestId(this.newClientPolicyNameInput).type("Test again");
|
||||||
|
cy.findByTestId(this.newClientPolicyDescriptionInput).type(
|
||||||
|
"Test Again Description"
|
||||||
|
);
|
||||||
|
cy.findByTestId(this.saveNewClientPolicyBtn).click();
|
||||||
|
cy.get(this.alertMessage).should("be.visible", "New client policy created");
|
||||||
|
cy.get(this.createClientDrpDwn).contains("Action").click();
|
||||||
|
cy.findByTestId("deleteClientPolicyDropdown").click();
|
||||||
|
cy.findByTestId("modalConfirm").contains("Delete").click();
|
||||||
|
cy.get(this.alertMessage).should("be.visible", "Client profile deleted");
|
||||||
|
cy.get("table").should("not.have.text", "Test Again Description");
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldReloadJSONPolicies() {
|
||||||
|
cy.findByTestId(this.jsonEditorSelectPolicies).check();
|
||||||
|
cy.findByTestId(this.jsonEditorReloadBtn).contains("Reload").click();
|
||||||
|
cy.findByTestId(this.jsonEditorSavePoliciesBtn).contains("Save");
|
||||||
|
cy.findByTestId(this.jsonEditorReloadBtn).contains("Reload");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,23 +119,25 @@ export const NewClientPolicyForm = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({
|
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({
|
||||||
titleKey: t("deleteClientProfileConfirmTitle"),
|
titleKey: t("deleteClientPolicyConfirmTitle"),
|
||||||
messageKey: t("deleteClientProfileConfirm"),
|
messageKey: t("deleteClientPolicyConfirm", {
|
||||||
|
policyName: policyName,
|
||||||
|
}),
|
||||||
continueButtonLabel: t("delete"),
|
continueButtonLabel: t("delete"),
|
||||||
continueButtonVariant: ButtonVariant.danger,
|
continueButtonVariant: ButtonVariant.danger,
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
const updatedPolicies = policies.filter(
|
const updatedPolicies = policies.filter(
|
||||||
(policy) => policy.name !== createdPolicy?.name
|
(policy) => policy.name !== policyName
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await adminClient.clientPolicies.updatePolicy({
|
await adminClient.clientPolicies.updatePolicy({
|
||||||
policies: updatedPolicies,
|
policies: updatedPolicies,
|
||||||
});
|
});
|
||||||
addAlert(t("deleteClientSuccess"), AlertVariant.success);
|
addAlert(t("deleteClientPolicySuccess"), AlertVariant.success);
|
||||||
history.push(toClientPolicies({ realm }));
|
history.push(toClientPolicies({ realm }));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
addError(t("deleteClientError"), error);
|
addError(t("deleteClientPolicyError"), error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -151,17 +153,17 @@ export const NewClientPolicyForm = () => {
|
||||||
}
|
}
|
||||||
divider
|
divider
|
||||||
dropdownItems={
|
dropdownItems={
|
||||||
showAddConditionsAndProfilesForm
|
showAddConditionsAndProfilesForm || policyName
|
||||||
? [
|
? [
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
key="delete"
|
key="delete"
|
||||||
value="delete"
|
value="delete"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
toggleDeleteDialog;
|
toggleDeleteDialog();
|
||||||
}}
|
}}
|
||||||
data-testid="deleteClientProfileDropdown"
|
data-testid="deleteClientPolicyDropdown"
|
||||||
>
|
>
|
||||||
{t("deleteClientProfile")}
|
{t("deleteClientPolicy")}
|
||||||
</DropdownItem>,
|
</DropdownItem>,
|
||||||
]
|
]
|
||||||
: undefined
|
: undefined
|
||||||
|
|
|
@ -203,6 +203,7 @@ export default {
|
||||||
formView: "Form view",
|
formView: "Form view",
|
||||||
jsonEditor: "JSON editor",
|
jsonEditor: "JSON editor",
|
||||||
},
|
},
|
||||||
|
deleteClientPolicy: "Delete client policy",
|
||||||
deleteClientPolicyConfirmTitle: "Delete policy?",
|
deleteClientPolicyConfirmTitle: "Delete policy?",
|
||||||
deleteClientPolicyConfirm:
|
deleteClientPolicyConfirm:
|
||||||
"This action will permanently delete the policy {{policyName}}. This cannot be undone.",
|
"This action will permanently delete the policy {{policyName}}. This cannot be undone.",
|
||||||
|
|
Loading…
Reference in a new issue