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,58 +8,31 @@ const sidebarPage = new SidebarPage();
const sessionsPage = new SessionsPage();
describe("Sessions test", () => {
describe("Session type dropdown", () => {
beforeEach(() => {
keycloakBefore();
loginPage.logIn();
sidebarPage.goToSessions();
});
beforeEach(() => {
keycloakBefore();
loginPage.logIn();
sidebarPage.goToSessions();
});
it("Check dropdown display and all options exist", () => {
sessionsPage.shouldDisplay();
sessionsPage.shouldNotBeEmpty();
});
it("Set revocation notBefore", () => {
sessionsPage.setToNow();
});
it("Select 'All session types' dropdown option", () => {
sessionsPage.selectAllSessionsType();
});
it("Check if notBefore saved", () => {
sessionsPage.checkNotBeforeValueExists();
});
it("Select 'Regular SSO' dropdown option", () => {
sessionsPage.selectRegularSSO();
});
it("Clear revocation notBefore", () => {
sessionsPage.clearNotBefore();
});
it("Select 'Offline' dropdown option", () => {
sessionsPage.selectOffline();
});
it("Check if notBefore cleared", () => {
sessionsPage.checkNotBeforeCleared();
});
it("Select 'Direct grant' dropdown option", () => {
sessionsPage.selectDirectGrant();
});
it("logout all sessions", () => {
sessionsPage.logoutAllSessions();
it("Select 'Service account' dropdown option", () => {
sessionsPage.selectServiceAccount();
});
it("Set revocation notBefore", () => {
sessionsPage.setToNow();
});
it("Check if notBefore saved", () => {
sessionsPage.checkNotBeforeValueExists();
});
it("Clear revocation notBefore", () => {
sessionsPage.clearNotBefore();
});
it("Check if notBefore cleared", () => {
sessionsPage.checkNotBeforeCleared();
});
it("logout all sessions", () => {
sessionsPage.logoutAllSessions();
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 {
sessionTypeDrpDwn = ".pf-c-select__toggle";
sessionTypeList = ".pf-c-select__toggle + ul";
allSessionTypesOption = "all-sessions-option";
regularSSOOption = "regular-sso-option";
@ -15,47 +14,6 @@ export default class SessionsPage {
logoutAll = "logout-all";
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() {
cy.findByTestId(this.actionDropdown).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 { useTranslation } from "react-i18next";
import moment from "moment";
import {
DropdownItem,
PageSection,
Select,
SelectOption,
SelectVariant,
} from "@patternfly/react-core";
import { FilterIcon } from "@patternfly/react-icons";
import { DropdownItem, PageSection } from "@patternfly/react-core";
import { CubesIcon } from "@patternfly/react-icons";
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 { ViewHeader } from "../components/view-header/ViewHeader";
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
import { useAdminClient } from "../context/auth/AdminClient";
import { CubesIcon } from "@patternfly/react-icons";
import "./SessionsSection.css";
import { RevocationModal } from "./RevocationModal";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import { LogoutAllSessionsModal } from "./LogoutAllSessionsModal";
import helpUrls from "../help-urls";
import "./SessionsSection.css";
const Clients = (row: UserSessionRepresentation) => {
return (
<>
@ -39,23 +32,14 @@ const Clients = (row: UserSessionRepresentation) => {
export default function SessionsSection() {
const { t } = useTranslation("sessions");
const adminClient = useAdminClient();
const [filterDropdownOpen, setFilterDropdownOpen] = useState(false);
const [revocationModalOpen, setRevocationModalOpen] = useState(false);
const [logoutAllSessionsModalOpen, setLogoutAllSessionsModalOpen] =
useState(false);
const [activeClientDetails, setActiveClientDetails] = useState<
ClientRepresentation[]
>([]);
const [filterType, setFilterType] = useState(
t("sessionsType.allSessions").toString()
);
const [key, setKey] = useState(0);
const [noSessions, setNoSessions] = useState(false);
const refresh = () => {
setKey(new Date().getTime());
};
const handleRevocationModalToggle = () => {
setRevocationModalOpen(!revocationModalOpen);
};
@ -140,48 +124,9 @@ export default function SessionsSection() {
/>
)}
<KeycloakDataTable
key={key}
loader={loader}
ariaLabelKey="session:title"
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={[
{
name: "username",