[playwright] table, switch, slider, title#105
Merged
Conversation
Reviewer's GuideThis PR refactors PatternFly widget components and the CI workflow to adopt Playwright-native interactions, normalize locator syntax, update element-handling methods, and streamline test ignore patterns in the GitHub Actions configuration. Sequence diagram for Playwright-native Switch interactionsequenceDiagram
participant Test
participant Switch
participant Browser
Test->>Switch: fill(value)
Switch->>Browser: element(CHECKBOX_LOCATOR)
alt value == True
Browser->>Browser: check(force=True)
else value == False
Browser->>Browser: uncheck(force=True)
end
Sequence diagram for Playwright-native Slider fill interactionsequenceDiagram
participant Test
participant Slider
participant Browser
Test->>Slider: fill(value)
Slider->>Browser: element(INPUT)
Browser->>Browser: press("Control+A")
Browser->>Browser: fill(str(value))
Browser->>Browser: press("Enter")
Sequence diagram for Playwright-native Table column expansionsequenceDiagram
participant Test
participant ExpandableColumn
participant Browser
Test->>ExpandableColumn: expand()
ExpandableColumn->>Browser: element(EXPAND_LOCATOR)
Browser->>Browser: click(button)
Class diagram for updated Switch, Slider, Title, and Table componentsclassDiagram
class BaseSwitch {
+CHECKBOX_LOCATOR: str
+PF_5_LABEL_ON: str
+PF_5_LABEL_OFF: str
+PF_6_LABLE: str
+is_enabled
+click()
+selected
+fill(value)
}
class BaseSlider {
+THUMB: str
+STEPS: str
+_str_num(value)
+fill(value)
+read()
}
class BaseTitle {
+heading_level
+text
+read()
}
class ExpandableColumn {
+EXPAND_LOCATOR: str
+__init__()
}
BaseExpandableTable <|-- ExpandableTable
PatternflyTable <|-- ExpandableTable
TableColumn <|-- ExpandableColumn
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- There's a typo in the constant PF_6_LABLE – renaming it to PF_6_LABEL will prevent confusion downstream.
- With the CI workflow now running all component tests, double-check that existing tests are updated to match the new switch/slider APIs to avoid unexpected breakage.
- To keep interactions consistent and reduce flakiness, consider using browser.check/browser.uncheck instead of force‐clicks across components when possible.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- There's a typo in the constant PF_6_LABLE – renaming it to PF_6_LABEL will prevent confusion downstream.
- With the CI workflow now running all component tests, double-check that existing tests are updated to match the new switch/slider APIs to avoid unexpected breakage.
- To keep interactions consistent and reduce flakiness, consider using browser.check/browser.uncheck instead of force‐clicks across components when possible.
## Individual Comments
### Comment 1
<location> `src/widgetastic_patternfly5/components/switch.py:18` </location>
<code_context>
+ CHECKBOX_LOCATOR = ".//input"
+ PF_5_LABEL_ON = ".//span[contains(@class, 'pf-m-on')]"
+ PF_5_LABEL_OFF = ".//span[contains(@class, 'pf-m-off')]"
+ PF_6_LABLE = ".//span[contains(@class, '-c-switch__label')]"
@property
</code_context>
<issue_to_address>
**suggestion (typo):** Typo in constant name: PF_6_LABLE should be PF_6_LABEL.
Please update the constant name to PF_6_LABEL.
```suggestion
PF_6_LABEL = ".//span[contains(@class, '-c-switch__label')]"
```
</issue_to_address>
### Comment 2
<location> `src/widgetastic_patternfly5/components/switch.py:29-31` </location>
<code_context>
def click(self):
"""Click on a Switch."""
if not self.is_enabled:
raise SwitchDisabled(f"{repr(self)} is disabled")
else:
self.browser.check(self.CHECKBOX_LOCATOR)
return True
</code_context>
<issue_to_address>
**suggestion (code-quality):** We've found these issues:
- Swap if/else branches [×2] ([`swap-if-else-branches`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/swap-if-else-branches/))
- Remove unnecessary else after guard condition ([`remove-unnecessary-else`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/remove-unnecessary-else/))
```suggestion
self.browser.check(self.CHECKBOX_LOCATOR)
return True
```
</issue_to_address>
### Comment 3
<location> `src/widgetastic_patternfly5/components/switch.py:42-50` </location>
<code_context>
def fill(self, value):
"""Fills a Switch with the supplied value."""
if not self.is_enabled:
raise SwitchDisabled(f"{repr(self)} is disabled")
if bool(value) == self.selected:
return False
else:
el = self.browser.element(self.CHECKBOX_LOCATOR)
if value == True:
el.check(force=True)
else:
el.uncheck(force=True)
return True
</code_context>
<issue_to_address>
**issue (code-quality):** Remove unnecessary else after guard condition ([`remove-unnecessary-else`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/remove-unnecessary-else/))
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
mshriver
reviewed
Oct 17, 2025
mshriver
reviewed
Oct 17, 2025
mshriver
reviewed
Oct 17, 2025
mshriver
approved these changes
Oct 17, 2025
afa3871
into
RedHatQE:feature-playwright
9 of 11 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Refine Playwright-based widget behaviors by updating XPath locators, switching to built-in check/uncheck methods, improving keyboard interactions, simplifying element access, and re-enabling component tests in CI.
Enhancements: