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:
parent
9ea2470aeb
commit
f2e26b0049
14 changed files with 463 additions and 410 deletions
|
@ -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"
|
||||
/>
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -113,7 +113,7 @@ export const ViewHeader = ({
|
|||
</LevelItem>
|
||||
</Level>
|
||||
{enabled && (
|
||||
<TextContent>
|
||||
<TextContent id="view-header-subkey">
|
||||
<Text>
|
||||
{t(subKey)}
|
||||
{subKeyLinkProps && (
|
||||
|
|
68
start.js
68
start.js
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
createClientScopePage
|
||||
.fillClientScopeData('address')
|
||||
.save()
|
||||
.checkClientNameRequiredMessage(false);
|
||||
// The error should inform about duplicated name/id
|
||||
masthead.checkNotificationMessage(
|
||||
"Could not create client scope: 'Error: Request failed with status code 409'"
|
||||
);
|
||||
});
|
||||
|
||||
// The error should inform about duplicated name/id
|
||||
headerPage.checkNotificationMessage('Could not create client scope: \'Error: Request failed with status code 409\'');
|
||||
});
|
||||
it("should create client scope", function () {
|
||||
loginPage.logIn();
|
||||
|
||||
it('should create client scope', function () {
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToClientScopes();
|
||||
|
||||
sidebarPage.goToClientScopes();
|
||||
listingPage.itemExist(itemId, false).goToCreateItem();
|
||||
|
||||
listingPage
|
||||
.itemExist(itemId, false)
|
||||
.goToCreateItem();
|
||||
createClientScopePage.fillClientScopeData(itemId).save();
|
||||
|
||||
createClientScopePage
|
||||
.fillClientScopeData(itemId)
|
||||
.save();
|
||||
masthead.checkNotificationMessage("Client scope created");
|
||||
|
||||
headerPage.checkNotificationMessage('Client scope created');
|
||||
sidebarPage.goToClientScopes();
|
||||
|
||||
sidebarPage.goToClientScopes();
|
||||
listingPage.itemExist(itemId).searchItem(itemId).itemExist(itemId);
|
||||
});
|
||||
});
|
||||
|
||||
listingPage
|
||||
.itemExist(itemId)
|
||||
.searchItem(itemId)
|
||||
.itemExist(itemId);
|
||||
});
|
||||
})
|
||||
describe("Client scope elimination", function () {
|
||||
beforeEach(function () {
|
||||
cy.visit("");
|
||||
});
|
||||
|
||||
describe('Client scope elimination', function () {
|
||||
beforeEach(function () {
|
||||
cy.visit('')
|
||||
})
|
||||
it("should delete client scope", function () {
|
||||
loginPage.logIn();
|
||||
|
||||
it('should delete client scope', function () {
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToClientScopes();
|
||||
|
||||
sidebarPage.goToClientScopes();
|
||||
listingPage.itemExist(itemId).deleteItem(itemId); // There should be a confirmation pop-up
|
||||
|
||||
listingPage
|
||||
.itemExist(itemId)
|
||||
.deleteItem(itemId); // There should be a confirmation pop-up
|
||||
masthead.checkNotificationMessage("The client scope has been deleted");
|
||||
|
||||
headerPage.checkNotificationMessage('The client scope has been deleted');
|
||||
|
||||
listingPage
|
||||
.itemExist(itemId, false);
|
||||
});
|
||||
})
|
||||
})
|
||||
listingPage.itemExist(itemId, false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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
|
||||
.continue()
|
||||
.checkClientTypeRequiredMessage()
|
||||
.checkClientIdRequiredMessage();
|
||||
createClientPage
|
||||
.fillClientData(itemId)
|
||||
.continue()
|
||||
.checkClientTypeRequiredMessage()
|
||||
.checkClientIdRequiredMessage(false);
|
||||
|
||||
createClientPage
|
||||
.fillClientData(itemId)
|
||||
.continue()
|
||||
.checkClientTypeRequiredMessage()
|
||||
.checkClientIdRequiredMessage(false);
|
||||
createClientPage
|
||||
.fillClientData("")
|
||||
.selectClientType("openid-connect")
|
||||
.continue()
|
||||
.checkClientTypeRequiredMessage(false)
|
||||
.checkClientIdRequiredMessage();
|
||||
|
||||
createClientPage
|
||||
.fillClientData('')
|
||||
.selectClientType('openid-connect')
|
||||
.continue()
|
||||
.checkClientTypeRequiredMessage(false)
|
||||
.checkClientIdRequiredMessage();
|
||||
createClientPage.fillClientData("account").continue().continue();
|
||||
|
||||
createClientPage
|
||||
.fillClientData('account')
|
||||
.continue()
|
||||
.continue();
|
||||
// The error should inform about duplicated name/id
|
||||
masthead.checkNotificationMessage(
|
||||
"Could not create client: 'Error: Request failed with status code 409'"
|
||||
);
|
||||
});
|
||||
|
||||
// The error should inform about duplicated name/id
|
||||
headerPage.checkNotificationMessage('Could not create client: \'Error: Request failed with status code 409\'');
|
||||
});
|
||||
it("should create client", function () {
|
||||
loginPage.logIn();
|
||||
|
||||
it('should create client', function () {
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToClients();
|
||||
|
||||
sidebarPage.goToClients();
|
||||
listingPage.itemExist(itemId, false).goToCreateItem();
|
||||
|
||||
listingPage
|
||||
.itemExist(itemId, false)
|
||||
.goToCreateItem();
|
||||
createClientPage
|
||||
.selectClientType("openid-connect")
|
||||
.fillClientData(itemId)
|
||||
.continue()
|
||||
.continue();
|
||||
|
||||
createClientPage
|
||||
.selectClientType('openid-connect')
|
||||
.fillClientData(itemId)
|
||||
.continue()
|
||||
.continue();
|
||||
masthead.checkNotificationMessage("Client created successfully");
|
||||
|
||||
headerPage.checkNotificationMessage('Client created successfully');
|
||||
sidebarPage.goToClients();
|
||||
|
||||
sidebarPage.goToClients();
|
||||
listingPage.itemExist(itemId).searchItem(itemId).itemExist(itemId);
|
||||
});
|
||||
});
|
||||
|
||||
listingPage
|
||||
.itemExist(itemId)
|
||||
.searchItem(itemId)
|
||||
.itemExist(itemId);
|
||||
});
|
||||
})
|
||||
describe("Client elimination", function () {
|
||||
beforeEach(function () {
|
||||
cy.visit("");
|
||||
});
|
||||
|
||||
describe('Client elimination', function () {
|
||||
beforeEach(function () {
|
||||
cy.visit('')
|
||||
})
|
||||
it("should delete client", function () {
|
||||
loginPage.logIn();
|
||||
|
||||
it('should delete client', function () {
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToClients();
|
||||
|
||||
sidebarPage.goToClients();
|
||||
listingPage.itemExist(itemId).deleteItem(itemId); // There should be a confirmation pop-up
|
||||
|
||||
listingPage
|
||||
.itemExist(itemId)
|
||||
.deleteItem(itemId); // There should be a confirmation pop-up
|
||||
masthead.checkNotificationMessage("The client has been deleted");
|
||||
|
||||
headerPage.checkNotificationMessage('The client has been deleted');
|
||||
|
||||
listingPage
|
||||
.itemExist(itemId, false);
|
||||
});
|
||||
})
|
||||
})
|
||||
listingPage.itemExist(itemId, false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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("");
|
||||
});
|
||||
|
||||
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('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);
|
||||
|
||||
it('redirects to admin console on success', function () {
|
||||
loginPage.logIn(username, password);
|
||||
masthead.isAdminConsole();
|
||||
|
||||
headerPage.isAdminConsole();
|
||||
|
||||
cy.getCookie('KEYCLOAK_SESSION_LEGACY').should('exist')
|
||||
})
|
||||
})
|
||||
})
|
||||
cy.getCookie("KEYCLOAK_SESSION_LEGACY").should("exist");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
69
tests/cypress/integration/masthead_test.spec.js
Normal file
69
tests/cypress/integration/masthead_test.spec.js
Normal 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();
|
||||
});
|
|
@ -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
|
||||
.save()
|
||||
.checkRealmRoleNameRequiredMessage();
|
||||
createRealmRolePage.fillRealmRoleData("admin").save();
|
||||
|
||||
createRealmRolePage
|
||||
.fillRealmRoleData('admin')
|
||||
.save();
|
||||
// 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"
|
||||
);
|
||||
});
|
||||
|
||||
// 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');
|
||||
});
|
||||
it("should create realm role", function () {
|
||||
loginPage.logIn();
|
||||
|
||||
it('should create realm role', function () {
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToRealmRoles();
|
||||
|
||||
sidebarPage.goToRealmRoles();
|
||||
listingPage.itemExist(itemId, false).goToCreateItem();
|
||||
|
||||
listingPage
|
||||
.itemExist(itemId, false)
|
||||
.goToCreateItem();
|
||||
createRealmRolePage.fillRealmRoleData(itemId).save();
|
||||
|
||||
createRealmRolePage
|
||||
.fillRealmRoleData(itemId)
|
||||
.save();
|
||||
masthead.checkNotificationMessage("Role created");
|
||||
|
||||
headerPage.checkNotificationMessage('Role created');
|
||||
sidebarPage.goToRealmRoles();
|
||||
|
||||
sidebarPage.goToRealmRoles();
|
||||
listingPage.itemExist(itemId).searchItem(itemId).itemExist(itemId);
|
||||
});
|
||||
});
|
||||
|
||||
listingPage
|
||||
.itemExist(itemId)
|
||||
.searchItem(itemId)
|
||||
.itemExist(itemId);
|
||||
});
|
||||
})
|
||||
describe("Realm roles elimination", function () {
|
||||
beforeEach(function () {
|
||||
cy.visit("");
|
||||
});
|
||||
|
||||
describe('Realm roles elimination', function () {
|
||||
beforeEach(function () {
|
||||
cy.visit('')
|
||||
})
|
||||
it("should delete realm role", function () {
|
||||
loginPage.logIn();
|
||||
|
||||
it('should delete realm role', function () {
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToRealmRoles();
|
||||
|
||||
sidebarPage.goToRealmRoles();
|
||||
listingPage.itemExist(itemId).deleteItem(itemId);
|
||||
|
||||
listingPage
|
||||
.itemExist(itemId)
|
||||
.deleteItem(itemId);
|
||||
modalUtils.checkModalTitle("Delete role?").confirmModal();
|
||||
|
||||
headerPage
|
||||
.checkModalTitle('Delete role?')
|
||||
.confirmModal();
|
||||
masthead.checkNotificationMessage("The role has been deleted");
|
||||
|
||||
headerPage.checkNotificationMessage('The role has been deleted');
|
||||
|
||||
listingPage
|
||||
.itemExist(itemId, false);
|
||||
});
|
||||
})
|
||||
})
|
||||
listingPage.itemExist(itemId, false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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();
|
||||
masthead.checkNotificationMessage(
|
||||
"Error: Request failed with status code 409"
|
||||
);
|
||||
});
|
||||
|
||||
headerPage.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();
|
||||
|
||||
sidebarPage.goToCreateRealm();
|
||||
createRealmPage
|
||||
.fillRealmName('Test')
|
||||
.createRealm();
|
||||
masthead.checkNotificationMessage("Realm created");
|
||||
});
|
||||
|
||||
headerPage.checkNotificationMessage('Realm created');
|
||||
});
|
||||
it("should change to Test realm", function () {
|
||||
loginPage.logIn();
|
||||
|
||||
it('should change to Test realm', function () {
|
||||
loginPage.logIn();
|
||||
sidebarPage.getCurrentRealm().should("eq", "Master");
|
||||
|
||||
sidebarPage.getCurrentRealm().should('eq', 'Master');
|
||||
|
||||
sidebarPage
|
||||
.goToRealm('Test')
|
||||
.getCurrentRealm().should('eq', 'Test');
|
||||
});
|
||||
})
|
||||
})
|
||||
sidebarPage.goToRealm("Test").getCurrentRealm().should("eq", "Test");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
58
tests/cypress/support/pages/admin_console/Masthead.js
Normal file
58
tests/cypress/support/pages/admin_console/Masthead.js
Normal 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;
|
||||
}
|
||||
}
|
40
tests/cypress/support/util/ModalUtils.js
Normal file
40
tests/cypress/support/util/ModalUtils.js
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue