-
Notifications
You must be signed in to change notification settings - Fork 21
Updates for PF6 unit tests #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,12 +41,27 @@ class Radio(BaseRadio, View): | |
|
|
||
| @property | ||
| def selected(self): | ||
| return self.radio.selected | ||
| return self.browser.is_checked(self.RADIO_LOC) | ||
|
|
||
| @property | ||
| def disabled(self): | ||
| return "pf-m-disabled" in self.browser.classes(self.label) | ||
|
|
||
| def fill(self, values): | ||
| """Can only handle `True` to check the radio, nature of individual radio button""" | ||
| return self.radio.fill(values) | ||
| if values == self.selected: | ||
| return False | ||
| if values: | ||
|
Comment on lines
50
to
+54
Comment on lines
50
to
+54
|
||
| el = self.browser.element(self.RADIO_LOC) | ||
| el.evaluate( | ||
| "e => {" | ||
| " const nativeSetter = Object.getOwnPropertyDescriptor(" | ||
| " window.HTMLInputElement.prototype, 'checked'" | ||
| " ).set;" | ||
| " nativeSetter.call(e, true);" | ||
|
Comment on lines
+52
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): Clarify behavior when With the current logic, calling Consider either treating |
||
| " e.dispatchEvent(new Event('click', {bubbles: true}));" | ||
| " e.dispatchEvent(new Event('input', {bubbles: true}));" | ||
| " e.dispatchEvent(new Event('change', {bubbles: true}));" | ||
| "}" | ||
| ) | ||
| return True | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| from wait_for import wait_for as _wait_for | ||
| from widgetastic.exceptions import NoSuchElementException | ||
| from widgetastic.widget import TextInput | ||
|
|
||
|
|
@@ -220,7 +221,15 @@ def fill(self, value, create_item=False): | |
|
|
||
| if create_item and value not in self.items: | ||
| self.input.fill(value) | ||
| self.root_browser.click(self.CREATE_ITEM_LOCATOR) | ||
| _id_attr = self.CREATE_ITEM_LOCATOR.split("@id='")[1].rstrip("']") | ||
| create_css = "#" + _id_attr | ||
| page = self.browser.element(".").page | ||
|
Comment on lines
+224
to
+226
|
||
| _wait_for( | ||
| lambda: page.locator(create_css).count() > 0, | ||
| timeout=10, | ||
| delay=0.2, | ||
| ) | ||
| page.locator(create_css).click() | ||
|
Comment on lines
+224
to
+232
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (bug_risk): Avoid brittle string parsing of This assumes Instead, either:
That avoids coupling this code to a specific string representation of the locator. |
||
| return True | ||
| else: | ||
| self.item_select(value) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Use the class attribute for
CATEGORY_CLOSEand leverage the existingclose_buttonwidget.CATEGORY_CLOSEis not defined in this scope and should be referenced as the class attribute (e.g.self.CATEGORY_CLOSE), otherwise this will raise aNameError.Also, the previous version used
self.close_button, which likely wraps the correct locator and behavior. To stay consistent with the existing API and avoid regressions, consider either:close_el = self.browser.element(self.CATEGORY_CLOSE), orself.close_button.dispatch_event("click")to reuse the widget abstraction.