2021-12-06 10:50:29 +00:00
|
|
|
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 Masthead from "../support/pages/admin_console/Masthead";
|
2022-01-07 07:27:58 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_hooks";
|
2022-02-24 10:31:46 +00:00
|
|
|
import adminClient from "../support/util/AdminClient";
|
2021-12-06 10:50:29 +00:00
|
|
|
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const sidebarPage = new SidebarPage();
|
|
|
|
const masthead = new Masthead();
|
|
|
|
const realmSettingsPage = new RealmSettingsPage();
|
|
|
|
|
|
|
|
describe("Realm settings tabs tests", () => {
|
|
|
|
const realmName = "Realm_" + (Math.random() + 1).toString(36).substring(7);
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToRealm(realmName);
|
|
|
|
});
|
|
|
|
|
|
|
|
before(async () => {
|
2022-02-24 10:31:46 +00:00
|
|
|
await adminClient.createRealm(realmName);
|
2021-12-06 10:50:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
after(async () => {
|
2022-02-24 10:31:46 +00:00
|
|
|
await adminClient.deleteRealm(realmName);
|
2021-12-06 10:50:29 +00:00
|
|
|
});
|
|
|
|
|
2022-01-03 15:00:03 +00:00
|
|
|
it("shows the 'user profile' tab if enabled", () => {
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
cy.findByTestId(realmSettingsPage.userProfileTab).should("not.exist");
|
2022-06-22 11:35:10 +00:00
|
|
|
realmSettingsPage.toggleSwitch(
|
|
|
|
realmSettingsPage.profileEnabledSwitch,
|
|
|
|
false
|
|
|
|
);
|
2022-01-03 15:00:03 +00:00
|
|
|
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
|
|
|
|
masthead.checkNotificationMessage("Realm successfully updated");
|
|
|
|
cy.findByTestId(realmSettingsPage.userProfileTab).should("exist");
|
|
|
|
});
|
|
|
|
|
2022-06-24 11:31:02 +00:00
|
|
|
// Clicking multiple toggles in succession causes quick re-renderings of the screen
|
|
|
|
// and there will be a noticeable flicker during the test.
|
|
|
|
// Sometimes, this will screw up the test and cause Cypress to hang.
|
|
|
|
// Clicking to another section each time fixes the problem.
|
|
|
|
function reloadRealm() {
|
|
|
|
sidebarPage.goToClientScopes();
|
2021-12-06 10:50:29 +00:00
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
cy.findByTestId("rs-login-tab").click();
|
2022-06-24 11:31:02 +00:00
|
|
|
}
|
2022-03-28 15:34:07 +00:00
|
|
|
|
2022-06-24 11:31:02 +00:00
|
|
|
function testToggle(realmSwitch: string, expectedValue: string) {
|
|
|
|
realmSettingsPage.toggleSwitch(realmSwitch);
|
|
|
|
reloadRealm();
|
|
|
|
cy.findByTestId(realmSwitch).should("have.value", expectedValue);
|
|
|
|
}
|
2022-03-28 15:34:07 +00:00
|
|
|
|
2022-06-24 11:31:02 +00:00
|
|
|
it("Go to login tab", () => {
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
cy.findByTestId("rs-login-tab").click();
|
2021-12-06 10:50:29 +00:00
|
|
|
|
2022-06-24 11:31:02 +00:00
|
|
|
testToggle(realmSettingsPage.userRegSwitch, "on");
|
|
|
|
testToggle(realmSettingsPage.forgotPwdSwitch, "on");
|
|
|
|
testToggle(realmSettingsPage.rememberMeSwitch, "on");
|
|
|
|
testToggle(realmSettingsPage.loginWithEmailSwitch, "off");
|
|
|
|
testToggle(realmSettingsPage.duplicateEmailsSwitch, "on");
|
2021-12-06 10:50:29 +00:00
|
|
|
|
2022-06-24 11:31:02 +00:00
|
|
|
// Check other values
|
2022-03-28 15:34:07 +00:00
|
|
|
cy.findByTestId(realmSettingsPage.emailAsUsernameSwitch).should(
|
|
|
|
"have.value",
|
|
|
|
"off"
|
|
|
|
);
|
|
|
|
|
|
|
|
cy.findByTestId(realmSettingsPage.verifyEmailSwitch).should(
|
|
|
|
"have.value",
|
|
|
|
"off"
|
|
|
|
);
|
2021-12-06 10:50:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Go to email tab", () => {
|
|
|
|
const msg: string = "Error! Failed to send email.";
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
cy.findByTestId("rs-email-tab").click();
|
2022-10-17 10:08:49 +00:00
|
|
|
//required fields not filled in or not filled properly
|
|
|
|
realmSettingsPage.addSenderEmail("not a valid email");
|
|
|
|
realmSettingsPage.fillFromDisplayName("displayName");
|
|
|
|
realmSettingsPage.fillReplyToEmail("replyTo@email.com");
|
|
|
|
realmSettingsPage.fillPort("10");
|
|
|
|
cy.findByTestId("email-tab-save").click();
|
|
|
|
cy.get("#kc-display-name-helper").contains("You must enter a valid email.");
|
|
|
|
cy.get("#kc-host-helper").contains("Required field");
|
|
|
|
//revert
|
|
|
|
cy.wait(100);
|
|
|
|
cy.findByTestId("email-tab-revert").click();
|
|
|
|
cy.findByTestId("sender-email-address").should("be.empty");
|
|
|
|
cy.findByTestId("from-display-name").should("be.empty");
|
|
|
|
cy.get("#kc-port").should("be.empty");
|
|
|
|
|
2021-12-06 10:50:29 +00:00
|
|
|
realmSettingsPage.addSenderEmail("example@example.com");
|
|
|
|
realmSettingsPage.toggleCheck(realmSettingsPage.enableSslCheck);
|
|
|
|
realmSettingsPage.toggleCheck(realmSettingsPage.enableStartTlsCheck);
|
|
|
|
realmSettingsPage.fillHostField("localhost");
|
2022-06-22 11:35:10 +00:00
|
|
|
cy.intercept(`/admin/realms/${realmName}/users/*`).as("load");
|
2021-12-06 10:50:29 +00:00
|
|
|
cy.findByTestId(realmSettingsPage.testConnectionButton).click();
|
2022-06-22 11:35:10 +00:00
|
|
|
cy.wait("@load");
|
2021-12-06 10:50:29 +00:00
|
|
|
|
2022-10-17 10:08:49 +00:00
|
|
|
//ln109-113 cause the tests to fail locally, but is needed for the test to pass on the dashboard.
|
2021-12-06 10:50:29 +00:00
|
|
|
realmSettingsPage.fillEmailField(
|
|
|
|
"example" + (Math.random() + 1).toString(36).substring(7) + "@example.com"
|
|
|
|
);
|
|
|
|
cy.findByTestId(realmSettingsPage.modalTestConnectionButton).click();
|
2022-10-17 10:08:49 +00:00
|
|
|
|
2021-12-06 10:50:29 +00:00
|
|
|
masthead.checkNotificationMessage(msg, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Go to themes tab", () => {
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
cy.findByTestId("rs-themes-tab").click();
|
|
|
|
|
|
|
|
realmSettingsPage.selectLoginThemeType("keycloak");
|
|
|
|
realmSettingsPage.selectAccountThemeType("keycloak");
|
|
|
|
realmSettingsPage.selectAdminThemeType("base");
|
|
|
|
realmSettingsPage.selectEmailThemeType("base");
|
|
|
|
|
|
|
|
realmSettingsPage.saveThemes();
|
|
|
|
});
|
|
|
|
});
|