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>
This commit is contained in:
Stan Silvert 2021-01-21 07:09:50 -05:00 committed by GitHub
parent 9ea2470aeb
commit f2e26b0049
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 463 additions and 410 deletions

View file

@ -30,6 +30,7 @@ export const Header = () => {
{adminClient.keycloak && (
<DropdownItem
key="manage account"
id="manage-account"
onClick={() => adminClient.keycloak.accountManagement()}
>
{t("manageAccount")}
@ -44,6 +45,7 @@ export const Header = () => {
<>
{adminClient.keycloak && (
<DropdownItem
id="sign-out"
key="sign out"
onClick={() => adminClient.keycloak.logout({ redirectUri: "" })}
>
@ -136,6 +138,7 @@ export const Header = () => {
return (
<Dropdown
id="user-dropdown-kebab"
isPlain
position="right"
toggle={<KebabToggle onToggle={onDropdownToggle} />}
@ -157,6 +160,7 @@ export const Header = () => {
<Dropdown
isPlain
position="right"
id="user-dropdown"
isOpen={isDropdownOpen}
toggle={
<DropdownToggle onToggle={onDropdownToggle}>
@ -175,6 +179,7 @@ export const Header = () => {
<Link to="/">
<Brand
src="/logo.svg"
id="masthead-logo"
alt="Logo"
className="keycloak__pageheader_brand"
/>

View file

@ -18,6 +18,7 @@ export const HelpItem = ({ helpText, forLabel, forID }: HelpItemProps) => {
{enabled && (
<Popover bodyContent={t(helpText)}>
<button
id={helpText}
aria-label={t(`helpLabel`, { label: forLabel })}
onClick={(e) => e.preventDefault()}
aria-describedby={forID}

View file

@ -6,6 +6,7 @@ exports[`<HelpItem /> render 1`] = `
aria-describedby="placeholder"
aria-label="helpLabel"
class="pf-c-form__group-label-help"
id="storybook"
>
<svg
aria-hidden="true"

View file

@ -113,7 +113,7 @@ export const ViewHeader = ({
</LevelItem>
</Level>
{enabled && (
<TextContent>
<TextContent id="view-header-subkey">
<Text>
{t(subKey)}
{subKeyLinkProps && (

View file

@ -1,19 +1,19 @@
#!/usr/bin/env node
const http = require('https');
const fs = require('fs');
const path = require('path');
const { spawn } = require('child_process');
const http = require("https");
const fs = require("fs");
const path = require("path");
const { spawn } = require("child_process");
const decompress = require('decompress');
const decompressTargz = require('decompress-targz');
const decompress = require("decompress");
const decompressTargz = require("decompress-targz");
const args = process.argv.slice(2);
const version = args[0] || '11.0.0';
const version = args[0] || "12.0.1";
const folder = 'server';
const fileName = path.join(folder, 'keycloak.tar.gz');
const folder = "server";
const fileName = path.join(folder, `keycloak-${version}.tar.gz`);
const serverPath = path.join(folder, `keycloak-${version}`);
const extension = process.platform === "win32" ? '.bat' : '.sh'
const extension = process.platform === "win32" ? ".bat" : ".sh";
if (!fs.existsSync(folder)) {
fs.mkdirSync(folder);
@ -21,33 +21,43 @@ if (!fs.existsSync(folder)) {
const decompressKeycloak = () =>
decompress(fileName, folder, {
plugins: [
decompressTargz()
]
}).then(() => {
console.log('Files decompressed');
}).catch(e => console.error(e));
;
plugins: [decompressTargz()],
})
.then(() => {
console.log("Files decompressed");
})
.catch((e) => console.error(e));
const run = () => {
const proc = spawn(path.join(serverPath, 'bin', `standalone${extension}`), ['-Djboss.socket.binding.port-offset=100']);
proc.stdout.on('data', (data) => {
const proc = spawn(path.join(serverPath, "bin", `standalone${extension}`), [
"-Djboss.socket.binding.port-offset=100",
]);
proc.stdout.on("data", (data) => {
console.log(data.toString());
});
}
};
const request = (url, file) => {
http.get(url, (response) => {
if (response.statusCode == 302) {
request(response.headers.location, file);
} else {
response.pipe(file);
response.on("end", () => {
console.log("Downloaded keycloak");
decompressKeycloak().then(() => run());
});
}
});
};
if (!fs.existsSync(fileName)) {
const file = fs.createWriteStream(fileName);
http.get(`https://downloads.jboss.org/keycloak/${version}/keycloak-${version}.tar.gz`, (response) => {
response.pipe(file)
response.on('end', () => {
console.log('Downloaded keycloak');
decompressKeycloak().then(() => run());
});
});
request(
`https://github.com/keycloak/keycloak/releases/download/${version}/keycloak-${version}.tar.gz`,
file
);
} else if (!fs.existsSync(serverPath)) {
decompressKeycloak().then(() => run());
} else {
run();
}

View file

@ -1,85 +1,74 @@
import LoginPage from '../support/pages/LoginPage.js'
import HeaderPage from '../support/pages/admin_console/HeaderPage.js'
import ListingPage from '../support/pages/admin_console/ListingPage.js'
import SidebarPage from '../support/pages/admin_console/SidebarPage.js'
import CreateClientScopePage from '../support/pages/admin_console/manage/client_scopes/CreateClientScopePage.js'
import LoginPage from "../support/pages/LoginPage.js";
import Masthead from "../support/pages/admin_console/Masthead.js";
import ListingPage from "../support/pages/admin_console/ListingPage.js";
import SidebarPage from "../support/pages/admin_console/SidebarPage.js";
import CreateClientScopePage from "../support/pages/admin_console/manage/client_scopes/CreateClientScopePage.js";
describe('Client Scopes test', function () {
describe("Client Scopes test", function () {
const itemId = "client_scope_1";
const loginPage = new LoginPage();
const masthead = new Masthead();
const sidebarPage = new SidebarPage();
const listingPage = new ListingPage();
const createClientScopePage = new CreateClientScopePage();
const itemId = 'client_scope_1';
const loginPage = new LoginPage();
const headerPage = new HeaderPage();
const sidebarPage = new SidebarPage();
const listingPage = new ListingPage();
const createClientScopePage = new CreateClientScopePage();
describe('Client Scope creation', function () {
beforeEach(function () {
cy.visit('')
})
describe("Client Scope creation", function () {
beforeEach(function () {
cy.visit("");
});
it('should fail creating client scope', function () {
loginPage.logIn();
it("should fail creating client scope", function () {
loginPage.logIn();
sidebarPage.goToClientScopes();
sidebarPage.goToClientScopes();
listingPage.goToCreateItem();
listingPage.goToCreateItem();
createClientScopePage
.save()
.checkClientNameRequiredMessage();
createClientScopePage.save().checkClientNameRequiredMessage();
createClientScopePage
.fillClientScopeData('address')
.save()
.checkClientNameRequiredMessage(false);
// The error should inform about duplicated name/id
headerPage.checkNotificationMessage('Could not create client scope: \'Error: Request failed with status code 409\'');
});
createClientScopePage
.fillClientScopeData("address")
.save()
.checkClientNameRequiredMessage(false);
it('should create client scope', function () {
loginPage.logIn();
// The error should inform about duplicated name/id
masthead.checkNotificationMessage(
"Could not create client scope: 'Error: Request failed with status code 409'"
);
});
sidebarPage.goToClientScopes();
it("should create client scope", function () {
loginPage.logIn();
listingPage
.itemExist(itemId, false)
.goToCreateItem();
sidebarPage.goToClientScopes();
createClientScopePage
.fillClientScopeData(itemId)
.save();
listingPage.itemExist(itemId, false).goToCreateItem();
headerPage.checkNotificationMessage('Client scope created');
createClientScopePage.fillClientScopeData(itemId).save();
sidebarPage.goToClientScopes();
listingPage
.itemExist(itemId)
.searchItem(itemId)
.itemExist(itemId);
});
})
masthead.checkNotificationMessage("Client scope created");
describe('Client scope elimination', function () {
beforeEach(function () {
cy.visit('')
})
it('should delete client scope', function () {
loginPage.logIn();
sidebarPage.goToClientScopes();
sidebarPage.goToClientScopes();
listingPage.itemExist(itemId).searchItem(itemId).itemExist(itemId);
});
});
listingPage
.itemExist(itemId)
.deleteItem(itemId); // There should be a confirmation pop-up
describe("Client scope elimination", function () {
beforeEach(function () {
cy.visit("");
});
headerPage.checkNotificationMessage('The client scope has been deleted');
it("should delete client scope", function () {
loginPage.logIn();
listingPage
.itemExist(itemId, false);
});
})
})
sidebarPage.goToClientScopes();
listingPage.itemExist(itemId).deleteItem(itemId); // There should be a confirmation pop-up
masthead.checkNotificationMessage("The client scope has been deleted");
listingPage.itemExist(itemId, false);
});
});
});

View file

@ -1,101 +1,91 @@
import LoginPage from '../support/pages/LoginPage.js'
import HeaderPage from '../support/pages/admin_console/HeaderPage.js'
import ListingPage from '../support/pages/admin_console/ListingPage.js'
import SidebarPage from '../support/pages/admin_console/SidebarPage.js'
import CreateClientPage from '../support/pages/admin_console/manage/clients/CreateClientPage.js'
import LoginPage from "../support/pages/LoginPage.js";
import Masthead from "../support/pages/admin_console/Masthead.js";
import ListingPage from "../support/pages/admin_console/ListingPage.js";
import SidebarPage from "../support/pages/admin_console/SidebarPage.js";
import CreateClientPage from "../support/pages/admin_console/manage/clients/CreateClientPage.js";
describe('Clients test', function () {
describe("Clients test", function () {
const itemId = "client_1";
const loginPage = new LoginPage();
const masthead = new Masthead();
const sidebarPage = new SidebarPage();
const listingPage = new ListingPage();
const createClientPage = new CreateClientPage();
const itemId = 'client_1';
const loginPage = new LoginPage();
const headerPage = new HeaderPage();
const sidebarPage = new SidebarPage();
const listingPage = new ListingPage();
const createClientPage = new CreateClientPage();
describe('Client creation', function () {
beforeEach(function () {
cy.visit('')
})
describe("Client creation", function () {
beforeEach(function () {
cy.visit("");
});
it('should fail creating client', function () {
loginPage.logIn();
it("should fail creating client", function () {
loginPage.logIn();
sidebarPage.goToClients();
sidebarPage.goToClients();
listingPage.goToCreateItem();
listingPage.goToCreateItem();
createClientPage
.continue()
.checkClientTypeRequiredMessage()
.checkClientIdRequiredMessage();
createClientPage
.fillClientData(itemId)
.continue()
.checkClientTypeRequiredMessage()
.checkClientIdRequiredMessage(false);
createClientPage
.fillClientData('')
.selectClientType('openid-connect')
.continue()
.checkClientTypeRequiredMessage(false)
.checkClientIdRequiredMessage();
createClientPage
.fillClientData('account')
.continue()
.continue();
// The error should inform about duplicated name/id
headerPage.checkNotificationMessage('Could not create client: \'Error: Request failed with status code 409\'');
});
createClientPage
.continue()
.checkClientTypeRequiredMessage()
.checkClientIdRequiredMessage();
it('should create client', function () {
loginPage.logIn();
createClientPage
.fillClientData(itemId)
.continue()
.checkClientTypeRequiredMessage()
.checkClientIdRequiredMessage(false);
sidebarPage.goToClients();
createClientPage
.fillClientData("")
.selectClientType("openid-connect")
.continue()
.checkClientTypeRequiredMessage(false)
.checkClientIdRequiredMessage();
listingPage
.itemExist(itemId, false)
.goToCreateItem();
createClientPage.fillClientData("account").continue().continue();
createClientPage
.selectClientType('openid-connect')
.fillClientData(itemId)
.continue()
.continue();
// The error should inform about duplicated name/id
masthead.checkNotificationMessage(
"Could not create client: 'Error: Request failed with status code 409'"
);
});
headerPage.checkNotificationMessage('Client created successfully');
it("should create client", function () {
loginPage.logIn();
sidebarPage.goToClients();
listingPage
.itemExist(itemId)
.searchItem(itemId)
.itemExist(itemId);
});
})
sidebarPage.goToClients();
describe('Client elimination', function () {
beforeEach(function () {
cy.visit('')
})
it('should delete client', function () {
loginPage.logIn();
listingPage.itemExist(itemId, false).goToCreateItem();
sidebarPage.goToClients();
createClientPage
.selectClientType("openid-connect")
.fillClientData(itemId)
.continue()
.continue();
listingPage
.itemExist(itemId)
.deleteItem(itemId); // There should be a confirmation pop-up
masthead.checkNotificationMessage("Client created successfully");
headerPage.checkNotificationMessage('The client has been deleted');
sidebarPage.goToClients();
listingPage
.itemExist(itemId, false);
});
})
})
listingPage.itemExist(itemId).searchItem(itemId).itemExist(itemId);
});
});
describe("Client elimination", function () {
beforeEach(function () {
cy.visit("");
});
it("should delete client", function () {
loginPage.logIn();
sidebarPage.goToClients();
listingPage.itemExist(itemId).deleteItem(itemId); // There should be a confirmation pop-up
masthead.checkNotificationMessage("The client has been deleted");
listingPage.itemExist(itemId, false);
});
});
});

View file

@ -1,31 +1,31 @@
import LoginPage from './../support/pages/LoginPage.js'
import HeaderPage from './../support/pages/admin_console/HeaderPage.js'
import LoginPage from "./../support/pages/LoginPage.js";
import Masthead from "./../support/pages/admin_console/Masthead.js";
describe('Logging In', function () {
describe("Logging In", function () {
const username = "admin";
const password = "admin";
const username = 'admin'
const password = 'admin'
const loginPage = new LoginPage();
const masthead = new Masthead();
const loginPage = new LoginPage();
const headerPage = new HeaderPage();
describe('Login form submission', function () {
beforeEach(function () {
cy.visit('')
})
it('displays errors on login', function () {
loginPage.logIn('wrong', 'user{enter}')
.checkErrorMessage('Invalid username or password.')
.isLogInPage();
})
it('redirects to admin console on success', function () {
loginPage.logIn(username, password);
describe("Login form submission", function () {
beforeEach(function () {
cy.visit("");
});
headerPage.isAdminConsole();
cy.getCookie('KEYCLOAK_SESSION_LEGACY').should('exist')
})
})
})
it("displays errors on login", function () {
loginPage
.logIn("wrong", "user{enter}")
.checkErrorMessage("Invalid username or password.")
.isLogInPage();
});
it("redirects to admin console on success", function () {
loginPage.logIn(username, password);
masthead.isAdminConsole();
cy.getCookie("KEYCLOAK_SESSION_LEGACY").should("exist");
});
});
});

View file

@ -0,0 +1,69 @@
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();
});

View file

@ -1,88 +1,75 @@
import LoginPage from '../support/pages/LoginPage.js'
import HeaderPage from '../support/pages/admin_console/HeaderPage.js'
import ListingPage from '../support/pages/admin_console/ListingPage.js'
import SidebarPage from '../support/pages/admin_console/SidebarPage.js'
import CreateRealmRolePage from '../support/pages/admin_console/manage/realm_roles/CreateRealmRolePage.js'
import LoginPage from "../support/pages/LoginPage.js";
import Masthead from "../support/pages/admin_console/Masthead.js";
import ModalUtils from "../support/util/ModalUtils.js";
import ListingPage from "../support/pages/admin_console/ListingPage.js";
import SidebarPage from "../support/pages/admin_console/SidebarPage.js";
import CreateRealmRolePage from "../support/pages/admin_console/manage/realm_roles/CreateRealmRolePage.js";
describe('Realm roles test', function () {
describe("Realm roles test", function () {
const itemId = "realm_role_1";
const loginPage = new LoginPage();
const masthead = new Masthead();
const modalUtils = new ModalUtils();
const sidebarPage = new SidebarPage();
const listingPage = new ListingPage();
const createRealmRolePage = new CreateRealmRolePage();
const itemId = 'realm_role_1';
const loginPage = new LoginPage();
const headerPage = new HeaderPage();
const sidebarPage = new SidebarPage();
const listingPage = new ListingPage();
const createRealmRolePage = new CreateRealmRolePage();
describe('Realm roles creation', function () {
beforeEach(function () {
cy.visit('')
})
describe("Realm roles creation", function () {
beforeEach(function () {
cy.visit("");
});
it('should fail creating realm role', function () {
loginPage.logIn();
it("should fail creating realm role", function () {
loginPage.logIn();
sidebarPage.goToRealmRoles();
sidebarPage.goToRealmRoles();
listingPage.goToCreateItem();
listingPage.goToCreateItem();
createRealmRolePage
.save()
.checkRealmRoleNameRequiredMessage();
createRealmRolePage
.fillRealmRoleData('admin')
.save();
// The error should inform about duplicated name/id (THIS MESSAGE DOES NOT HAVE QUOTES AS THE OTHERS)
headerPage.checkNotificationMessage('Could not create role: Role with name admin already exists');
});
createRealmRolePage.save().checkRealmRoleNameRequiredMessage();
it('should create realm role', function () {
loginPage.logIn();
createRealmRolePage.fillRealmRoleData("admin").save();
sidebarPage.goToRealmRoles();
// The error should inform about duplicated name/id (THIS MESSAGE DOES NOT HAVE QUOTES AS THE OTHERS)
masthead.checkNotificationMessage(
"Could not create role: Role with name admin already exists"
);
});
listingPage
.itemExist(itemId, false)
.goToCreateItem();
it("should create realm role", function () {
loginPage.logIn();
createRealmRolePage
.fillRealmRoleData(itemId)
.save();
sidebarPage.goToRealmRoles();
headerPage.checkNotificationMessage('Role created');
listingPage.itemExist(itemId, false).goToCreateItem();
sidebarPage.goToRealmRoles();
listingPage
.itemExist(itemId)
.searchItem(itemId)
.itemExist(itemId);
});
})
createRealmRolePage.fillRealmRoleData(itemId).save();
describe('Realm roles elimination', function () {
beforeEach(function () {
cy.visit('')
})
it('should delete realm role', function () {
loginPage.logIn();
masthead.checkNotificationMessage("Role created");
sidebarPage.goToRealmRoles();
sidebarPage.goToRealmRoles();
listingPage
.itemExist(itemId)
.deleteItem(itemId);
listingPage.itemExist(itemId).searchItem(itemId).itemExist(itemId);
});
});
headerPage
.checkModalTitle('Delete role?')
.confirmModal();
describe("Realm roles elimination", function () {
beforeEach(function () {
cy.visit("");
});
headerPage.checkNotificationMessage('The role has been deleted');
it("should delete realm role", function () {
loginPage.logIn();
listingPage
.itemExist(itemId, false);
});
})
})
sidebarPage.goToRealmRoles();
listingPage.itemExist(itemId).deleteItem(itemId);
modalUtils.checkModalTitle("Delete role?").confirmModal();
masthead.checkNotificationMessage("The role has been deleted");
listingPage.itemExist(itemId, false);
});
});
});

View file

@ -1,50 +1,45 @@
import LoginPage from '../support/pages/LoginPage.js'
import SidebarPage from '../support/pages/admin_console/SidebarPage.js'
import CreateRealmPage from '../support/pages/admin_console/CreateRealmPage.js'
import HeaderPage from '../support/pages/admin_console/HeaderPage.js'
import LoginPage from "../support/pages/LoginPage.js";
import SidebarPage from "../support/pages/admin_console/SidebarPage.js";
import CreateRealmPage from "../support/pages/admin_console/CreateRealmPage.js";
import Masthead from "../support/pages/admin_console/Masthead.js";
describe('Realms test', function () {
describe("Realms test", function () {
const loginPage = new LoginPage();
const sidebarPage = new SidebarPage();
const createRealmPage = new CreateRealmPage();
const masthead = new Masthead();
const loginPage = new LoginPage();
const sidebarPage = new SidebarPage();
const createRealmPage = new CreateRealmPage();
const headerPage = new HeaderPage();
describe('Realm creation', function () {
beforeEach(function () {
cy.visit('')
})
describe("Realm creation", function () {
beforeEach(function () {
cy.visit("");
});
it('should fail creating Master realm', function () {
loginPage.logIn();
it("should fail creating Master realm", function () {
loginPage.logIn();
sidebarPage.goToCreateRealm();
createRealmPage
.fillRealmName('master')
.createRealm();
sidebarPage.goToCreateRealm();
createRealmPage.fillRealmName("master").createRealm();
headerPage.checkNotificationMessage('Error: Request failed with status code 409');
});
masthead.checkNotificationMessage(
"Error: Request failed with status code 409"
);
});
it('should create Test realm', function () {
loginPage.logIn();
it("should create Test realm", function () {
loginPage.logIn();
sidebarPage.goToCreateRealm();
createRealmPage
.fillRealmName('Test')
.createRealm();
headerPage.checkNotificationMessage('Realm created');
});
sidebarPage.goToCreateRealm();
createRealmPage.fillRealmName("Test").createRealm();
it('should change to Test realm', function () {
loginPage.logIn();
masthead.checkNotificationMessage("Realm created");
});
sidebarPage.getCurrentRealm().should('eq', 'Master');
it("should change to Test realm", function () {
loginPage.logIn();
sidebarPage
.goToRealm('Test')
.getCurrentRealm().should('eq', 'Test');
});
})
})
sidebarPage.getCurrentRealm().should("eq", "Master");
sidebarPage.goToRealm("Test").getCurrentRealm().should("eq", "Test");
});
});
});

View file

@ -1,92 +0,0 @@
export default class HeaderPage {
constructor() {
this.menuBtn = '#nav-toggle';
this.logoBtn = 'img[alt="Logo"]';
this.helpBtn = '#help';
this.userDrpDwn = '[id*="pf-dropdown-toggle-id"]';
this.manageAccountBtn = '.pf-c-page__header-tools-item [role*="menu"] li:nth-child(1)';
this.serverInfoBtn = '.pf-c-page__header-tools-item [role*="menu"] li:nth-child(2)';
this.signOutBtn = '.pf-c-page__header-tools-item [role*="menu"] li:nth-child(4)';
this.notificationList = '.pf-c-alert-group.pf-m-toast';
this.modalTitle = '.pf-c-modal-box .pf-c-modal-box__title-text';
this.modalMessage = '.pf-c-modal-box .pf-c-modal-box__body';
this.confirmModalBtn = '#modal-confirm';
this.cancelModalBtn = '#modal-cancel';
this.closeModalBtn = '.pf-c-modal-box .pf-m-plain';
}
goToAdminConsole() {
cy.visit('');
return this;
}
goToManageAccount() {
cy.get(this.userDrpDwn).click();
cy.get(this.manageAccountBtn).click();
return this;
}
goToServerInfo() {
cy.get(this.userDrpDwn).click();
cy.get(this.serverInfoBtn).click();
return this;
}
signOut() {
cy.get(this.userDrpDwn).click();
cy.get(this.signOutBtn).click();
return this;
}
isAdminConsole() {
cy.get(this.logoBtn).should('exist');
cy.get(this.userDrpDwn).should('exist');
return this;
}
checkNotificationMessage(message) {
cy.contains(message).should('exist');
return this;
}
confirmModal() {
cy.get(this.confirmModalBtn).click();
return this;
}
cancelModal() {
cy.get(this.cancelModalBtn).click();
return this;
}
closeModal() {
cy.get(this.closeModalBtn).click();
return this;
}
checkModalTitle(title) {
cy.get(this.modalTitle).invoke('text').should('eq', title);
return this;
}
checkModalMessage(message) {
cy.get(this.modalMessage).invoke('text').should('eq', message);
return this;
}
}

View file

@ -0,0 +1,58 @@
export default class Masthead {
constructor() {
this.menuBtn = "#nav-toggle";
this.logoBtn = "#masthead-logo";
this.helpBtn = "#help";
this.userDrpDwn = "#user-dropdown";
this.userDrpDwnKebab = "#user-dropdown-kebab";
}
isAdminConsole() {
cy.get(this.logoBtn).should("exist");
cy.get(this.userDrpDwn).should("exist");
return this;
}
isMobileMode() {
return cy.window().specWindow.parent[0].innerWidth < 768;
}
setMobileMode(isMobileMode) {
if (isMobileMode) {
cy.viewport("iphone-6");
} else {
cy.viewport();
}
}
toggleGlobalHelp() {
cy.get(this.helpBtn).click();
cy.get("#enableHelp").click({ force: true });
}
userDropdown() {
if (this.isMobileMode()) {
return cy.get(this.userDrpDwnKebab);
} else {
return cy.get(this.userDrpDwn);
}
}
signOut() {
this.userDropdown().click();
cy.get("#sign-out").click();
}
accountManagement() {
this.userDropdown().click();
cy.get("#manage-account").click();
}
checkNotificationMessage(message) {
cy.contains(message).should("exist");
return this;
}
}

View file

@ -0,0 +1,40 @@
export default class ModalUtils {
constructor() {
this.modalTitle = ".pf-c-modal-box .pf-c-modal-box__title-text";
this.modalMessage = ".pf-c-modal-box .pf-c-modal-box__body";
this.confirmModalBtn = "#modal-confirm";
this.cancelModalBtn = "#modal-cancel";
this.closeModalBtn = ".pf-c-modal-box .pf-m-plain";
}
confirmModal() {
cy.get(this.confirmModalBtn).click();
return this;
}
cancelModal() {
cy.get(this.cancelModalBtn).click();
return this;
}
closeModal() {
cy.get(this.closeModalBtn).click();
return this;
}
checkModalTitle(title) {
cy.get(this.modalTitle).invoke("text").should("eq", title);
return this;
}
checkModalMessage(message) {
cy.get(this.modalMessage).invoke("text").should("eq", message);
return this;
}
}