Skip to content

[playwright] Menu widgets migration#102

Merged
mshriver merged 1 commit into
RedHatQE:feature-playwrightfrom
digitronik:menu_migration
Oct 16, 2025
Merged

[playwright] Menu widgets migration#102
mshriver merged 1 commit into
RedHatQE:feature-playwrightfrom
digitronik:menu_migration

Conversation

@digitronik

@digitronik digitronik commented Oct 15, 2025

Copy link
Copy Markdown
Member
  • Some fixes
  • Cleanup as I like to avoid opening specific widget url.

Summary by Sourcery

Refactor menu widget tests to use a unified module-scoped view fixture, update widget APIs for more reliable element handling and selection state, and adjust test component paths.

Bug Fixes:

  • Switch selection state checks from is_selected() to is_checked() in menu and select components

Enhancements:

  • Consolidate select, checkbox_select, and typeahead_select fixtures into a single module-scoped view fixture and remove manual URL switching
  • Replace browser.wait_for_element with browser.element in dropdown.open
  • Update TESTING_PAGE_COMPONENT path in group dropdown tests

Tests:

  • Refactor test_select.py fixtures for improved reuse

@digitronik digitronik requested a review from mshriver October 16, 2025 07:32
@mshriver

Copy link
Copy Markdown
Collaborator

@sourcery-ai review

@sourcery-ai

sourcery-ai Bot commented Oct 16, 2025

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Migrates menu widget tests to a unified module-level view fixture eliminating manual URL changes, refactors Widgetastic PatternFly5 components to use browser.element and is_checked(), and simplifies the test_group_dropdown component path.

Class diagram for updated browser element usage in menu widgets

classDiagram
    class Browser {
        +element(locator, parent)
        +click(element)
    }
    class Dropdown {
        +open()
        BUTTON_LOCATOR
        browser : Browser
    }
    class Menu {
        +read()
        browser : Browser
    }
    class Select {
        +read()
        browser : Browser
    }
    Dropdown --> Browser
    Menu --> Browser
    Select --> Browser
Loading

Class diagram for updated input selection logic in Menu and Select

classDiagram
    class Menu {
        +read()
    }
    class Select {
        +read()
    }
    class Input {
        +is_checked()
    }
    Menu --> Input : uses is_checked()
    Select --> Input : uses is_checked()
Loading

File-Level Changes

Change Details Files
Refactored pytest fixtures for select widgets into a shared view fixture
  • added module-scoped view fixture encapsulating all select variants
  • removed manual browser.url manipulation in individual fixtures
  • redefined select, checkbox_select, typeahead_select to yield view attributes
  • updated fixture names and scopes
testing/components/menus/test_select.py
Replaced wait_for_element with element API in Dropdown component
  • removed wait_for_element usage
  • used browser.element to locate the dropdown toggle
src/widgetastic_patternfly5/components/menus/dropdown.py
Swapped is_selected with is_checked for input state in Menu and Select components
  • replaced is_selected() calls with is_checked() in menu.read
  • replaced is_selected() calls with is_checked() in select.read
src/widgetastic_patternfly5/components/menus/menu.py
src/widgetastic_patternfly5/components/menus/select.py
Adjusted TESTING_PAGE_COMPONENT path for GroupDropdown tests
  • simplified TESTING_PAGE_COMPONENT to a generic dropdown endpoint
testing/components/menus/test_group_dropdown.py

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:

  • The new view fixture no longer navigates to specific sub-URLs for each select variant—ensure your test harness still loads the correct “single”, “checkbox”, and “typeahead” pages or reintroduce per-fixture navigation.
  • Switching from browser.wait_for_element to browser.element removes the implicit wait—consider adding an explicit wait or assertion to avoid flakiness when clicking the dropdown button.
  • You changed the TESTING_PAGE_COMPONENT for test_group_dropdown—verify the generic path still loads the grouped items example and update it if it now points to the wrong page.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `view` fixture no longer navigates to specific sub-URLs for each select variant—ensure your test harness still loads the correct “single”, “checkbox”, and “typeahead” pages or reintroduce per-fixture navigation.
- Switching from `browser.wait_for_element` to `browser.element` removes the implicit wait—consider adding an explicit wait or assertion to avoid flakiness when clicking the dropdown button.
- You changed the `TESTING_PAGE_COMPONENT` for `test_group_dropdown`—verify the generic path still loads the grouped items example and update it if it now points to the wrong page.

## Individual Comments

### Comment 1
<location> `src/widgetastic_patternfly5/components/menus/dropdown.py:90` </location>
<code_context>
         #     self.browser.click(self.BUTTON_LOCATOR)
         #     return self.is_open
-        el = self.browser.wait_for_element(self.BUTTON_LOCATOR)
+        el = self.browser.element(self.BUTTON_LOCATOR)
         self.browser.click(el)
         return self.is_open
</code_context>

<issue_to_address>
**issue (bug_risk):** Switching from wait_for_element to element may reduce robustness against slow-loading elements.

This change assumes BUTTON_LOCATOR is always present, which may cause failures if the UI loads slowly. Please ensure this is safe for all scenarios.
</issue_to_address>

### Comment 2
<location> `src/widgetastic_patternfly5/components/menus/select.py:160` </location>
<code_context>
                     selected[item] = self.browser.element(
                         parent=el, locator=".//input"
-                    ).is_selected()
+                    ).is_checked()
                 except NoSuchElementException:
                     selected[item] = False
</code_context>

<issue_to_address>
**question (bug_risk):** Switching to is_checked may not be appropriate for all input types.

Ensure that all input elements in the menu are checkboxes or radio buttons before relying on is_checked, as it may not work correctly for other input types.
</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/menus/dropdown.py
Comment thread src/widgetastic_patternfly5/components/menus/select.py
Comment thread testing/components/menus/test_select.py
@mshriver mshriver merged commit 10efc2d into RedHatQE:feature-playwright Oct 16, 2025
11 checks passed
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