Skip to content

Commit

Permalink
refactor: simplify login method in tests and add new admin monitoring…
Browse files Browse the repository at this point in the history
… and user management tests (#7041)
  • Loading branch information
pethers authored Jan 17, 2025
1 parent c0ceb9c commit d2accd2
Show file tree
Hide file tree
Showing 14 changed files with 421 additions and 302 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void shouldStartImportOperations() throws Exception {
try {
retryOnFailure(() -> {
try {
pageVisit.loginAsAdmin(pageVisit);
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(new PageModeMenuCommand(AdminViews.ADMIN_AGENT_OPERATIONVIEW_NAME, ""));

WebElement worldBankButton = pageVisit.findButton("Start IMPORT MODEL_EXTERNAL_WORLDBANK");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.hack23.cia.systemintegrationtest.admin;

import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.hack23.cia.systemintegrationtest.AbstractUITest;
import com.hack23.cia.systemintegrationtest.categories.IntegrationTest;
import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.PageCommandAdminConstants;

// ...imports...

@Category(IntegrationTest.class)
public class AdminApplicationSystemTest extends AbstractUITest {

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyApplicationSessionPaginationTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_APPLICATION_SESSION);
pageVisit.verifyPageContent("Application Session");

// Test last page
pageVisit.performClickAction(pageVisit.findButton("last page"));

// Test next page
pageVisit.performClickAction(pageVisit.findButton("next page"));
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyApplicationEventsChartTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_APPLICATION_EVENTS_CHARTS);
pageVisit.verifyPageContent("Charts");
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyApplicationSessionChartsTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_APPLICATION_SESSION_CHARTS);
pageVisit.verifyPageContent("Admin Application Session Charts");
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_APPLICATION_SESSION_CHARTS);
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyAgentOperationsTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_AGENT_OPERATION);
pageVisit.verifyPageContent("Agent Operations");
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_AGENT_OPERATION);
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyApplicationGridOperationsTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_APPLICATION_SESSION);
pageVisit.verifyPageContent("Application Session");
pageVisit.selectFirstGridRow();
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_APPLICATION_SESSION);
pageVisit.verifyPageContent("ApplicationActionEvent");
}

// ...other application management tests...
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.hack23.cia.systemintegrationtest.admin;

import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.hack23.cia.systemintegrationtest.AbstractUITest;
import com.hack23.cia.systemintegrationtest.categories.IntegrationTest;
import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.PageCommandAdminConstants;

@Category(IntegrationTest.class)
public class AdminConfigurationSystemTest extends AbstractUITest {

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyLanguageConfigurationTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_LANGUAGE);
pageVisit.verifyPageContent("Language");
pageVisit.selectFirstGridRow();
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_LANGUAGE);
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyCountryConfigurationTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_COUNTRY);
pageVisit.verifyPageContent("Country");
pageVisit.selectFirstGridRow();
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_COUNTRY);
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyPortalConfigurationTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_PORTAL);
pageVisit.verifyPageContent("Portal Configuration");
pageVisit.selectFirstGridRow();
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_PORTAL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void shouldUpdateConfiguration() throws Exception {
try {
retryOnFailure(() -> {
try {
pageVisit.loginAsAdmin(pageVisit);
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(
new PageModeMenuCommand(AdminViews.ADMIN_APPLICATIONS_CONFIGURATION_VIEW_NAME, ""));
pageVisit.verifyPageContent("Admin Application Configuration");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.hack23.cia.systemintegrationtest.admin;

import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.openqa.selenium.WebElement;

import com.hack23.cia.systemintegrationtest.AbstractUITest;
import com.hack23.cia.systemintegrationtest.categories.IntegrationTest;
import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.PageCommandAdminConstants;

// ...imports...

@Category(IntegrationTest.class)
public class AdminDataSummarySystemTest extends AbstractUITest {

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyDataManagementOperationsTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_DATASUMMARY);

// Test refresh views
WebElement refreshButton = pageVisit.findButton("Refresh Views");
assertNotNull(refreshButton);
pageVisit.performClickAction(refreshButton);

// Test update search index
WebElement indexButton = pageVisit.findButton("Update Search Index");
assertNotNull(indexButton);
pageVisit.performClickAction(indexButton);
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyDataManagementRemoveOperationsTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_DATASUMMARY);

assertNotNull("Expect to find Remove Application History button",
pageVisit.findButton("Remove Application History"));
assertNotNull("Expect to find Remove Documents button",
pageVisit.findButton("Remove Documents"));
assertNotNull("Expect to find Remove Politicians button",
pageVisit.findButton("Remove Politicians"));
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyAuthorDataSummaryTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_AUTHOR_DATASUMMARY);
pageVisit.verifyPageContent("Author Summary");
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_AUTHOR_DATASUMMARY);
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyRefreshViewsTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_DATASUMMARY);
final WebElement refreshViewsButton = pageVisit.findButton("Refresh Views");
assertNotNull("Expect to find a Refresh Views Button", refreshViewsButton);
pageVisit.performClickAction(refreshViewsButton);
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyRemoveDataOperationsButtonsTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_DATASUMMARY);
assertNotNull("Expect to find Remove Application History button", pageVisit.findButton("Remove Application History"));
assertNotNull("Expect to find Remove Documents button", pageVisit.findButton("Remove Documents"));
assertNotNull("Expect to find Remove Politicians button", pageVisit.findButton("Remove Politicians"));
}

// ...other data management tests...
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public final class AdminEmailTest extends AbstractUITest {
public void shouldSendValidEmail() {
retryOnFailure(() -> {
try {
pageVisit.loginAsAdmin(pageVisit);
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(new PageModeMenuCommand(AdminViews.ADMIN_EMAIL_VIEW_NAME, ""));
pageVisit.verifyPageContent("email");
pageVisit.sendEmailOnEmailPage("[email protected]", "Test Subject", "Test content");
Expand All @@ -31,7 +31,7 @@ public void shouldSendValidEmail() {
public void shouldFailWithInvalidEmail() {
retryOnFailure(() -> {
try {
pageVisit.loginAsAdmin(pageVisit);
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(new PageModeMenuCommand(AdminViews.ADMIN_EMAIL_VIEW_NAME, ""));
pageVisit.verifyPageContent("email");
pageVisit.sendEmailOnEmailPage("invalidemail", "Test Subject", "Test content");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.hack23.cia.systemintegrationtest.admin;

import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.hack23.cia.systemintegrationtest.AbstractUITest;
import com.hack23.cia.systemintegrationtest.categories.IntegrationTest;
import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.PageCommandAdminConstants;

@Category(IntegrationTest.class)
public class AdminMonitoringSystemTest extends AbstractUITest {

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyMonitoringAccessAndContentTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_MONITORING);
pageVisit.verifyPageContent("Admin Monitoring");
pageVisit.verifyPageContent("System Status");
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyMonitoringHealthIndicatorsTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_MONITORING);
pageVisit.verifyPageContent("Health Indicators");
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_MONITORING);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package com.hack23.cia.systemintegrationtest.admin;

import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.hack23.cia.systemintegrationtest.AbstractUITest;
import com.hack23.cia.systemintegrationtest.categories.IntegrationTest;
import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.PageCommandAdminConstants;

@Category(IntegrationTest.class)
public class AdminPageSystemTest extends AbstractUITest {

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyAgencyPageTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_AGENCY);
pageVisit.verifyPageContent("Agency");
pageVisit.selectFirstGridRow();
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_AGENCY);
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyAgentOperationTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_AGENT_OPERATION);
pageVisit.verifyPageContent("Agent Operation");
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_AGENT_OPERATION);
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyApplicationConfigurationPageTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_APPLICATION_CONFIGURATION);
pageVisit.verifyPageContent("Application Configuration");
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_APPLICATION_CONFIGURATION);
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyApplicationEventsPageTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_APPLICATION_EVENTS);
pageVisit.verifyPageContent("Admin Application Events");
pageVisit.selectFirstGridRow();
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_APPLICATION_EVENTS);
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyApplicationSessionPageTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_APPLICATION_SESSION);
pageVisit.verifyPageContent("Application Session");
pageVisit.selectFirstGridRow();
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_APPLICATION_SESSION);
pageVisit.verifyPageContent("ApplicationActionEvent");
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyMonitoringPageFailedAccessTest() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_MONITORING);
pageVisit.verifyPageContent("Access denied:adminmonitoring");
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyMonitoringPageSuccessTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_MONITORING);
pageVisit.verifyPageContent("Admin Monitoring");
assertFalse("Dont expect this content", pageVisit.getIframesHtmlBodyAsText().contains("Login with Username and Password"));
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyDataSummaryPageOperationsTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_DATASUMMARY);

// Verify all buttons exist
assertNotNull("Expect to find a Refresh Views Button", pageVisit.findButton("Refresh Views"));
assertNotNull("Expect to find Remove Application History button", pageVisit.findButton("Remove Application History"));
assertNotNull("Expect to find Remove Documents button", pageVisit.findButton("Remove Documents"));
assertNotNull("Expect to find Remove Politicians button", pageVisit.findButton("Remove Politicians"));
assertNotNull("Expect to find Update Search Index button", pageVisit.findButton("Update Search Index"));

// Test refresh views operation
pageVisit.performClickAction(pageVisit.findButton("Refresh Views"));

// Test search index update
pageVisit.performClickAction(pageVisit.findButton("Update Search Index"));
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyLanguagePageTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_LANGUAGE);
pageVisit.verifyPageContent("Language");
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_LANGUAGE);
}

@Test(timeout = DEFAULT_TIMEOUT)
public void verifyUserAccountPageTest() throws Exception {
pageVisit.loginAsAdmin();
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_USERACCOUNT);
pageVisit.verifyPageContent("User Account");
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_USERACCOUNT);
}
}
Loading

0 comments on commit d2accd2

Please sign in to comment.