Skip to content

Commit

Permalink
Add user home command constants and update menu item factories (#7100)
Browse files Browse the repository at this point in the history
* Add user home command constants and update menu item factories

* Refactor UserViews constructor to private and remove ambiguous comment from PageCommandGovernmentBodyRankingConstants; add integration tests for government body and committee ranking pages.

* Refactor PageCommandCommitteeRankingConstants to remove ambiguous comment; update UserParliamentTest for consistency in command usage

* Add integration tests for committees, government bodies, parliament, and parties; verify page links and visit history

* Refactor view content verification in admin tests; replace calls to deprecated method with direct pageVisit verification

* Add content verification for government body ranking pages in integration tests

* Refactor government body ranking tests; rename methods for clarity and add content verification for income, expenditure, and visit history pages.

* Add content verification for party and committee ranking pages in integration tests

* Add content verification for politician ranking pages in integration tests

* Add content verification for ministry ranking pages in integration tests
  • Loading branch information
pethers authored Jan 26, 2025
1 parent 4e02d85 commit d5b1561
Show file tree
Hide file tree
Showing 22 changed files with 485 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,4 @@ public interface PageCommandCommitteeRankingConstants {
PageModeMenuCommand COMMAND_CHARTS_CURRENT_COMMITTEES = new PageModeMenuCommand(
UserViews.COMMITTEE_RANKING_VIEW_NAME, PageMode.CHARTS, "CURRENT_COMMITTEES");


// Remove this line to avoid ambiguity
// PageModeMenuCommand COMMAND_PAGEVISIT_HISTORY = COMMITTEE_RANKING_COMMAND_PAGEVISIT_HISTORY;
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,4 @@ public interface PageCommandGovernmentBodyRankingConstants {
new PageModeMenuCommand(UserViews.GOVERNMENT_BODY_RANKING_VIEW_NAME, PageMode.PAGEVISITHISTORY);



// Remove this line to avoid ambiguity
// PageModeMenuCommand COMMAND_PAGEVISITHISTORY = GOVERNMENT_RANKING_COMMAND_PAGEVISIT_HISTORY;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*/
public interface PageCommandUserConstants
extends PageCommandAdminConstants, PageCommandBallotConstants, PageCommandCommitteeConstants,
PageCommandCommitteeRankingConstants, PageCommandCountryRankingConstants, PageCommandDocumentConstants,
PageCommandCommitteeRankingConstants, PageCommandDocumentConstants,
PageCommandGovernmentBodyConstants, PageCommandMainViewConstants, PageCommandGovernmentBodyRankingConstants,
PageCommandMinistryConstants, PageCommandMinistryRankingConstants, PageCommandParliamentRankingConstants,
PageCommandPartyConstants, PageCommandPartyRankingConstants, PageCommandPoliticianRankingConstants {
PageCommandPartyConstants, PageCommandPartyRankingConstants, PageCommandPoliticianRankingConstants,PageCommandUserHomeConstants {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.pagecommands;

import com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand;
import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserHomePageMode;
import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;

/**
* The Interface PageCommandUserHomeConstants.
*/
public interface PageCommandUserHomeConstants {

/** The command userhome overview. */
PageModeMenuCommand COMMAND_USERHOME_OVERVIEW = new PageModeMenuCommand(
UserViews.USERHOME_VIEW_NAME, PageMode.OVERVIEW);

/** The command userhome security settings. */
PageModeMenuCommand COMMAND_USERHOME_SECURITY_SETTINGS = new PageModeMenuCommand(
UserViews.USERHOME_VIEW_NAME, UserHomePageMode.SECURITY_SETTINGS.toString());

/** The command userhome user visits. */
PageModeMenuCommand COMMAND_USERHOME_USER_VISITS = new PageModeMenuCommand(
UserViews.USERHOME_VIEW_NAME, UserHomePageMode.USER_VISITS.toString());

/** The command userhome user events. */
PageModeMenuCommand COMMAND_USERHOME_USER_EVENTS = new PageModeMenuCommand(
UserViews.USERHOME_VIEW_NAME, UserHomePageMode.USER_EVENTS.toString());

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* The Class ApplicationMenuItemFactoryImpl.
*/
@Service
public final class ApplicationMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl implements ApplicationMenuItemFactory,PageCommandUserConstants {
public final class ApplicationMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl implements ApplicationMenuItemFactory {

/** The committee ranking menu item factory. */
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* overview pages with relevant descriptions and icons.
*/
@Service
public final class BallotMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl implements BallotMenuItemFactory,PageCommandBallotConstants {
public final class BallotMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl implements BallotMenuItemFactory {

/** The Constant CHARTS_TEXT. */
private static final String CHARTS_TEXT = "Charts";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.MinistryRankingMenuItemFactory;
import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.pagecommands.PageCommandGovernmentBodyRankingConstants;
import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.pagecommands.PageCommandMinistryRankingConstants;
import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.pagecommands.PageCommandUserConstants;
import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.text.MenuItemRankingPageVisitHistoryConstants;
import com.hack23.cia.web.impl.ui.application.views.common.rows.RowUtil;
import com.jarektoro.responsivelayout.ResponsiveRow;
Expand All @@ -39,7 +38,7 @@
*/
@Service
public final class MinistryRankingMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl
implements MinistryRankingMenuItemFactory,PageCommandUserConstants {
implements MinistryRankingMenuItemFactory {

/** The application menu item factory. */
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@

import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.ApplicationMenuItemFactory;
import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.UserHomeMenuItemFactory;
import com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand;
import com.hack23.cia.web.impl.ui.application.views.common.rows.RowUtil;
import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserHomePageMode;
import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
import com.jarektoro.responsivelayout.ResponsiveRow;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.ui.MenuBar;
Expand All @@ -44,52 +40,40 @@ public final class UserHomeMenuItemFactoryImpl extends AbstractMenuItemFactoryIm
@Autowired
private ApplicationMenuItemFactory applicationMenuItemFactory;

/**
* Instantiates a new user home menu item factory impl.
*/
public UserHomeMenuItemFactoryImpl() {
super();
}
@Override
public void createOverviewPage(final VerticalLayout overviewLayout) {
final ResponsiveRow grid = RowUtil.createGridLayout(overviewLayout);

@Override
public void createOverviewPage(final VerticalLayout overviewLayout) {
final ResponsiveRow grid = RowUtil.createGridLayout(overviewLayout);
createButtonLink(grid, SECURITY_SETTING_TEXT, VaadinIcons.SHIELD,
COMMAND_USERHOME_SECURITY_SETTINGS,
SECURITY_SETTINGS_DESCRIPTION);

createButtonLink(grid, SECURITY_SETTING_TEXT, VaadinIcons.SHIELD,
new PageModeMenuCommand(UserViews.USERHOME_VIEW_NAME, UserHomePageMode.SECURITY_SETTINGS.toString(),
""),
SECURITY_SETTINGS_DESCRIPTION);
createButtonLink(grid, USER_VISITS, VaadinIcons.EYE,
COMMAND_USERHOME_USER_VISITS,
USER_VISITS_DESCRIPTION);

createButtonLink(grid, USER_VISITS, VaadinIcons.EYE,
new PageModeMenuCommand(UserViews.USERHOME_VIEW_NAME, UserHomePageMode.USER_VISITS.toString()),
USER_VISITS_DESCRIPTION);
createButtonLink(grid, USER_EVENTS, VaadinIcons.CALENDAR,
COMMAND_USERHOME_USER_EVENTS,
USER_EVENTS_DESCRIPTION);
}

createButtonLink(grid, USER_EVENTS, VaadinIcons.CALENDAR,
new PageModeMenuCommand(UserViews.USERHOME_VIEW_NAME, UserHomePageMode.USER_EVENTS.toString()),
USER_EVENTS_DESCRIPTION);
@Override
public void createUserHomeMenuBar(final MenuBar menuBar, final String pageId) {
initApplicationMenuBar(menuBar);

}
applicationMenuItemFactory.addRankingMenu(menuBar);
final MenuItem accountItem = menuBar.addItem(USERACCOUNT, VaadinIcons.USER, null);

@Override
public void createUserHomeMenuBar(final MenuBar menuBar, final String pageId) {
initApplicationMenuBar(menuBar);
accountItem.addItem(USER_HOME_OVERVIEW_TEXT, VaadinIcons.USER,
COMMAND_USERHOME_OVERVIEW);

applicationMenuItemFactory.addRankingMenu(menuBar);
final MenuItem accountItem = menuBar.addItem(USERACCOUNT, VaadinIcons.USER, null);
accountItem.addItem(SECURITY_SETTING_TEXT, VaadinIcons.SHIELD,
COMMAND_USERHOME_SECURITY_SETTINGS);

accountItem.addItem(USER_HOME_OVERVIEW_TEXT, VaadinIcons.USER,
new PageModeMenuCommand(UserViews.USERHOME_VIEW_NAME, PageMode.OVERVIEW, pageId));

accountItem.addItem(SECURITY_SETTING_TEXT, VaadinIcons.SHIELD,
new PageModeMenuCommand(UserViews.USERHOME_VIEW_NAME, UserHomePageMode.SECURITY_SETTINGS.toString(),
pageId));

accountItem.addItem(USER_VISITS, VaadinIcons.EYE,
new PageModeMenuCommand(UserViews.USERHOME_VIEW_NAME, UserHomePageMode.USER_VISITS.toString(), pageId));

accountItem.addItem(USER_EVENTS, VaadinIcons.CALENDAR,
new PageModeMenuCommand(UserViews.USERHOME_VIEW_NAME, UserHomePageMode.USER_EVENTS.toString(), pageId));

}
accountItem.addItem(USER_VISITS, VaadinIcons.EYE,
COMMAND_USERHOME_USER_VISITS);

accountItem.addItem(USER_EVENTS, VaadinIcons.CALENDAR,
COMMAND_USERHOME_USER_EVENTS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public final class UserViews {
/**
* Default constructor for UserViews.
*/
public UserViews() {
private UserViews() {
// Default constructor
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,4 @@ public void adminSetup() throws Exception {
pageVisit.loginAsAdmin();
}

/**
* Verify view content.
*
* @param contentToVerify the content to verify
*/
protected void verifyViewContent(final String... contentToVerify) {
for (final String content : contentToVerify) {
pageVisit.verifyPageContent(content);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class AdminConfigurationTest extends AbstractAdminTest {
@Test(timeout = DEFAULT_TIMEOUT)
public void verifyPortalConfiguration() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_PORTAL);
verifyViewContent(AdminViewConstants.ADMIN_PORTAL_MANAGEMENT, AdminViewConstants.PORTAL_OVERVIEW,
pageVisit.verifyViewContent(AdminViewConstants.ADMIN_PORTAL_MANAGEMENT, AdminViewConstants.PORTAL_OVERVIEW,
AdminViewConstants.PORTAL_MANAGEMENT_OVERVIEW);
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_PORTAL);
}
Expand All @@ -36,7 +36,7 @@ public void verifyPortalConfiguration() throws Exception {
@Test(timeout = DEFAULT_TIMEOUT)
public void verifyCountryConfiguration() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_COUNTRY);
verifyViewContent(AdminViewConstants.ADMIN_COUNTRY_MANAGEMENT, AdminViewConstants.COUNTRY_OVERVIEW,
pageVisit.verifyViewContent(AdminViewConstants.ADMIN_COUNTRY_MANAGEMENT, AdminViewConstants.COUNTRY_OVERVIEW,
AdminViewConstants.COUNTRY_OVERVIEW_DESCRIPTION);
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_COUNTRY);
}
Expand All @@ -49,7 +49,7 @@ public void verifyCountryConfiguration() throws Exception {
@Test(timeout = DEFAULT_TIMEOUT)
public void verifyLanguageConfiguration() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_LANGUAGE);
verifyViewContent(AdminViewConstants.ADMIN_LANGUAGE_MANAGEMENT, AdminViewConstants.LANGUAGE_OVERVIEW,
pageVisit.verifyViewContent(AdminViewConstants.ADMIN_LANGUAGE_MANAGEMENT, AdminViewConstants.LANGUAGE_OVERVIEW,
AdminViewConstants.LANGUAGE_ADMINISTRATION);
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_LANGUAGE);
}
Expand All @@ -62,7 +62,7 @@ public void verifyLanguageConfiguration() throws Exception {
@Test(timeout = DEFAULT_TIMEOUT)
public void verifyAgencyConfiguration() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_AGENCY);
verifyViewContent(AdminViewConstants.ADMIN_AGENCY_MANAGEMENT, AdminViewConstants.AGENCY_OVERVIEW_HEADER,
pageVisit.verifyViewContent(AdminViewConstants.ADMIN_AGENCY_MANAGEMENT, AdminViewConstants.AGENCY_OVERVIEW_HEADER,
AdminViewConstants.AGENCY_OVERVIEW);
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_AGENCY);
}
Expand All @@ -75,7 +75,7 @@ public void verifyAgencyConfiguration() throws Exception {
@Test(timeout = DEFAULT_TIMEOUT)
public void verifyApplicationConfiguration() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_APPLICATION_CONFIGURATION);
verifyViewContent(AdminViewConstants.ADMIN_APPLICATION_CONFIGURATION,
pageVisit.verifyViewContent(AdminViewConstants.ADMIN_APPLICATION_CONFIGURATION,
AdminViewConstants.APPLICATION_CONFIGURATION_OVERVIEW,
AdminViewConstants.APPLICATION_CONFIGURATION_OVERVIEW);
pageVisit.selectFirstGridRow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class AdminDataTest extends AbstractAdminTest {
@Test(timeout = DEFAULT_TIMEOUT)
public void verifyDataSummary() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_DATASUMMARY);
verifyViewContent(
pageVisit.verifyViewContent(
AdminViewConstants.ADMIN_DATA_SUMMARY_OVERVIEW,
AdminViewConstants.DATA_SUMMARY_OVERVIEW
);
Expand All @@ -39,7 +39,7 @@ public void verifyDataSummary() throws Exception {
@Test(timeout = DEFAULT_TIMEOUT)
public void verifyDataSummaryAuthor() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_AUTHOR_DATASUMMARY);
verifyViewContent(
pageVisit.verifyViewContent(
AdminViewConstants.ADMIN_AUTHOR_SUMMARY,
AdminViewConstants.AUTHOR_OVERVIEW, AdminViewConstants.AUTHOR_DETAILED_SUMMARY
);
Expand All @@ -55,7 +55,7 @@ public void verifyDataSummaryAuthor() throws Exception {
@Test(timeout = DEFAULT_TIMEOUT)
public void verifyApplicationEvents() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_APPLICATION_EVENTS);
verifyViewContent(
pageVisit.verifyViewContent(
AdminViewConstants.ADMIN_APPLICATION_EVENTS, AdminViewConstants.EVENT_DETAILS,
AdminViewConstants.EVENT_REVIEW
);
Expand All @@ -70,7 +70,7 @@ public void verifyApplicationEvents() throws Exception {
@Test(timeout = DEFAULT_TIMEOUT)
public void verifyApplicationEventsCharts() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_APPLICATION_EVENTS_CHARTS);
verifyViewContent(
pageVisit.verifyViewContent(
AdminViewConstants.ADMIN_APPLICATION_EVENT_CHARTS, AdminViewConstants.EVENT_ANALYSIS_HEADER, AdminViewConstants.EVENT_ANALYSIS
);
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_APPLICATION_EVENTS_CHARTS);
Expand All @@ -84,13 +84,13 @@ public void verifyApplicationEventsCharts() throws Exception {
@Test(timeout = DEFAULT_TIMEOUT)
public void verifyApplicationSessions() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_APPLICATION_SESSION);
verifyViewContent(
pageVisit.verifyViewContent(
AdminViewConstants.ADMIN_APPLICATION_SESSIONS,
AdminViewConstants.SESSION_DETAILS,
AdminViewConstants.SESSION_OVERVIEW
);
pageVisit.selectFirstGridRow();
verifyViewContent(
pageVisit.verifyViewContent(
AdminViewConstants.APPLICATION_SESSION_DETAILS,
AdminViewConstants.SESSION_TYPE,
AdminViewConstants.USER_ID,
Expand All @@ -107,7 +107,7 @@ public void verifyApplicationSessions() throws Exception {
@Test(timeout = DEFAULT_TIMEOUT)
public void verifySessionCharts() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_APPLICATION_SESSION_CHARTS);
verifyViewContent(
pageVisit.verifyViewContent(
AdminViewConstants.ADMIN_APPLICATION_SESSION_CHARTS,
AdminViewConstants.SESSION_ANALYSIS
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class AdminOperationsTest extends AbstractAdminTest {
@Test(timeout = DEFAULT_TIMEOUT)
public void verifyAgentOperation() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_AGENT_OPERATION);
verifyViewContent(
pageVisit.verifyViewContent(
AdminViewConstants.ADMIN_AGENT_OPERATION_OVERVIEW,
AdminViewConstants.ADMIN_AGENT_OPERATION,
AdminViewConstants.ADMIN_AGENT_OPERATION_TASKS_OVERVIEW
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class AdminSecurityTest extends AbstractAdminTest {
@Test(timeout = DEFAULT_TIMEOUT)
public void verifyUserAccount() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_USERACCOUNT);
verifyViewContent(AdminViewConstants.ADMIN_USER_ACCOUNT_MANAGEMENT, AdminViewConstants.USER_ACCOUNT_OVERVIEW,
pageVisit.verifyViewContent(AdminViewConstants.ADMIN_USER_ACCOUNT_MANAGEMENT, AdminViewConstants.USER_ACCOUNT_OVERVIEW,
AdminViewConstants.USER_ACCOUNT_MANAGEMENT_DESCRIPTION);
pageVisit.selectFirstGridRow();
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_USERACCOUNT);
Expand All @@ -37,7 +37,7 @@ public void verifyUserAccount() throws Exception {
@Test(timeout = DEFAULT_TIMEOUT)
public void verifySessionAccess() throws Exception {
pageVisit.visitDirectPage(PageCommandAdminConstants.COMMAND_APPLICATION_SESSION);
verifyViewContent(AdminViewConstants.ADMIN_APPLICATION_SESSIONS, AdminViewConstants.SESSION_DETAILS,
pageVisit.verifyViewContent(AdminViewConstants.ADMIN_APPLICATION_SESSIONS, AdminViewConstants.SESSION_DETAILS,
AdminViewConstants.SESSION_OVERVIEW);
pageVisit.selectFirstGridRow();
pageVisit.validatePage(PageCommandAdminConstants.COMMAND_APPLICATION_SESSION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,18 @@ public void visitDirectPage(final PageModeMenuCommand page) {
assertNotNull(driver.getWindowHandle());
}

/**
* Verify view content.
*
* @param contentToVerify the content to verify
*/
public void verifyViewContent(final String... contentToVerify) {
for (final String content : contentToVerify) {
verifyPageContent(content);
}
}


/**
* Visit main view.
*/
Expand Down
Loading

0 comments on commit d5b1561

Please sign in to comment.