keycloak-scim/tests/cypress/integration/masthead_test.spec.js
Stan Silvert f2e26b0049
Cypress tests for masthead. (#304)
* Cypress tests for masthead.

* Update snapshot

* Update Keycloak version.

* Fix download address

* Update start.js

Co-authored-by: Erik Jan de Wit <erikjan.dewit@gmail.com>

* Follow redirect when downloading keycloak.

* Refactor HeaderPage into Masthead and ModalUtils

* Minor change to kick off build.

* logOutTest no longer needs a param

* goToAcctMgtTest no longer needs a param

* Update tests/cypress/support/pages/admin_console/Masthead.js

Co-authored-by: Aboullos <61687012+Aboullos@users.noreply.github.com>

* Update tests/cypress/support/pages/admin_console/Masthead.js

Co-authored-by: Aboullos <61687012+Aboullos@users.noreply.github.com>

* Fix userDropdown() method

* Minor refactor

Co-authored-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Co-authored-by: Aboullos <61687012+Aboullos@users.noreply.github.com>
2021-01-21 07:09:50 -05:00

69 lines
1.8 KiB
JavaScript

import ListingPage from "../support/pages/admin_console/ListingPage.js";
import LoginPage from "../support/pages/LoginPage.js";
import SidebarPage from "../support/pages/admin_console/SidebarPage.js";
import Masthead from "../support/pages/admin_console/Masthead.js";
const loginPage = new LoginPage();
const masthead = new Masthead();
const logOutTest = () => {
it("logs out", () => {
masthead.signOut();
loginPage.isLogInPage();
});
};
const goToAcctMgtTest = () => {
it("opens manage account and returns to admin console", () => {
masthead.accountManagement();
cy.contains("Welcome to Keycloak Account Management");
cy.get("#landingReferrerLink").click({ force: true });
masthead.isAdminConsole();
});
};
describe("Masthead tests in desktop mode", () => {
beforeEach(() => {
cy.visit("");
loginPage.logIn();
});
goToAcctMgtTest();
it("disables header help and form field help", () => {
const sidebarPage = new SidebarPage();
const listingPage = new ListingPage();
sidebarPage.goToClientScopes();
listingPage.goToItemDetails("address");
cy.get("#view-header-subkey").should("exist");
cy.get(`#${CSS.escape("client-scopes-help:name")}`).should("exist");
masthead.toggleGlobalHelp();
cy.get("#view-header-subkey").should("not.exist");
cy.get(`#${CSS.escape("client-scopes-help:name")}`).should("not.exist");
});
logOutTest();
});
describe("Masthead tests with kebab menu", () => {
beforeEach(() => {
cy.visit("");
loginPage.logIn();
masthead.setMobileMode(true);
});
it("shows kabab and hides regular menu", () => {
cy.get(masthead.userDrpDwn).should("not.exist");
cy.get(masthead.userDrpDwnKebab).should("exist");
});
// TODO: Add test for help when using kebab menu.
// Feature not yet implemented for kebab.
goToAcctMgtTest();
logOutTest();
});