This is an automated email from the ASF dual-hosted git repository. robbie pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/artemis.git
commit 06d7083a008919e435e5d0fbbd800e726f8c3b19 Author: Domenico Francesco Bruscino <[email protected]> AuthorDate: Tue Mar 10 19:35:22 2026 +0100 ARTEMIS-5910 Fix TabsTest visibility validations Use the same locator to validate negative and positive visibility validations. --- .../artemis/tests/smoke/console/TabsTest.java | 114 ++++++++------------- 1 file changed, 43 insertions(+), 71 deletions(-) diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/TabsTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/TabsTest.java index 14f52c5370..87ff4ca404 100644 --- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/TabsTest.java +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/TabsTest.java @@ -16,103 +16,75 @@ */ package org.apache.activemq.artemis.tests.smoke.console; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension; import org.apache.activemq.artemis.tests.smoke.console.pages.LoginPage; +import org.apache.activemq.artemis.tests.smoke.console.pages.StatusPage; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.openqa.selenium.By; import org.openqa.selenium.NoSuchElementException; +import java.util.Collections; +import java.util.Set; + //Parameters set in super class @ExtendWith(ParameterizedTestExtension.class) public class TabsTest extends ArtemisTest { - public TabsTest(String browser, String serverName) { - super(browser, serverName); - } - - @TestTemplate - public void testConnectionsTab() { - testTab("connections", "Connections"); - } - - @TestTemplate - public void testSessionsTab() { - testTab("sessions", "Sessions"); - } - - @TestTemplate - public void testConsumersTab() { - testTab("consumers", "Consumers"); - } - - @TestTemplate - public void testProducersTab() { - testTab("producers", "Producers"); - } - - @TestTemplate - public void testAddressesTab() { - testTab("addresses", "Addresses"); - } + private final String TAB_CONNECTIONS = "Connections"; - @TestTemplate - public void testQueuesTab() { - testTab("queues", "Queues"); - } + private final String TAB_SESSIONS = "Sessions"; - private void testTab(String userpass, String tab) { - loadLandingPage(); - new LoginPage(driver).loginValidUser(userpass, userpass, DEFAULT_TIMEOUT); - driver.findElement(By.xpath("//button/span[contains(text(),'" + tab + "')]")); - } + private final String TAB_CONSUMERS = "Consumers"; - @TestTemplate - public void testConnectionsTabNegative() { - // use credentials for a valid user who cannot see the tab - testTabNegative("queues", "Connections"); - } + private final String TAB_PRODUCERS = "Producers"; - @TestTemplate - public void testSessionsTabNegative() { - // use credentials for a valid user who cannot see the tab - testTabNegative("connections", "Sessions"); - } + private final String TAB_ADDRESSES = "Addresses"; - @TestTemplate - public void testConsumersTabNegative() { - // use credentials for a valid user who cannot see the tab - testTabNegative("connections", "Consumers"); - } + private final String TAB_QUEUES = "Queues"; - @TestTemplate - public void testProducersTabNegative() { - // use credentials for a valid user who cannot see the tab - testTabNegative("connections", "roducers"); - } + private final String[] TABS = new String[]{TAB_CONNECTIONS, TAB_SESSIONS, TAB_CONSUMERS, TAB_PRODUCERS, TAB_ADDRESSES, TAB_QUEUES}; - @TestTemplate - public void testAddressesTabNegative() { - // use credentials for a valid user who cannot see the tab - testTabNegative("connections", "Addresses"); + public TabsTest(String browser, String serverName) { + super(browser, serverName); } @TestTemplate - public void testQueuesTabNegative() { - // use credentials for a valid user who cannot see the tab - testTabNegative("connections", "Queues"); + public void testVisibleTabs() { + testTabs(SERVER_ADMIN_USERNAME, false, Set.of(TABS)); + testTabs("connections", true, Collections.singleton(TAB_CONNECTIONS)); + testTabs("sessions", true, Collections.singleton(TAB_SESSIONS)); + testTabs("consumers", true, Collections.singleton(TAB_CONSUMERS)); + testTabs("producers", true, Collections.singleton(TAB_PRODUCERS)); + testTabs("addresses", true, Collections.singleton(TAB_ADDRESSES)); + testTabs("queues", true, Collections.singleton(TAB_QUEUES)); } - private void testTabNegative(String userpass, String tab) { + private void testTabs(String userpass, boolean isAlertExpected, Set<String> visibleTabs) { loadLandingPage(); - new LoginPage(driver).loginValidUser(userpass, userpass, DEFAULT_TIMEOUT); - try { - driver.findElement(By.xpath("//a[contains(text(),'" + tab + "')]")); - fail("User " + userpass + " should not have been able to see the " + tab + " tab."); - } catch (NoSuchElementException e) { - // expected + + StatusPage statusPage = new LoginPage(driver).loginValidUser(userpass, userpass, DEFAULT_TIMEOUT); + + assertEquals(isAlertExpected, statusPage.countAlerts() > 0); + statusPage.closeAlerts(); + + for (String tab : TABS) { + By tabLocator = By.xpath("//button/span[contains(text(),'" + tab + "')]"); + if (visibleTabs.contains(tab)) { + driver.findElement(tabLocator); + } else { + try { + driver.findElement(tabLocator); + fail("User " + userpass + " should not have been able to see the " + tab + " tab."); + } catch (Exception e) { + assertEquals(NoSuchElementException.class, e.getClass()); + } + } } + + statusPage.logout(DEFAULT_TIMEOUT); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
