Add realm selector tests (#2362)
This commit is contained in:
parent
bb226b52ff
commit
77ef19e0e6
5 changed files with 96 additions and 7 deletions
|
@ -29,7 +29,7 @@ const modalUtils = new ModalUtils();
|
|||
const createRealmRolePage = new CreateRealmRolePage();
|
||||
|
||||
describe("Clients test", () => {
|
||||
describe.skip("Client details - Client scopes subtab", () => {
|
||||
describe("Client details - Client scopes subtab", () => {
|
||||
const clientScopesTab = new ClientScopesTab();
|
||||
const clientId = "client-scopes-subtab-test";
|
||||
const clientScopeName = "client-scope-test";
|
||||
|
@ -203,7 +203,7 @@ describe("Clients test", () => {
|
|||
});*/
|
||||
});
|
||||
|
||||
describe.skip("Client creation", () => {
|
||||
describe("Client creation", () => {
|
||||
before(() => {
|
||||
keycloakBefore();
|
||||
loginPage.logIn();
|
||||
|
@ -356,10 +356,7 @@ describe("Clients test", () => {
|
|||
.searchItem("", false);
|
||||
|
||||
initialAccessTokenTab.getFirstId((id) => {
|
||||
listingPage
|
||||
.checkRowColumnValue(id, 4, "3")
|
||||
.checkRowColumnValue(id, 5, "3")
|
||||
.itemExist(id);
|
||||
listingPage.checkRowColumnValue(id, 4, "4").itemExist(id);
|
||||
});
|
||||
|
||||
listingPage.goToCreateItem();
|
||||
|
|
|
@ -4,11 +4,15 @@ import CreateRealmPage from "../support/pages/admin_console/CreateRealmPage";
|
|||
import Masthead from "../support/pages/admin_console/Masthead";
|
||||
import adminClient from "../support/util/AdminClient";
|
||||
import { keycloakBefore } from "../support/util/keycloak_hooks";
|
||||
import RealmSettings from "../support/pages/admin_console/configure/realm_settings/RealmSettings";
|
||||
import ModalUtils from "../support/util/ModalUtils";
|
||||
|
||||
const masthead = new Masthead();
|
||||
const loginPage = new LoginPage();
|
||||
const sidebarPage = new SidebarPage();
|
||||
const createRealmPage = new CreateRealmPage();
|
||||
const realmSettings = new RealmSettings();
|
||||
const modalUtils = new ModalUtils();
|
||||
|
||||
describe("Realms test", () => {
|
||||
const testRealmName =
|
||||
|
@ -40,13 +44,53 @@ describe("Realms test", () => {
|
|||
cy.reload();
|
||||
});
|
||||
|
||||
it("should fail creating realm with empty name", () => {
|
||||
sidebarPage.goToCreateRealm();
|
||||
createRealmPage.createRealm();
|
||||
|
||||
createRealmPage.verifyRealmNameFieldInvalid();
|
||||
cy.reload();
|
||||
});
|
||||
|
||||
it("should create Test realm", () => {
|
||||
sidebarPage.goToCreateRealm();
|
||||
|
||||
// Test and clear resource field
|
||||
createRealmPage.fillCodeEditor();
|
||||
createRealmPage.clearTextField();
|
||||
|
||||
createRealmPage.fillRealmName(testRealmName).createRealm();
|
||||
|
||||
masthead.checkNotificationMessage("Realm created");
|
||||
});
|
||||
|
||||
it("should create Test Disabled realm", () => {
|
||||
sidebarPage.goToCreateRealm();
|
||||
createRealmPage.fillRealmName("Test Disabled").createRealm();
|
||||
createRealmPage.disableRealm();
|
||||
|
||||
masthead.checkNotificationMessage("Realm created");
|
||||
});
|
||||
|
||||
it("Should cancel deleting Test Disabled realm", () => {
|
||||
sidebarPage.goToRealmSettings();
|
||||
realmSettings.clickActionMenu();
|
||||
cy.findByText("Delete").click();
|
||||
modalUtils.cancelModal();
|
||||
});
|
||||
|
||||
it("Should delete Test Disabled realm", () => {
|
||||
sidebarPage.goToRealmSettings();
|
||||
realmSettings.clickActionMenu();
|
||||
cy.findByText("Delete").click();
|
||||
modalUtils.confirmModal();
|
||||
masthead.checkNotificationMessage("The realm has been deleted");
|
||||
});
|
||||
|
||||
it("Should update realms on delete", () => {
|
||||
sidebarPage.showCurrentRealms(2);
|
||||
});
|
||||
|
||||
it("should create realm from new a realm", () => {
|
||||
sidebarPage.goToCreateRealm();
|
||||
createRealmPage.fillRealmName(newRealmName).createRealm();
|
||||
|
@ -66,6 +110,10 @@ describe("Realms test", () => {
|
|||
cy.wait(["@fetch"]);
|
||||
});
|
||||
|
||||
it("Should show current realms", () => {
|
||||
sidebarPage.showCurrentRealms(4);
|
||||
});
|
||||
|
||||
it("should change to Test realm", () => {
|
||||
sidebarPage.getCurrentRealm().should("eq", editedRealmName);
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
export default class CreateRealmPage {
|
||||
private browseBtn = "#kc-realm-filename-browse-button";
|
||||
private clearBtn = ".pf-c-file-upload__file-select button:last-child";
|
||||
private modalClearBtn = "clear-button";
|
||||
private realmFileNameInput = "#kc-realm-filename";
|
||||
private realmNameInput = "#kc-realm-name";
|
||||
private enabledSwitch =
|
||||
'[for="kc-realm-enabled-switch"] span.pf-c-switch__toggle';
|
||||
private createBtn = '.pf-c-form__group:last-child button[type="submit"]';
|
||||
private cancelBtn = '.pf-c-form__group:last-child button[type="button"]';
|
||||
private codeEditor = ".pf-c-code-editor__code";
|
||||
|
||||
fillRealmName(realmName: string) {
|
||||
cy.get(this.realmNameInput).clear().type(realmName);
|
||||
|
@ -14,15 +16,43 @@ export default class CreateRealmPage {
|
|||
return this;
|
||||
}
|
||||
|
||||
fillCodeEditor() {
|
||||
cy.get(this.codeEditor).click().type("clear this field");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
createRealm() {
|
||||
cy.get(this.createBtn).click();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
disableRealm() {
|
||||
cy.get(this.enabledSwitch).click();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
cancelRealmCreation() {
|
||||
cy.get(this.cancelBtn).click();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
clearTextField() {
|
||||
cy.get(this.clearBtn).click();
|
||||
cy.findByTestId(this.modalClearBtn).click();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
verifyRealmNameFieldInvalid() {
|
||||
cy.get(this.realmNameInput)
|
||||
.next("div")
|
||||
.contains("Required field")
|
||||
.should("have.class", "pf-m-error");
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,14 @@ export default class SidebarPage {
|
|||
private identityProvidersBtn = "#nav-item-identity-providers";
|
||||
private userFederationBtn = "#nav-item-user-federation";
|
||||
|
||||
showCurrentRealms(length: number) {
|
||||
cy.get(this.realmsDrpDwn).scrollIntoView().click({ force: true });
|
||||
cy.get(this.realmsList)
|
||||
.children("li")
|
||||
.should("have.length", length + 1); // account for button
|
||||
cy.get(this.realmsDrpDwn).click({ force: true });
|
||||
}
|
||||
|
||||
getCurrentRealm() {
|
||||
return cy.get(this.realmsDrpDwn).scrollIntoView().invoke("text");
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@ export const FileUploadForm = ({
|
|||
<Button
|
||||
key="confirm"
|
||||
variant="primary"
|
||||
data-testid="clear-button"
|
||||
onClick={() => {
|
||||
setFileUpload(defaultUpload);
|
||||
onChange("");
|
||||
|
@ -91,7 +92,12 @@ export const FileUploadForm = ({
|
|||
>
|
||||
{t("clear")}
|
||||
</Button>,
|
||||
<Button key="cancel" variant="link" onClick={removeDialog}>
|
||||
<Button
|
||||
data-testid="cancel"
|
||||
key="cancel"
|
||||
variant="link"
|
||||
onClick={removeDialog}
|
||||
>
|
||||
{t("cancel")}
|
||||
</Button>,
|
||||
]}
|
||||
|
|
Loading…
Reference in a new issue