Package io.jmix.flowui.sys
Class UiTestIdSupport
java.lang.Object
io.jmix.flowui.sys.UiTestIdSupport
Support class for calculating and setting a special static ID attribute for testing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringstatic final Stringprotected UiPropertiesprotected UiTestIdManager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringaddFragmentIdPrefix(com.vaadin.flow.component.Component component, String id) Adds the prefix of its parentFragmentto the component's ID.voidaddTestIdListener(com.vaadin.flow.component.Component component) Adds a listener to add a special static ID attribute for testing as aUI_TEST_IDattribute of the component.protected StringgetMenuDetailsTestId(com.vaadin.flow.component.details.Details details) Gets a special static ID attribute for testing for aDetailscomponent in the menu.protected voidsetLegacyTestId(com.vaadin.flow.component.Component component, String testId) Mirrors the passed test ID to the legacyJ_TEST_IDattribute iflegacy test IDsare enabled.protected voidsetMenuTestId(com.vaadin.flow.component.Component component) Sets a special static ID attribute for testing for theJmixListMenuandHorizontalMenucomponents and for their nested components (like aDetails,ListItemetc.).protected voidsetTestId(com.vaadin.flow.component.Component component) Sets a special static ID attribute for testing for passed component.protected voidSets passed UI test ID for the passed UI component as aUI_TEST_IDweb-element attribute.protected voidtestIdListener(com.vaadin.flow.component.AttachEvent attachEvent) Attach event listener for components that adds a special static ID attribute for testing.
-
Field Details
-
UI_TEST_ID
- See Also:
-
J_TEST_ID
- See Also:
-
uiTestIdManager
-
uiProperties
-
-
Constructor Details
-
UiTestIdSupport
-
-
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 aUI_TEST_IDattribute 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 addingUI_TEST_IDattribute
-
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 theJmixListMenuandHorizontalMenucomponents and for their nested components (like aDetails,ListItemetc.).- Parameters:
component- menu component
-
getMenuDetailsTestId
Gets a special static ID attribute for testing for aDetailscomponent in the menu. ID is calculated based onDetails.getSummaryText()or the summary component.- Parameters:
details-Detailscomponent to calculate UI test ID- Returns:
- special static ID attribute for a
Detailscomponent 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_IDattribute is already assigned, it is kept as is and only mirrored to the legacyJ_TEST_IDattribute whenlegacy test IDsare enabled.- Parameters:
component- component for calculating and setting UI test ID
-
addFragmentIdPrefix
Adds the prefix of its parentFragmentto the component's ID. -
setTestId
Sets passed UI test ID for the passed UI component as aUI_TEST_IDweb-element attribute.- Parameters:
component- component for setting UI test IDtestId- UI test ID for setting
-
setLegacyTestId
Mirrors the passed test ID to the legacyJ_TEST_IDattribute iflegacy test IDsare enabled.- Parameters:
component- component to set the legacy test ID attribute fortestId- test ID to set
-