Skip to content

Commit

Permalink
Merge pull request #225 from ikerreyes/ouia-default-component-id
Browse files Browse the repository at this point in the history
Set default component_id to "" for OUIA base components
  • Loading branch information
Dmitrii Misharov authored Jul 20, 2022
2 parents 69ae078 + 8012bcf commit c40d7f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/widgetastic/ouia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class OUIABase:
def _set_attrs(
self,
component_type: str,
component_id: Optional[str] = None,
component_id: str = "",
) -> None:
self.component_type = quote(component_type)
self.component_id = quote(component_id)
Expand Down Expand Up @@ -104,7 +104,7 @@ class OUIAGenericWidget(OUIABase, Widget, ClickableMixin):
def __init__(
self,
parent: ViewParent,
component_id: Optional[str] = None,
component_id: str = "",
logger: Optional[Logger] = None,
component_type: Optional[str] = None,
) -> None:
Expand Down
10 changes: 10 additions & 0 deletions testing/test_ouia.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,13 @@ def test_safety(testing_view):
def test_select(testing_view):
testing_view.select.choose("first_option")
testing_view.select.choose("second_option")


def test_widget_without_id(browser):
class TestView(OUIAGenericView):
OUIA_COMPONENT_TYPE = "TestView"
button = Button()

view = TestView(browser)
assert view.is_displayed
assert view.button.locator == './/*[@data-ouia-component-type="PF/Button"]'

0 comments on commit c40d7f5

Please sign in to comment.