Removed waits from realm test (#1906)

This commit is contained in:
Erik Jan de Wit 2022-01-24 15:17:55 +01:00 committed by GitHub
parent c4724b21c8
commit db63cdd61c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 81 additions and 39 deletions

View file

@ -1,30 +1,35 @@
import SidebarPage from "../support/pages/admin_console/SidebarPage";
import LoginPage from "../support/pages/LoginPage";
import RealmSettingsPage from "../support/pages/admin_console/manage/realm_settings/RealmSettingsPage";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import {
keycloakBefore,
keycloakBeforeEach,
} from "../support/util/keycloak_hooks";
import AdminClient from "../support/util/AdminClient";
const loginPage = new LoginPage();
const sidebarPage = new SidebarPage();
const realmSettingsPage = new RealmSettingsPage();
describe("Realm settings client policies tab tests", () => {
const realmName = "Realm_" + (Math.random() + 1).toString(36).substring(7);
const realmSettingsPage = new RealmSettingsPage(realmName);
beforeEach(() => {
keycloakBefore();
loginPage.logIn();
keycloakBeforeEach();
sidebarPage.goToRealm(realmName);
sidebarPage.goToRealmSettings();
cy.findByTestId("rs-clientPolicies-tab").click();
cy.findByTestId("rs-policies-clientPolicies-tab").click();
});
before(async () => {
await new AdminClient().createRealm(realmName);
before(() => {
keycloakBefore();
new AdminClient().createRealm(realmName);
loginPage.logIn();
});
after(async () => {
await new AdminClient().deleteRealm(realmName);
after(() => {
new AdminClient().deleteRealm(realmName);
});
it("Go to client policies tab", () => {
@ -96,14 +101,17 @@ describe("Realm settings client policies tab tests", () => {
});
it("Should not create duplicate client profile", () => {
const url = `/auth/admin/realms/${realmName}/client-policies/policies`;
cy.intercept("PUT", url).as("save");
realmSettingsPage.shouldCompleteAndCreateNewClientPolicyFromEmptyState();
cy.wait("@save");
sidebarPage.goToRealmSettings();
cy.findByTestId("rs-clientPolicies-tab").click();
cy.findByTestId("rs-policies-clientPolicies-tab").click();
realmSettingsPage.shouldCompleteAndCreateNewClientPolicy();
cy.wait("@save");
realmSettingsPage.shouldNotCreateDuplicateClientPolicy();
cy.wait(2000);
sidebarPage.goToRealmSettings();
cy.findByTestId("rs-clientPolicies-tab").click();
cy.findByTestId("rs-policies-clientPolicies-tab").click();

View file

@ -1,26 +1,31 @@
import SidebarPage from "../support/pages/admin_console/SidebarPage";
import LoginPage from "../support/pages/LoginPage";
import RealmSettingsPage from "../support/pages/admin_console/manage/realm_settings/RealmSettingsPage";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import {
keycloakBefore,
keycloakBeforeEach,
} from "../support/util/keycloak_hooks";
import AdminClient from "../support/util/AdminClient";
const loginPage = new LoginPage();
const sidebarPage = new SidebarPage();
const realmSettingsPage = new RealmSettingsPage();
describe("Realm settings client profiles tab tests", () => {
const realmName = "Realm_" + (Math.random() + 1).toString(36).substring(7);
const realmSettingsPage = new RealmSettingsPage(realmName);
beforeEach(() => {
keycloakBefore();
loginPage.logIn();
keycloakBeforeEach();
sidebarPage.goToRealm(realmName);
sidebarPage.goToRealmSettings();
cy.findByTestId("rs-clientPolicies-tab").click();
cy.findByTestId("rs-policies-clientProfiles-tab").click();
});
before(async () => {
await new AdminClient().createRealm(realmName);
before(() => {
keycloakBefore();
new AdminClient().createRealm(realmName);
loginPage.logIn();
});
after(async () => {

View file

@ -3,6 +3,7 @@ import SidebarPage from "../support/pages/admin_console/SidebarPage";
import CreateRealmPage from "../support/pages/admin_console/CreateRealmPage";
import Masthead from "../support/pages/admin_console/Masthead";
import AdminClient from "../support/util/AdminClient";
import RealmSelector from "../support/pages/admin_console/RealmSelector";
import {
keycloakBefore,
keycloakBeforeEach,
@ -12,6 +13,8 @@ const masthead = new Masthead();
const loginPage = new LoginPage();
const sidebarPage = new SidebarPage();
const createRealmPage = new CreateRealmPage();
const realmSelector = new RealmSelector();
const adminClient = new AdminClient();
describe("Realms test", () => {
const testRealmName = "Test realm";
@ -25,10 +28,9 @@ describe("Realms test", () => {
keycloakBeforeEach();
});
after(async () => {
const client = new AdminClient();
[testRealmName, "one", "two"].map(
async (realm) => await client.deleteRealm(realm)
after(() => {
[testRealmName, "one", "two"].map((realm) =>
adminClient.deleteRealm(realm)
);
});
@ -76,4 +78,23 @@ describe("Realms test", () => {
.should("eq", testRealmName);
});
});
describe("More then 5 realms", () => {
const realmNames = ["One", "Two", "Three", "Four", "Five"];
before(() => {
keycloakBefore();
loginPage.logIn();
realmNames.map((realm) => adminClient.createRealm(realm));
});
after(() => {
for (const realmName of realmNames) {
adminClient.deleteRealm(realmName);
}
});
it("switch to searchable realm selector", () => {
realmSelector.openRealmContextSelector().shouldContainAll(realmNames);
});
});
});

View file

@ -220,6 +220,11 @@ export default class RealmSettingsPage {
private deleteClientRolesCondition = "delete-client-roles-condition";
private deleteClientScopesCondition = "delete-client-scopes-condition";
private realmName?: string;
constructor(realmName?: string) {
this.realmName = realmName;
}
selectLoginThemeType(themeType: string) {
cy.get(this.selectLoginTheme).click();
cy.get(this.loginThemeList).contains(themeType).click();
@ -303,7 +308,7 @@ export default class RealmSettingsPage {
}
toggleAddProviderDropdown() {
const keysUrl = "/auth/admin/realms/master/keys";
const keysUrl = `/auth/admin/realms/${this.realmName}/keys`;
cy.intercept(keysUrl).as("keysFetch");
cy.findByTestId(this.addProviderDropdown).click();
@ -327,17 +332,6 @@ export default class RealmSettingsPage {
return this;
}
deleteProvider(providerName: string) {
cy.findAllByTestId("provider-name-link")
.contains(providerName)
.parent()
.siblings(".pf-c-data-list__item-action")
.click()
.findByTestId(this.deleteAction)
.click();
cy.wait(500).findByTestId(this.modalConfirm).click();
}
enterConsoleDisplayName(name: string) {
cy.findByTestId(this.displayName).clear().type(name);
}
@ -772,9 +766,9 @@ export default class RealmSettingsPage {
shouldCancelEditingExecutor() {
cy.get(this.clientProfileTwo).click();
cy.intercept("/auth/admin/realms/master/client-policies/profiles*").as(
"profilesFetch"
);
cy.intercept(
`/auth/admin/realms/${this.realmName}/client-policies/profiles*`
).as("profilesFetch");
cy.findByTestId(this.editExecutor).first().click();
cy.wait("@profilesFetch");
@ -1016,6 +1010,10 @@ export default class RealmSettingsPage {
}
shouldAddClientScopesCondition() {
cy.intercept(`/auth/admin/realms/${this.realmName}/client-scopes`).as(
"clientScopes"
);
cy.get(this.clientPolicy).click();
cy.findByTestId(this.addCondition).click();
cy.get(this.addConditionDrpDwn).click();
@ -1023,6 +1021,7 @@ export default class RealmSettingsPage {
.contains("client-scopes")
.click();
cy.wait("@clientScopes");
this.addClientScopes();
cy.findByTestId(this.addConditionSaveBtn).click();
@ -1051,12 +1050,13 @@ export default class RealmSettingsPage {
}
shouldEditClientScopesCondition() {
cy.intercept(`/auth/admin/realms/${this.realmName}/client-scopes`).as(
"clientScopes"
);
cy.get(this.clientPolicy).click();
cy.findByTestId(this.clientScopesConditionLink).click();
cy.wait(200);
cy.wait("@clientScopes");
this.addClientScopes();
cy.findByTestId(this.addConditionSaveBtn).click();
@ -1117,9 +1117,16 @@ export default class RealmSettingsPage {
cy.findByTestId(this.newClientPolicyDescriptionInput).type(
"Test Again Description"
);
cy.intercept(
"PUT",
`/auth/admin/realms/${this.realmName}/client-policies/policies`
).as("save");
cy.findByTestId(this.saveNewClientPolicyBtn).click();
cy.get(this.alertMessage).should("be.visible", "New client policy created");
cy.wait(500);
cy.wait("@save");
cy.get(".pf-c-alert").should("not.exist");
cy.findByTestId(this.clientPolicyDrpDwn).contains("Action").click();
cy.findByTestId("deleteClientPolicyDropdown").click();
cy.findByTestId("modalConfirm").contains("Delete").click();

View file

@ -199,7 +199,7 @@ export default {
accessTokenLifespanImplicitFlow: "Access Token Lifespan For Implicit Flow",
clientLoginTimeout: "Client Login Timeout",
userInitiatedActionLifespan: "User-Initiated Action Lifespan",
defaultAdminInitiated: "Default Admin-Initated Action Lifespan",
defaultAdminInitiated: "Default Admin-Initiated Action Lifespan",
emailVerification: "Email Verification",
idpAccountEmailVerification: "IdP account email verification",
executeActions: "Execute actions",
@ -211,6 +211,7 @@ export default {
createClientPolicy: "Create client policy",
createClientPolicySuccess: "New policy created",
updateClientPolicySuccess: "Client policy updated",
createClientPolicyError: "Could not create policy due to: {{error}}",
createClientConditionSuccess: "Condition created successfully.",
createClientConditionError: "Error creating condition: {{error}}",
updateClientConditionSuccess: "Condition updated successfully.",