Admin events auth dialog (#1131)

* admin-events-list: updated keys for Auth modal

* admin-events-list:added cypress test for auth dialog

* admin-events-list:added cypress test for representation dialog

* admin-events-list: fixed keys def

* admin-events-list: fixed keys def

Co-authored-by: Agnieszka Gancarczyk <agancarc@redhat.com>
This commit is contained in:
agagancarczyk 2021-09-07 12:38:36 +01:00 committed by GitHub
parent b5e5677cb5
commit 6d4b11aab2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 4 deletions

View file

@ -13,7 +13,7 @@ const adminEventsTab = new AdminEventsTab();
const realmSettingsPage = new RealmSettingsPage(); const realmSettingsPage = new RealmSettingsPage();
const masthead = new Masthead(); const masthead = new Masthead();
describe("Search events tests", function () { describe("Events tests", function () {
describe("Search user events", function () { describe("Search user events", function () {
beforeEach(function () { beforeEach(function () {
keycloakBefore(); keycloakBefore();
@ -99,4 +99,21 @@ describe("Search events tests", function () {
adminEventsTab.shouldHaveSearchBtnEnabled(); adminEventsTab.shouldHaveSearchBtnEnabled();
}); });
}); });
describe("Check more button opens auth and representation dialogs", function () {
beforeEach(function () {
keycloakBefore();
loginPage.logIn();
sidebarPage.goToEvents();
cy.getId("admin-events-tab").click();
});
it("Check auth dialog opens and is not empty", () => {
adminEventsTab.shouldCheckAuthDialogOpensAndIsNotEmpty();
});
it("Check representation dialog opens and is not empty", () => {
adminEventsTab.shouldCheckRepDialogOpensAndIsNotEmpty();
});
});
}); });

View file

@ -11,12 +11,17 @@ export default class AdminEventsTab {
dateFromInputFld = "dateFrom-searchField"; dateFromInputFld = "dateFrom-searchField";
dateToInputFld = "dateTo-searchField"; dateToInputFld = "dateTo-searchField";
searchEventsBtn = "search-events-btn"; searchEventsBtn = "search-events-btn";
operationTypesList = ".pf-c-form-control"; operationTypesList = ".pf-c-form-control";
operationTypesOption = ".pf-c-select__menu-item"; operationTypesOption = ".pf-c-select__menu-item";
operationTypesInputFld = ".pf-c-form-control.pf-c-select__toggle-typeahead"; operationTypesInputFld = ".pf-c-form-control.pf-c-select__toggle-typeahead";
operationTypesBtn = ".pf-c-button.pf-c-select__toggle-button.pf-m-plain"; operationTypesBtn = ".pf-c-button.pf-c-select__toggle-button.pf-m-plain";
adminEventsTabTitle = ".pf-c-title"; adminEventsTabTitle = ".pf-c-title";
moreBtn = ".pf-c-dropdown__toggle.pf-m-plain";
moreDrpDwnItems = ".pf-c-dropdown__menu";
dialogTitle = ".pf-c-modal-box__title-text";
dialogClose = `[aria-label="Close"]`;
authAttrDataRow = 'tbody > tr > [data-label="Attribute"]';
authValDataRow = 'tbody > tr > [data-label="Value"]';
shouldHaveFormFields() { shouldHaveFormFields() {
cy.getId(this.searchAdminEventDrpDwnBtn).click(); cy.getId(this.searchAdminEventDrpDwnBtn).click();
@ -63,4 +68,23 @@ export default class AdminEventsTab {
cy.getId(this.searchEventsBtn).click(); cy.getId(this.searchEventsBtn).click();
cy.get(this.adminEventsTabTitle).contains("No events logged"); cy.get(this.adminEventsTabTitle).contains("No events logged");
} }
shouldCheckAuthDialogOpensAndIsNotEmpty() {
cy.get(this.moreBtn).last().click();
cy.get(this.moreDrpDwnItems).contains("Auth").click();
cy.get(this.dialogTitle).contains("Auth");
cy.get(this.authAttrDataRow).contains("Realm");
cy.get(this.authAttrDataRow).contains("Client");
cy.get(this.authAttrDataRow).contains("User");
cy.get(this.authAttrDataRow).contains("IP address");
cy.get(this.authValDataRow).should("exist");
cy.get(this.dialogClose).click();
}
shouldCheckRepDialogOpensAndIsNotEmpty() {
cy.get(this.moreBtn).last().click();
cy.get(this.moreDrpDwnItems).contains("Representation").click();
cy.get(this.dialogTitle).contains("Representation");
cy.get(this.dialogClose).click();
}
} }

View file

@ -194,7 +194,6 @@ export const AdminEvents = () => {
(value) => value !== "" || (Array.isArray(value) && value.length > 0) (value) => value !== "" || (Array.isArray(value) && value.length > 0)
); );
console.log(newFilters);
setActiveFilters(newFilters); setActiveFilters(newFilters);
setKey(key + 1); setKey(key + 1);
} }
@ -534,15 +533,23 @@ export const AdminEvents = () => {
); );
}; };
const rows = [
[t("realm"), authEvent?.authDetails?.realmId],
[t("client"), authEvent?.authDetails?.clientId],
[t("user"), authEvent?.authDetails?.userId],
[t("ipAddress"), authEvent?.authDetails?.ipAddress],
];
return ( return (
<> <>
{authEvent && ( {authEvent && (
<DisplayDialog titleKey="auth" onClose={() => setAuthEvent(undefined)}> <DisplayDialog titleKey="auth" onClose={() => setAuthEvent(undefined)}>
<Table <Table
aria-label="authData" aria-label="authData"
data-testid="auth-dialog"
variant={TableVariant.compact} variant={TableVariant.compact}
cells={[t("attribute"), t("value")]} cells={[t("attribute"), t("value")]}
rows={Object.entries(authEvent.authDetails!)} rows={rows}
> >
<TableHeader /> <TableHeader />
<TableBody /> <TableBody />
@ -552,6 +559,7 @@ export const AdminEvents = () => {
{representationEvent && ( {representationEvent && (
<DisplayDialog <DisplayDialog
titleKey="representation" titleKey="representation"
data-testid="representation-dialog"
onClose={() => setRepresentationEvent(undefined)} onClose={() => setRepresentationEvent(undefined)}
> >
some json from the changed values some json from the changed values