removed not working filter option (#2067)

This commit is contained in:
Erik Jan de Wit 2022-02-22 14:30:18 +01:00 committed by GitHub
parent 83d9018f6d
commit 6ef3dc16f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 149 deletions

View file

@ -8,38 +8,12 @@ const sidebarPage = new SidebarPage();
const sessionsPage = new SessionsPage(); const sessionsPage = new SessionsPage();
describe("Sessions test", () => { describe("Sessions test", () => {
describe("Session type dropdown", () => {
beforeEach(() => { beforeEach(() => {
keycloakBefore(); keycloakBefore();
loginPage.logIn(); loginPage.logIn();
sidebarPage.goToSessions(); sidebarPage.goToSessions();
}); });
it("Check dropdown display and all options exist", () => {
sessionsPage.shouldDisplay();
sessionsPage.shouldNotBeEmpty();
});
it("Select 'All session types' dropdown option", () => {
sessionsPage.selectAllSessionsType();
});
it("Select 'Regular SSO' dropdown option", () => {
sessionsPage.selectRegularSSO();
});
it("Select 'Offline' dropdown option", () => {
sessionsPage.selectOffline();
});
it("Select 'Direct grant' dropdown option", () => {
sessionsPage.selectDirectGrant();
});
it("Select 'Service account' dropdown option", () => {
sessionsPage.selectServiceAccount();
});
it("Set revocation notBefore", () => { it("Set revocation notBefore", () => {
sessionsPage.setToNow(); sessionsPage.setToNow();
}); });
@ -62,4 +36,3 @@ describe("Sessions test", () => {
cy.get("#kc-page-title").contains("Sign in to your account"); cy.get("#kc-page-title").contains("Sign in to your account");
}); });
}); });
});

View file

@ -1,5 +1,4 @@
export default class SessionsPage { export default class SessionsPage {
sessionTypeDrpDwn = ".pf-c-select__toggle";
sessionTypeList = ".pf-c-select__toggle + ul"; sessionTypeList = ".pf-c-select__toggle + ul";
allSessionTypesOption = "all-sessions-option"; allSessionTypesOption = "all-sessions-option";
regularSSOOption = "regular-sso-option"; regularSSOOption = "regular-sso-option";
@ -15,47 +14,6 @@ export default class SessionsPage {
logoutAll = "logout-all"; logoutAll = "logout-all";
logoutAllConfirm = "logout-all-confirm-button"; logoutAllConfirm = "logout-all-confirm-button";
shouldDisplay() {
cy.get(this.sessionTypeDrpDwn).should("exist");
}
shouldNotBeEmpty() {
cy.get(this.sessionTypeDrpDwn).should("exist").click();
cy.get(this.sessionTypeList).should("exist");
return this;
}
selectAllSessionsType() {
cy.get(this.sessionTypeDrpDwn).should("exist").click();
cy.findByTestId(this.allSessionTypesOption).should("exist").click();
cy.get(this.selectedType).should("have.text", "All session types");
}
selectRegularSSO() {
cy.get(this.sessionTypeDrpDwn).should("exist").click();
cy.findByTestId(this.regularSSOOption).should("exist").click();
cy.get(this.selectedType).should("have.text", "Regular SSO");
}
selectOffline() {
cy.get(this.sessionTypeDrpDwn).should("exist").click();
cy.findByTestId(this.offlineOption).should("exist").click();
cy.get(this.selectedType).should("have.text", "Offline");
}
selectDirectGrant() {
cy.get(this.sessionTypeDrpDwn).should("exist").click();
cy.findByTestId(this.directGrantOption).should("exist").click();
cy.get(this.selectedType).should("have.text", "Direct grant");
}
selectServiceAccount() {
cy.get(this.sessionTypeDrpDwn).should("exist").click();
cy.findByTestId(this.serviceAccountOption).should("exist").click();
cy.get(this.selectedType).should("have.text", "Service account");
}
setToNow() { setToNow() {
cy.findByTestId(this.actionDropdown).should("exist").click(); cy.findByTestId(this.actionDropdown).should("exist").click();
cy.findByTestId(this.revocationActionItem).should("exist").click(); cy.findByTestId(this.revocationActionItem).should("exist").click();

View file

@ -2,28 +2,21 @@ import React, { useState } from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import moment from "moment"; import moment from "moment";
import { import { DropdownItem, PageSection } from "@patternfly/react-core";
DropdownItem, import { CubesIcon } from "@patternfly/react-icons";
PageSection,
Select,
SelectOption,
SelectVariant,
} from "@patternfly/react-core";
import { FilterIcon } from "@patternfly/react-icons";
import type UserSessionRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userSessionRepresentation"; import type UserSessionRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userSessionRepresentation";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState"; import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
import { ViewHeader } from "../components/view-header/ViewHeader"; import { ViewHeader } from "../components/view-header/ViewHeader";
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable"; import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
import { useAdminClient } from "../context/auth/AdminClient"; import { useAdminClient } from "../context/auth/AdminClient";
import { CubesIcon } from "@patternfly/react-icons";
import "./SessionsSection.css";
import { RevocationModal } from "./RevocationModal"; import { RevocationModal } from "./RevocationModal";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import { LogoutAllSessionsModal } from "./LogoutAllSessionsModal"; import { LogoutAllSessionsModal } from "./LogoutAllSessionsModal";
import helpUrls from "../help-urls"; import helpUrls from "../help-urls";
import "./SessionsSection.css";
const Clients = (row: UserSessionRepresentation) => { const Clients = (row: UserSessionRepresentation) => {
return ( return (
<> <>
@ -39,23 +32,14 @@ const Clients = (row: UserSessionRepresentation) => {
export default function SessionsSection() { export default function SessionsSection() {
const { t } = useTranslation("sessions"); const { t } = useTranslation("sessions");
const adminClient = useAdminClient(); const adminClient = useAdminClient();
const [filterDropdownOpen, setFilterDropdownOpen] = useState(false);
const [revocationModalOpen, setRevocationModalOpen] = useState(false); const [revocationModalOpen, setRevocationModalOpen] = useState(false);
const [logoutAllSessionsModalOpen, setLogoutAllSessionsModalOpen] = const [logoutAllSessionsModalOpen, setLogoutAllSessionsModalOpen] =
useState(false); useState(false);
const [activeClientDetails, setActiveClientDetails] = useState< const [activeClientDetails, setActiveClientDetails] = useState<
ClientRepresentation[] ClientRepresentation[]
>([]); >([]);
const [filterType, setFilterType] = useState(
t("sessionsType.allSessions").toString()
);
const [key, setKey] = useState(0);
const [noSessions, setNoSessions] = useState(false); const [noSessions, setNoSessions] = useState(false);
const refresh = () => {
setKey(new Date().getTime());
};
const handleRevocationModalToggle = () => { const handleRevocationModalToggle = () => {
setRevocationModalOpen(!revocationModalOpen); setRevocationModalOpen(!revocationModalOpen);
}; };
@ -140,48 +124,9 @@ export default function SessionsSection() {
/> />
)} )}
<KeycloakDataTable <KeycloakDataTable
key={key}
loader={loader} loader={loader}
ariaLabelKey="session:title" ariaLabelKey="session:title"
searchPlaceholderKey="sessions:searchForSession" searchPlaceholderKey="sessions:searchForSession"
searchTypeComponent={
<Select
data-testid="filter-session-type-select"
isOpen={filterDropdownOpen}
className="kc-filter-session-type-select"
variant={SelectVariant.single}
onToggle={(isExpanded) => setFilterDropdownOpen(isExpanded)}
toggleIcon={<FilterIcon />}
onSelect={(_, value) => {
setFilterType(value.toString());
refresh();
setFilterDropdownOpen(false);
}}
selections={filterType}
>
<SelectOption
data-testid="all-sessions-option"
value={t("sessionsType.allSessions")}
isPlaceholder
/>
<SelectOption
data-testid="regular-sso-option"
value={t("sessionsType.regularSSO")}
/>
<SelectOption
data-testid="offline-option"
value={t("sessionsType.offline")}
/>
<SelectOption
data-testid="direct-grant-option"
value={t("sessionsType.directGrant")}
/>
<SelectOption
data-testid="service-account-option"
value={t("sessionsType.serviceAccount")}
/>
</Select>
}
columns={[ columns={[
{ {
name: "username", name: "username",