Skip to content

[CCXDEV-16481] fix(ocp-advisor-frontend): update CHIP_ROOT selector for PF6 Chip-to-Label migration#128

Merged
digitronik merged 3 commits into
RedHatQE:mainfrom
matysek:mzibrick-ccxdev16481
Jun 16, 2026
Merged

[CCXDEV-16481] fix(ocp-advisor-frontend): update CHIP_ROOT selector for PF6 Chip-to-Label migration#128
digitronik merged 3 commits into
RedHatQE:mainfrom
matysek:mzibrick-ccxdev16481

Conversation

@matysek

@matysek matysek commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Updates CHIP_ROOT XPath selector to match both the old OUIA data-ouia-component-type="/Chip" attribute and the new .pf-v6-c-label CSS class
  • Fixes chip detection, clearing, and iteration after ocp-advisor-frontend#1134 migrated FilterChips from PF6/Chip OUIA components to plain PF6 Label components (via @redhat-cloud-services/frontend-components 7.0.11 → 7.7.1)

Problem

The frontend upgrade removed data-ouia-component-type="PF6/Chip" from filter chips, replacing them with .pf-v6-c-label elements. The CHIP_ROOT selector only matched the OUIA attribute, so:

  • clear_all_chips() silently failed to find/remove active filter chips
  • Chip iteration and remove_all_chips() returned no results
  • Tests relying on chip operations failed in shared browser sessions (CI) where stale filters persisted

Test plan

  • Verified fix locally against ocp-advisor-frontend staging with IQE CCX plugin UI tests
  • widgetastic.patternfly5 unit tests

🤖 Generated with Claude Code

Summary by Sourcery

Bug Fixes:

  • Fix detection and removal of filter chips after frontend migration from PF6 Chip OUIA components to PF6 Label components.

…or PF6 Chip-to-Label migration

The frontend migrated FilterChips from PF6/Chip OUIA components to
plain .pf-v6-c-label CSS classes, removing the data-ouia-component-type
attribute. This broke chip detection, clearing, and iteration in tests.
@sourcery-ai

sourcery-ai Bot commented Jun 12, 2026

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

Reviewer's Guide

Updates the CHIP_ROOT selector in the PatternFly 5 chip widget to support both legacy OUIA Chip components and new PF6 label-based chips, restoring chip detection and clearing behavior after the frontend migration.

File-Level Changes

Change Details Files
Broaden chip root locator to match both OUIA Chip components and PF6 label elements while excluding overflow and group containers.
  • Extended the CHIP_ROOT XPath to accept elements with either a data-ouia-component-type containing '/Chip' or a CSS class containing '-c-label'.
  • Preserved the exclusion of overflow variants by keeping the not(contains(@Class, '-m-overflow')) predicate in the XPath.
  • Ensured chip and label group containers are still excluded by maintaining the not(contains(@Class, '-c-chip-group') or contains(@Class, '-c-label-group')) predicate.
src/widgetastic_patternfly5/components/chip.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

@matysek matysek marked this pull request as ready for review June 12, 2026 13:59

@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 - I've left some high level feedback:

  • The updated CHIP_ROOT selector now matches any element whose class contains -c-label, which may accidentally include non-filter label components; consider tightening this to the specific PF6 label class (e.g., contains(@class, 'pf-v6-c-label ') or a more constrained pattern) to reduce the risk of unintended matches.
  • For consistency and maintainability, you might want to align how CHIP_ROOT and CHIP_TEXT detect chip/label elements (e.g., share a common helper or clearly document the expected PF versions/classes they support) so future PF upgrades require fewer scattered selector changes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The updated CHIP_ROOT selector now matches any element whose class contains `-c-label`, which may accidentally include non-filter label components; consider tightening this to the specific PF6 label class (e.g., `contains(@class, 'pf-v6-c-label ')` or a more constrained pattern) to reduce the risk of unintended matches.
- For consistency and maintainability, you might want to align how CHIP_ROOT and CHIP_TEXT detect chip/label elements (e.g., share a common helper or clearly document the expected PF versions/classes they support) so future PF upgrades require fewer scattered selector changes.

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.

…ting/components/test_chip.py::test_chipgroup_simple
@matysek

matysek commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Second commit fixes this test failure. The test works on main:

===================================================================================================== FAILURES =====================================================================================================
______________________________________________________________________________________________ test_chipgroup_simple _______________________________________________________________________________________________

chip_group_view = <test_chip.chip_group_view.<locals>.TestView object at 0x7f6ff55f7a10>

    def test_chipgroup_simple(chip_group_view):
        assert chip_group_view.is_displayed
        assert chip_group_view.chip_group.is_displayed
    
        chips = [
            "Chip one",
            "Really long chip that goes on and on",
            "Chip three",
            "Chip four",
            "Chip five",
        ]
>       assert chip_group_view.chip_group.read() == chips
E       AssertionError: assert ['Chip one', ..., 'Show Less'] == ['Chip one', ..., 'Chip five']
E         
E         Left contains one more item: 'Show Less'
E         
E         Full diff:
E           [
E               'Chip one',
E               'Really long chip that goes on and on',...
E         
E         ...Full output truncated (5 lines hidden), use '-vv' to show

testing/components/test_chip.py:45: AssertionError
---------------------------------------------------------------------------------------------- Captured stdout setup -----------------------------------------------------------------------------------------------
Testing page: https://www.patternfly.org/components/chip

@matysek

matysek commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

I tried to add a test case.

@matysek matysek force-pushed the mzibrick-ccxdev16481 branch from a7c66b2 to d871847 Compare June 15, 2026 15:30

@digitronik digitronik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

Comment thread testing/components/test_chip.py
@digitronik

Copy link
Copy Markdown
Member

LGTM failures are not related to this changes. Some locator changes. Fixing them.

@digitronik digitronik merged commit 5145516 into RedHatQE:main Jun 16, 2026
7 of 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