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 Details

  • Constructor Details

  • 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 the native UI_TEST_ID attribute is already assigned, it is kept as is and only mirrored to the legacy J_TEST_ID attribute when legacy test IDs are enabled.

      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
    • setLegacyTestId

      protected void setLegacyTestId(com.vaadin.flow.component.Component component, String testId)
      Mirrors the passed test ID to the legacy J_TEST_ID attribute if legacy test IDs are enabled.
      Parameters:
      component - component to set the legacy test ID attribute for
      testId - test ID to set