Class UiTestIdSupport

java.lang.Object
io.jmix.flowui.sys.UiTestIdSupport

@Component("flowui_UiTestIdSupport") public class UiTestIdSupport extends Object
Support class for calculating and setting a special static ID attribute for testing.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    protected UiTestIdManager
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    addFragmentIdPrefix(com.vaadin.flow.component.Component component, String id)
    Adds the prefix of its parent Fragment to the component's ID.
    void
    addTestIdListener(com.vaadin.flow.component.Component component)
    Adds a listener to add a special static ID attribute for testing as a UI_TEST_ID attribute of the component.
    protected String
    getMenuDetailsTestId(com.vaadin.flow.component.details.Details details)
    Gets a special static ID attribute for testing for a Details component in the menu.
    protected void
    setMenuTestId(com.vaadin.flow.component.Component component)
    Sets a special static ID attribute for testing for the JmixListMenu and HorizontalMenu components and for their nested components (like a Details, ListItem etc.).
    protected void
    setTestId(com.vaadin.flow.component.Component component)
    Sets a special static ID attribute for testing for passed component.
    protected void
    setTestId(com.vaadin.flow.component.Component component, String testId)
    Sets passed UI test ID for the passed UI component as a UI_TEST_ID web-element attribute.
    protected void
    testIdListener(com.vaadin.flow.component.AttachEvent attachEvent)
    Attach event listener for components that adds a special static ID attribute for testing.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • UiTestIdSupport

      public UiTestIdSupport(UiTestIdManager uiTestIdManager)
  • Method Details

    • addTestIdListener

      public void addTestIdListener(com.vaadin.flow.component.Component component)
      Adds a listener to add a special static ID attribute for testing as a UI_TEST_ID attribute of the component.

      Typically it equals to Component.getId(), but in certain cases it can be calculated from the component state.

      Parameters:
      component - component for adding UI_TEST_ID attribute
    • testIdListener

      protected void testIdListener(com.vaadin.flow.component.AttachEvent attachEvent)
      Attach event listener for components that adds a special static ID attribute for testing.
      Parameters:
      attachEvent - attach event
    • setMenuTestId

      protected void setMenuTestId(com.vaadin.flow.component.Component component)
      Sets a special static ID attribute for testing for the JmixListMenu and HorizontalMenu components and for their nested components (like a Details, ListItem etc.).
      Parameters:
      component - menu component
    • getMenuDetailsTestId

      protected String getMenuDetailsTestId(com.vaadin.flow.component.details.Details details)
      Gets a special static ID attribute for testing for a Details component in the menu. ID is calculated based on Details.getSummaryText() or the summary component.
      Parameters:
      details - Details component to calculate UI test ID
      Returns:
      special static ID attribute for a Details component in the menu
    • setTestId

      protected void setTestId(com.vaadin.flow.component.Component component)
      Sets a special static ID attribute for testing for passed component.

      Typically it equals to Component.getId(), but in certain cases it can be calculated from the component state.

      If UI test ID already exist, nothing will happen.

      Parameters:
      component - component for calculating and setting UI test ID
    • addFragmentIdPrefix

      protected String addFragmentIdPrefix(com.vaadin.flow.component.Component component, String id)
      Adds the prefix of its parent Fragment to the component's ID.
      Parameters:
      component - component to find parent Fragment
      id - component ID
      Returns:
      component ID with the prefix of its parent Fragment if the fragment has an ID, the component ID otherwise
    • setTestId

      protected void setTestId(com.vaadin.flow.component.Component component, @Nullable String testId)
      Sets passed UI test ID for the passed UI component as a UI_TEST_ID web-element attribute.
      Parameters:
      component - component for setting UI test ID
      testId - UI test ID for setting