Class DashboardTester<T extends Dashboard>

java.lang.Object
com.vaadin.browserless.ComponentTester<T>
com.vaadin.flow.component.dashboard.DashboardTester<T>
Type Parameters:
T - the dashboard type
All Implemented Interfaces:
Clickable<T>

public class DashboardTester<T extends Dashboard> extends ComponentTester<T>
Tester for the Dashboard component.

Simulates the interactions a user performs on an editable dashboard: reordering, resizing and removing widgets. Each method fires the same client-side event the web component sends, so the dashboard updates its server-side model and notifies any registered listeners exactly as it would in a browser. All three actions require the dashboard to be editable (Dashboard.setEditable(boolean)), mirroring the component: a user cannot move, resize or remove widgets otherwise.

Since:
1.1
  • Constructor Details

    • DashboardTester

      public DashboardTester(T component)
      Wrap given component for testing.
      Parameters:
      component - target component
  • Method Details

    • moveWidget

      public void moveWidget(DashboardWidget widget, int toIndex)
      Simulates a user dragging the given widget to a new position within its current container (the dashboard root, or the section it belongs to).
      Parameters:
      widget - the widget to move, not null
      toIndex - the target index among the widget's siblings
      Throws:
      IllegalStateException - if the dashboard is not editable
      IllegalArgumentException - if the widget is not in this dashboard or the target index is out of bounds
    • resizeWidget

      public void resizeWidget(DashboardWidget widget, int colspan, int rowspan)
      Simulates a user resizing the given widget to the given column and row span.
      Parameters:
      widget - the widget to resize, not null
      colspan - the new column span
      rowspan - the new row span
      Throws:
      IllegalStateException - if the dashboard is not editable
      IllegalArgumentException - if the widget is not in this dashboard
    • removeWidget

      public void removeWidget(DashboardWidget widget)
      Simulates a user removing the given widget by clicking its remove button.

      If the dashboard has a custom remove handler, it receives the event and decides whether to remove the widget; otherwise the widget is removed immediately.

      Parameters:
      widget - the widget to remove, not null
      Throws:
      IllegalStateException - if the dashboard is not editable
      IllegalArgumentException - if the widget is not in this dashboard