Skip to content

[playwright] table, switch, slider, title#105

Merged
digitronik merged 1 commit into
RedHatQE:feature-playwrightfrom
digitronik:table_pw
Oct 17, 2025
Merged

[playwright] table, switch, slider, title#105
digitronik merged 1 commit into
RedHatQE:feature-playwrightfrom
digitronik:table_pw

Conversation

@digitronik

@digitronik digitronik commented Oct 17, 2025

Copy link
Copy Markdown
Member

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:

  • Standardize XPath locators to use descendant axis for switch, table expand button, and slider steps
  • Switch component now uses Playwright’s check/uncheck and is_checked methods for more reliable toggling
  • Slider component uses force click on drag targets and replaces send_keys with press and fill for input fields
  • Title component simplifies tag and text retrieval by calling browser methods directly without parent parameter
  • CI workflow test command no longer excludes individual component tests to ensure full coverage

@sourcery-ai

sourcery-ai Bot commented Oct 17, 2025

Copy link
Copy Markdown

Reviewer's Guide

This 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 interaction

sequenceDiagram
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
Loading

Sequence diagram for Playwright-native Slider fill interaction

sequenceDiagram
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")
Loading

Sequence diagram for Playwright-native Table column expansion

sequenceDiagram
participant Test
participant ExpandableColumn
participant Browser
Test->>ExpandableColumn: expand()
ExpandableColumn->>Browser: element(EXPAND_LOCATOR)
Browser->>Browser: click(button)
Loading

Class diagram for updated Switch, Slider, Title, and Table components

classDiagram
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
Loading

File-Level Changes

Change Details Files
Modernize Switch component interactions
  • Normalized locators to use ".//" prefix
  • Replaced browser.click() with browser.check()
  • Updated selected property to use browser.is_checked()
  • Implemented element().check()/uncheck() with force in fill()
src/widgetastic_patternfly5/components/switch.py
Improve Slider component behavior
  • Adjusted step locator class from '-step' to '-step-tick'
  • Added force flag to click() on target element
  • Replaced send_keys sequence with press()/fill()/press() calls
src/widgetastic_patternfly5/components/slider.py
Simplify Title component API
  • Replaced browser.element().tag_name with browser.tag()
  • Changed text retrieval to browser.text(self)
src/widgetastic_patternfly5/components/title.py
Correct ExpandableColumn locator
  • Prefixed EXPAND_LOCATOR with ".//" for consistent XPath
src/widgetastic_patternfly5/components/table.py
Streamline CI test ignores
  • Removed multiple explicit --ignore flags for component tests
  • Consolidated ignore to a single testing/ouia pattern
.github/workflows/tests.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/widgetastic_patternfly5/components/switch.py Outdated
Comment thread src/widgetastic_patternfly5/components/switch.py Outdated
Comment thread src/widgetastic_patternfly5/components/switch.py Outdated
@digitronik digitronik changed the title [playwright] table, switch, slider, title [WIP][playwright] table, switch, slider, title Oct 17, 2025
@digitronik digitronik changed the title [WIP][playwright] table, switch, slider, title [playwright] table, switch, slider, title Oct 17, 2025
@digitronik digitronik requested a review from mshriver October 17, 2025 11:00
Comment thread .github/workflows/tests.yaml
Comment thread src/widgetastic_patternfly5/components/slider.py
Comment thread src/widgetastic_patternfly5/components/switch.py Outdated
@digitronik digitronik merged commit afa3871 into RedHatQE:feature-playwright Oct 17, 2025
9 of 11 checks passed
@digitronik digitronik deleted the table_pw branch October 17, 2025 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants