com.vaadin.flow.component.sidenav.

Class SideNavTester<T extends SideNav>

java.lang.Object
com.vaadin.testbench.unit.ComponentTester<T>
com.vaadin.flow.component.sidenav.SideNavTester<T>
public class SideNavTester<T extends SideNav> extends ComponentTester<T>
  • Constructor Details

    • SideNavTester

      public SideNavTester(T component)

      Wrap given component for testing.

      Parameters:

      component - target component

  • Method Details

    • clickItem

      public void clickItem(String topLevelLabel, String... nestedItemLabels)

      Simulates a click on the item that matches the given label. For nested navigation item provide the label of each item in the hierarchy. The path to the navigation item must reflect what is seen in the browser, meaning that hidden items are ignored. For the same reason, items inside collapsed nodes cannot be clicked and an exception is thrown. Use expandAndClickItem(String, String...) to expand intermediate node and click on the desired item.

       
      
       sideNav.addItem(new SideNavItem("Home", HomeView.class));
       SideNavItem childNav = new SideNavItem("Messages");
       childNav.addItem(new SideNavItem("Inbox", InboxView.class));
       childNav.addItem(new SideNavItem("Sent", SentView.class));
       sideNav.addItem(childNav);
      
       // clicks top level navigation item with label Home
       tester.clickItem("Home");
      
       // clicks nested navigation item with label Sent
       wrapper.clickItem("Messages", "Sent");
       
       

      Parameters:

      topLevelLabel - the text content of the top level SideNav item label, not null.

      nestedItemLabels - labels of the nested SideNav items

      Throws:

      IllegalArgumentException - if the provided text does not identify a SideNav item.

      IllegalStateException - if the item at given path is not usable.

      See Also:

    • expandAndClickItem

      public void expandAndClickItem(String topLevelLabel, String... nestedItemLabels)

      Simulates a click on the item that matches the given label, expanding potential parent collapsed nodes. For nested navigation item provide the label of each item in the hierarchy. The path to the navigation item must reflect what is seen in the browser, meaning that hidden items are ignored. For the same reason, items inside collapsed nodes cannot be clicked and an exception is thrown.

       
      
       sideNav.addItem(new SideNavItem("Home", HomeView.class));
       SideNavItem childNav = new SideNavItem("Messages");
       childNav.addItem(new SideNavItem("Inbox", InboxView.class));
       childNav.addItem(new SideNavItem("Sent", SentView.class));
       sideNav.addItem(childNav);
      
       // clicks nested navigation item with label Sent
       wrapper.expandAndClickItem("Messages", "Sent");
       
       

      Parameters:

      topLevelLabel - the text content of the top level SideNav item label, not null.

      nestedItemLabels - labels of the nested SideNav items

      Throws:

      IllegalArgumentException - if the provided text does not identify a SideNav item.

      IllegalStateException - if the item at given path is not usable.

      See Also:

    • click

      public void click()

      Simulates a click on the SideNav label, expanding or collapsing item list.

      Throws:

      IllegalStateException - if the SideNav component is not collapsible or not usable.

      See Also:

    • toggleItem

      public void toggleItem(String topLevelLabel, String... nestedItemLabels)

      Simulates a click on the item that matches the given label. For nested navigation item provide the label of each item in the hierarchy. The path to the navigation item must reflect what is seen in the browser, meaning that hidden items are ignored. For the same reason, items inside collapsed nodes cannot be clicked and an exception is thrown. Use expandAndClickItem(String, String...) to expand intermediate node and click on the desired item.

       
      
       sideNav.addItem(new SideNavItem("Home", HomeView.class));
       SideNavItem childNav = new SideNavItem("Messages");
       childNav.addItem(new SideNavItem("Inbox", InboxView.class));
       childNav.addItem(new SideNavItem("Sent", SentView.class));
       sideNav.addItem(childNav);
      
       // clicks top level navigation item with label Home
       tester.clickItem("Home");
      
       // clicks nested navigation item with label Sent
       wrapper.clickItem("Messages", "Sent");
       
       

      Parameters:

      topLevelLabel - the text content of the top level SideNav item label, not null.

      nestedItemLabels - labels of the nested SideNav items

      Throws:

      IllegalArgumentException - if the provided text does not identify a SideNav item.

      IllegalStateException - if the item at given path is not usable.

      See Also:

    • toggle

      public void toggle()

      Simulates a click on the SideNav toggle button, expanding or collapsing item list.

      Throws:

      IllegalStateException - if the SideNav component is not collapsible or not usable.

      See Also: