2024-06-27 15:38:20 +00:00
|
|
|
import { v4 as uuid } from "uuid";
|
2021-01-27 12:56:28 +00:00
|
|
|
import LoginPage from "../support/pages/LoginPage";
|
2022-12-07 15:28:28 +00:00
|
|
|
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
|
|
|
|
import Masthead from "../support/pages/admin-ui/Masthead";
|
2022-03-09 16:42:51 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_hooks";
|
2024-06-27 15:38:20 +00:00
|
|
|
import adminClient from "../support/util/AdminClient";
|
2021-01-21 12:09:50 +00:00
|
|
|
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const masthead = new Masthead();
|
2022-02-08 22:10:27 +00:00
|
|
|
const sidebarPage = new SidebarPage();
|
2024-04-05 14:37:05 +00:00
|
|
|
const helpLabel = ".pf-v5-c-form__group-label-help";
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2023-02-21 13:41:33 +00:00
|
|
|
describe("Masthead tests", () => {
|
2022-02-15 16:02:17 +00:00
|
|
|
beforeEach(() => {
|
2021-01-21 12:09:50 +00:00
|
|
|
loginPage.logIn();
|
2023-02-10 10:10:35 +00:00
|
|
|
keycloakBefore();
|
2021-01-21 12:09:50 +00:00
|
|
|
});
|
|
|
|
|
2023-02-21 13:41:33 +00:00
|
|
|
describe("Desktop view", () => {
|
|
|
|
it("Go to account console and back to admin console", () => {
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
masthead.accountManagement();
|
2024-03-04 12:38:28 +00:00
|
|
|
cy.url().should("contain", "/realms/master/account");
|
2023-02-21 13:41:33 +00:00
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2023-02-21 13:41:33 +00:00
|
|
|
it("Sign out reachs to log in screen", () => {
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
masthead.signOut();
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
loginPage.isLogInPage();
|
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2023-02-21 13:41:33 +00:00
|
|
|
it("Go to realm info", () => {
|
|
|
|
sidebarPage.goToClients();
|
|
|
|
masthead.toggleUsernameDropdown().clickRealmInfo();
|
2024-04-05 14:37:05 +00:00
|
|
|
cy.get(".pf-v5-l-grid").should("contain.text", "Welcome");
|
2023-02-21 13:41:33 +00:00
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2023-02-21 13:41:33 +00:00
|
|
|
it("Should go to documentation page", () => {
|
|
|
|
masthead.clickGlobalHelp();
|
2023-06-20 12:21:49 +00:00
|
|
|
masthead
|
|
|
|
.getDocumentationLink()
|
|
|
|
.invoke("attr", "href")
|
|
|
|
.then((href) => {
|
|
|
|
if (!href) return;
|
|
|
|
|
|
|
|
masthead.clickDocumentationLink();
|
|
|
|
cy.origin(href, () => {
|
|
|
|
cy.get("#header").should(
|
|
|
|
"contain.text",
|
2023-07-11 14:03:21 +00:00
|
|
|
"Server Administration Guide",
|
2023-06-20 12:21:49 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2023-02-21 13:41:33 +00:00
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2023-02-21 13:41:33 +00:00
|
|
|
it("Enable/disable help mode in desktop mode", () => {
|
|
|
|
masthead.assertIsDesktopView();
|
2024-01-09 19:02:31 +00:00
|
|
|
cy.findByTestId("infoTab").click();
|
2023-02-21 13:41:33 +00:00
|
|
|
cy.get(helpLabel).should("exist");
|
|
|
|
masthead.toggleGlobalHelp();
|
|
|
|
masthead.clickGlobalHelp();
|
|
|
|
cy.get(helpLabel).should("not.exist");
|
|
|
|
masthead.toggleGlobalHelp();
|
|
|
|
cy.get(helpLabel).should("exist");
|
|
|
|
});
|
2022-02-16 16:34:54 +00:00
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2024-06-27 15:38:20 +00:00
|
|
|
describe("Login works for unprivileged users", () => {
|
|
|
|
const realmName = `test-realm-${uuid()}`;
|
|
|
|
const username = `test-user-${uuid()}`;
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
await adminClient.createRealm(realmName, { enabled: true });
|
|
|
|
|
|
|
|
await adminClient.inRealm(realmName, () =>
|
|
|
|
adminClient.createUser({
|
|
|
|
username,
|
|
|
|
enabled: true,
|
|
|
|
emailVerified: true,
|
|
|
|
credentials: [{ type: "password", value: "test" }],
|
|
|
|
firstName: "Test",
|
|
|
|
lastName: "User",
|
|
|
|
email: "test@keycloak.org",
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
after(() => adminClient.deleteRealm(realmName));
|
|
|
|
|
|
|
|
it("Login without privileges to see admin console", () => {
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
masthead.signOut();
|
|
|
|
|
|
|
|
cy.visit(`/admin/${realmName}/console`);
|
|
|
|
|
|
|
|
cy.get('[role="progressbar"]').should("not.exist");
|
|
|
|
cy.get("#username").type(username);
|
|
|
|
cy.get("#password").type("test");
|
|
|
|
|
|
|
|
cy.get("#kc-login").click();
|
|
|
|
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
masthead.signOut();
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
loginPage.isLogInPage();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-02-21 13:41:33 +00:00
|
|
|
describe("Mobile view", () => {
|
|
|
|
it("Mobile menu is shown when in mobile view", () => {
|
|
|
|
cy.viewport("samsung-s10");
|
|
|
|
masthead.assertIsMobileView();
|
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2023-02-21 13:41:33 +00:00
|
|
|
it("Enable/disable help mode in mobile view", () => {
|
|
|
|
cy.viewport("samsung-s10");
|
|
|
|
masthead
|
|
|
|
.assertIsMobileView()
|
|
|
|
.toggleUsernameDropdown()
|
|
|
|
.toggleMobileViewHelp();
|
|
|
|
masthead.toggleMobileViewHelp();
|
2024-01-09 19:02:31 +00:00
|
|
|
cy.findByTestId("helpIcon").should("exist");
|
2023-02-21 13:41:33 +00:00
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
});
|
2023-03-22 16:14:53 +00:00
|
|
|
|
2024-04-05 14:37:05 +00:00
|
|
|
describe("Accessibility tests for masthead", () => {
|
2023-03-22 16:14:53 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
loginPage.logIn();
|
|
|
|
keycloakBefore();
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
masthead.accountManagement();
|
|
|
|
cy.injectAxe();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Check a11y violations on load/ masthead", () => {
|
|
|
|
cy.checkA11y();
|
|
|
|
});
|
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
});
|