Skip to content

adjusting roles selection view to pf5#2472

Open
pondrejk wants to merge 1 commit into
SatelliteQE:masterfrom
pondrejk:pf5dual
Open

adjusting roles selection view to pf5#2472
pondrejk wants to merge 1 commit into
SatelliteQE:masterfrom
pondrejk:pf5dual

Conversation

@pondrejk

@pondrejk pondrejk commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Dual list selector is being updated to PF5 in theforeman/foreman_ansible#796 this should prevent future breakage

@pondrejk pondrejk self-assigned this Jul 7, 2026
@pondrejk pondrejk added No-CherryPick PR doesnt need CherryPick to previous branches Stream do not merge labels Jul 7, 2026
@pondrejk

pondrejk commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author
trigger: test-robottelo
pytest: tests/foreman/ui/test_ansible.py -k test_positive_assign_and_remove_ansible_role_to_hostgroup    
theforeman:
    foreman_ansible: 796

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Consider using contains(@class, 'pf-v5-c-dual-list-selector') instead of an exact class match in addAnsibleRole to make the locator more robust against additional classes being added by PatternFly.
  • For CHOSEN_ITEMS and AVAILABLE_ITEMS, it may be safer to anchor the XPath to the dual list selector container (e.g., relative to addAnsibleRole’s root locator) so changes in surrounding layout don’t inadvertently affect these locators.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider using `contains(@class, 'pf-v5-c-dual-list-selector')` instead of an exact class match in `addAnsibleRole` to make the locator more robust against additional classes being added by PatternFly.
- For `CHOSEN_ITEMS` and `AVAILABLE_ITEMS`, it may be safer to anchor the XPath to the dual list selector container (e.g., relative to `addAnsibleRole`’s root locator) so changes in surrounding layout don’t inadvertently affect these locators.

## Individual Comments

### Comment 1
<location path="airgun/views/host_new.py" line_range="1128" />
<code_context>
-    hostAssignedAnsibleRoles = Text(
-        './/button[@class="pf-v5-c-dual-list-selector__item"]/span[1]//span[2]'
-    )
+    hostAssignedAnsibleRoles = Text('.//span[contains(@class, "dual-list-selector__item-text")]')
     selectRoles = PF5Button(locator='.//button[@aria-label="Add selected"]')
     unselectRoles = PF5Button(locator='.//button[@aria-label="Remove selected"]')
</code_context>
<issue_to_address>
**issue (bug_risk):** hostAssignedAnsibleRoles locator may inadvertently match both available and chosen roles

This locator now targets any element with `dual-list-selector__item-text`, which exists in both available and chosen lists. If `hostAssignedAnsibleRoles` should only reflect assigned roles, please scope it under the chosen column (e.g., under a `pf-m-chosen` container or via the existing `CHOSEN_ITEMS` anchor) so we don’t mix available and assigned roles.
</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 airgun/views/host_new.py
hostAssignedAnsibleRoles = Text(
'.//button[@class="pf-v5-c-dual-list-selector__item"]/span[1]//span[2]'
)
hostAssignedAnsibleRoles = Text('.//span[contains(@class, "dual-list-selector__item-text")]')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): hostAssignedAnsibleRoles locator may inadvertently match both available and chosen roles

This locator now targets any element with dual-list-selector__item-text, which exists in both available and chosen lists. If hostAssignedAnsibleRoles should only reflect assigned roles, please scope it under the chosen column (e.g., under a pf-m-chosen container or via the existing CHOSEN_ITEMS anchor) so we don’t mix available and assigned roles.

@Satellite-QE

Copy link
Copy Markdown
Contributor

PRT Result

Build Number: 854
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/ui/test_ansible.py -k test_positive_assign_and_remove_ansible_role_to_hostgroup --external-logging
Test Result : ========== 1 passed, 19 deselected, 5 warnings in 1498.03s (0:24:58) ===========

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge No-CherryPick PR doesnt need CherryPick to previous branches PRT-Passed Indicates that latest PRT run is passed for the PR Stream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants