2022-12-07 15:28:28 +00:00
|
|
|
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
|
2021-04-14 14:17:41 +00:00
|
|
|
import LoginPage from "../support/pages/LoginPage";
|
2022-12-07 15:28:28 +00:00
|
|
|
import PartialImportModal from "../support/pages/admin-ui/configure/realm_settings/PartialImportModal";
|
|
|
|
import RealmSettings from "../support/pages/admin-ui/configure/realm_settings/RealmSettings";
|
2022-03-09 16:42:51 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_hooks";
|
2022-02-24 10:31:46 +00:00
|
|
|
import adminClient from "../support/util/AdminClient";
|
2021-04-14 14:17:41 +00:00
|
|
|
|
|
|
|
describe("Partial import test", () => {
|
2022-04-27 09:07:23 +00:00
|
|
|
const TEST_REALM = "Partial-import-test-realm";
|
|
|
|
const TEST_REALM_2 = "Partial-import-test-realm-2";
|
2021-04-14 14:17:41 +00:00
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const sidebarPage = new SidebarPage();
|
2021-06-16 11:03:55 +00:00
|
|
|
const modal = new PartialImportModal();
|
2021-04-14 14:17:41 +00:00
|
|
|
const realmSettings = new RealmSettings();
|
|
|
|
|
2022-04-27 09:07:23 +00:00
|
|
|
beforeEach(() => {
|
2023-02-10 10:10:35 +00:00
|
|
|
loginPage.logIn();
|
|
|
|
keycloakBefore();
|
|
|
|
sidebarPage.goToRealm(TEST_REALM);
|
2021-04-14 14:17:41 +00:00
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
realmSettings.clickActionMenu();
|
|
|
|
});
|
|
|
|
|
2023-02-10 10:10:35 +00:00
|
|
|
before(() =>
|
|
|
|
Promise.all([
|
|
|
|
adminClient.createRealm(TEST_REALM),
|
|
|
|
adminClient.createRealm(TEST_REALM_2),
|
2023-07-11 14:03:21 +00:00
|
|
|
]),
|
2023-02-10 10:10:35 +00:00
|
|
|
);
|
2022-04-27 09:07:23 +00:00
|
|
|
|
|
|
|
after(async () => {
|
2022-06-24 13:35:02 +00:00
|
|
|
await Promise.all([
|
|
|
|
adminClient.deleteRealm(TEST_REALM),
|
|
|
|
adminClient.deleteRealm(TEST_REALM_2),
|
|
|
|
]);
|
2021-06-16 11:03:55 +00:00
|
|
|
});
|
|
|
|
|
2021-04-14 14:17:41 +00:00
|
|
|
it("Opens and closes partial import dialog", () => {
|
2021-06-16 11:03:55 +00:00
|
|
|
modal.open();
|
|
|
|
modal.importButton().should("be.disabled");
|
|
|
|
modal.cancelButton().click();
|
|
|
|
modal.importButton().should("not.exist");
|
2021-04-14 14:17:41 +00:00
|
|
|
});
|
|
|
|
|
2022-03-15 09:45:15 +00:00
|
|
|
it("Import button only enabled if JSON has something to import", () => {
|
2021-06-16 11:03:55 +00:00
|
|
|
modal.open();
|
2023-06-20 12:21:49 +00:00
|
|
|
modal.textArea().type("{}", { force: true });
|
2021-06-16 11:03:55 +00:00
|
|
|
modal.importButton().should("be.disabled");
|
2022-02-08 22:10:27 +00:00
|
|
|
modal.cancelButton().click();
|
2021-06-16 11:03:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Displays user options after multi-realm import", () => {
|
|
|
|
modal.open();
|
|
|
|
modal.typeResourceFile("multi-realm.json");
|
|
|
|
|
|
|
|
// Import button should be disabled if no checkboxes selected
|
|
|
|
modal.importButton().should("be.disabled");
|
|
|
|
modal.usersCheckbox().click();
|
|
|
|
modal.importButton().should("be.enabled");
|
|
|
|
modal.groupsCheckbox().click();
|
|
|
|
modal.importButton().should("be.enabled");
|
|
|
|
modal.groupsCheckbox().click();
|
|
|
|
modal.usersCheckbox().click();
|
|
|
|
modal.importButton().should("be.disabled");
|
|
|
|
|
|
|
|
// verify resource counts
|
2021-12-10 10:53:21 +00:00
|
|
|
modal.userCount().contains("1 Users");
|
|
|
|
modal.groupCount().contains("1 Groups");
|
|
|
|
modal.clientCount().contains("1 Clients");
|
|
|
|
modal.idpCount().contains("1 Identity providers");
|
|
|
|
modal.realmRolesCount().contains("2 Realm roles");
|
|
|
|
modal.clientRolesCount().contains("1 Client roles");
|
2021-06-16 11:03:55 +00:00
|
|
|
|
|
|
|
// import button should disable when switching realms
|
|
|
|
modal.usersCheckbox().click();
|
|
|
|
modal.importButton().should("be.enabled");
|
|
|
|
modal.selectRealm("realm2");
|
|
|
|
modal.importButton().should("be.disabled");
|
|
|
|
|
2021-12-10 10:53:21 +00:00
|
|
|
modal.clientCount().contains("2 Clients");
|
|
|
|
|
|
|
|
modal.clientsCheckbox().click();
|
|
|
|
modal.importButton().click();
|
|
|
|
|
|
|
|
cy.contains("2 records added");
|
|
|
|
cy.contains("customer-portal");
|
|
|
|
cy.contains("customer-portal2");
|
2022-02-08 22:10:27 +00:00
|
|
|
modal.closeButton().click();
|
2021-06-16 11:03:55 +00:00
|
|
|
});
|
|
|
|
|
2022-03-15 09:45:15 +00:00
|
|
|
it("Displays user options after realmless import and does the import", () => {
|
2022-04-27 09:07:23 +00:00
|
|
|
sidebarPage.goToRealm(TEST_REALM_2);
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
realmSettings.clickActionMenu();
|
2021-06-16 11:03:55 +00:00
|
|
|
modal.open();
|
|
|
|
|
|
|
|
modal.typeResourceFile("client-only.json");
|
|
|
|
|
|
|
|
modal.realmSelector().should("not.exist");
|
|
|
|
|
2021-12-10 10:53:21 +00:00
|
|
|
modal.clientCount().contains("1 Clients");
|
|
|
|
|
|
|
|
modal.usersCheckbox().should("not.exist");
|
|
|
|
modal.groupsCheckbox().should("not.exist");
|
|
|
|
modal.idpCheckbox().should("not.exist");
|
|
|
|
modal.realmRolesCheckbox().should("not.exist");
|
|
|
|
modal.clientRolesCheckbox().should("not.exist");
|
|
|
|
|
|
|
|
modal.clientsCheckbox().click();
|
|
|
|
modal.importButton().click();
|
2021-06-16 11:03:55 +00:00
|
|
|
|
2021-12-10 10:53:21 +00:00
|
|
|
cy.contains("One record added");
|
2024-06-18 07:06:10 +00:00
|
|
|
cy.contains("customer-portal3");
|
2022-06-24 13:35:02 +00:00
|
|
|
modal.closeButton().click();
|
2021-04-14 14:17:41 +00:00
|
|
|
});
|
|
|
|
|
2022-06-24 13:35:02 +00:00
|
|
|
it("Should clear the input with the button", () => {
|
|
|
|
modal.open();
|
|
|
|
|
|
|
|
//clear button should be disabled if there is nothing in the dialog
|
|
|
|
modal.clearButton().should("be.disabled");
|
2024-06-18 07:06:10 +00:00
|
|
|
modal.textArea().get(".view-lines").should("have.text", "");
|
2024-06-19 11:29:45 +00:00
|
|
|
modal.textArea().get(".view-lines").click();
|
2024-06-18 07:06:10 +00:00
|
|
|
modal.textArea().type("{}", { force: true });
|
|
|
|
modal.textArea().get(".view-lines").should("have.text", "{}");
|
2022-06-24 13:35:02 +00:00
|
|
|
modal.clearButton().should("not.be.disabled");
|
|
|
|
modal.clearButton().click();
|
|
|
|
modal.clickClearConfirmButton();
|
|
|
|
modal.textArea().get(".view-lines").should("have.text", "");
|
|
|
|
});
|
2021-04-14 14:17:41 +00:00
|
|
|
});
|