Skip to content

PF5 migration of Bookmarks - #1938

Merged
Gauravtalreja1 merged 1 commit into
SatelliteQE:masterfrom
lhellebr:pf5_bookmarks
Aug 14, 2025
Merged

PF5 migration of Bookmarks#1938
Gauravtalreja1 merged 1 commit into
SatelliteQE:masterfrom
lhellebr:pf5_bookmarks

Conversation

@lhellebr

@lhellebr lhellebr commented Jul 31, 2025

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Migrate BookmarkCreateView locators to PatternFly 5 and OUIA attributes by enhancing selectors while retaining backwards compatibility

Enhancements:

  • Include aria-label 'bookmark-modal' in ROOT locator to detect PF5 modal
  • Broaden error_message locator to capture PF5 error styling
  • Add OUIA-based locator for the public checkbox while retaining legacy name selectors
  • Add OUIA-based locators for submit and cancel buttons while preserving existing selectors

@lhellebr lhellebr added the No-CherryPick PR doesnt need CherryPick to previous branches label Jul 31, 2025
@sourcery-ai

sourcery-ai Bot commented Jul 31, 2025

Copy link
Copy Markdown
Contributor

Reviewer's Guide

The PR migrates the BookmarkCreateView selectors to PatternFly 5 standards by extending existing XPaths with aria-labels and data-ouia-component-id attributes, ensuring backward compatibility while adopting new PF5 conventions.

File-Level Changes

Change Details Files
Refactored element locators in BookmarkCreateView for PF5 migration
  • Extended ROOT XPath to include aria-label 'bookmark-modal' alongside the modal-dialog class
  • Enhanced error_message locator to catch PF5 error styling via ancestor classes
  • Updated public checkbox selector to prefer data-ouia-component-id and fallback to legacy name attributes
  • Augmented submit and cancel button XPaths with data-ouia-component-id attributes while preserving original conditions
airgun/views/common.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

@lhellebr

Copy link
Copy Markdown
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/ui/test_bookmarks.py

@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 @lhellebr - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `airgun/views/common.py:686` </location>
<code_context>
-    submit = Text(".//button[@type='submit' or @ng-click='ok()']")
-    # may contain <span> inside, using normalize-space
-    cancel = Text(".//button[normalize-space(.)='Cancel']")
+    error_message = Text(
+        ".//span[@class='error-message' or (ancestor::div[contains(@class, 'pf-m-error')] and contains(@class, 'item-text'))]"
+    )
+    public = Checkbox(
</code_context>

<issue_to_address>
The XPath for error_message may match more elements than intended.

This XPath may select spans that are not actual error messages if they share the 'item-text' class within error containers, potentially causing false positives.
</issue_to_address>

### Comment 2
<location> `airgun/views/common.py:689` </location>
<code_context>
+    error_message = Text(
+        ".//span[@class='error-message' or (ancestor::div[contains(@class, 'pf-m-error')] and contains(@class, 'item-text'))]"
+    )
+    public = Checkbox(
+        locator="//input[@data-ouia-component-id='isPublic-checkbox' or (@type='checkbox' and (@name='public' or @name='publik'))]"
+    )
+    submit = Text(
</code_context>

<issue_to_address>
The locator for the public checkbox is now more flexible but could match unintended elements.

This may cause ambiguous selection if multiple checkboxes meet these criteria on the page.
</issue_to_address>

### Comment 3
<location> `airgun/views/common.py:692` </location>
<code_context>
+    public = Checkbox(
+        locator="//input[@data-ouia-component-id='isPublic-checkbox' or (@type='checkbox' and (@name='public' or @name='publik'))]"
+    )
+    submit = Text(
+        ".//button[@data-ouia-component-id='submit-btn' or @type='submit' or @ng-click='ok()']"
+    )
+    cancel = Text(".//button[@data-ouia-component-id='cancel-btn' or normalize-space(.)='Cancel']")
</code_context>

<issue_to_address>
The submit button selector may match multiple buttons if present.

If multiple buttons meet these criteria, the selector may not uniquely identify the intended submit button. Consider refining the selector for uniqueness.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
    submit = Text(
        ".//button[@data-ouia-component-id='submit-btn' or @type='submit' or @ng-click='ok()']"
    )
=======
    submit = Text(
        # Prefer the unique data-ouia-component-id, otherwise fallback to the first visible submit button
        ".//button[@data-ouia-component-id='submit-btn'] | (.//button[(@type='submit' or @ng-click='ok()') and not(@data-ouia-component-id)])[1]"
    )
>>>>>>> REPLACE

</suggested_fix>

### Comment 4
<location> `airgun/views/common.py:695` </location>
<code_context>
+    submit = Text(
+        ".//button[@data-ouia-component-id='submit-btn' or @type='submit' or @ng-click='ok()']"
+    )
+    cancel = Text(".//button[@data-ouia-component-id='cancel-btn' or normalize-space(.)='Cancel']")

     @property
</code_context>

<issue_to_address>
The cancel button selector could be more robust to localization.

Relying on button text may fail in localized environments. Use data-ouia-component-id or another stable attribute instead.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
    cancel = Text(".//button[@data-ouia-component-id='cancel-btn' or normalize-space(.)='Cancel']")
=======
    cancel = Text(".//button[@data-ouia-component-id='cancel-btn']")
>>>>>>> REPLACE

</suggested_fix>

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/common.py
Comment on lines +686 to +687
error_message = Text(
".//span[@class='error-message' or (ancestor::div[contains(@class, 'pf-m-error')] and contains(@class, '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): The XPath for error_message may match more elements than intended.

This XPath may select spans that are not actual error messages if they share the 'item-text' class within error containers, potentially causing false positives.

Comment thread airgun/views/common.py
Comment on lines +689 to +690
public = Checkbox(
locator="//input[@data-ouia-component-id='isPublic-checkbox' or (@type='checkbox' and (@name='public' or @name='publik'))]"

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): The locator for the public checkbox is now more flexible but could match unintended elements.

This may cause ambiguous selection if multiple checkboxes meet these criteria on the page.

Comment thread airgun/views/common.py
Comment on lines +692 to +694
submit = Text(
".//button[@data-ouia-component-id='submit-btn' or @type='submit' or @ng-click='ok()']"
)

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.

suggestion (bug_risk): The submit button selector may match multiple buttons if present.

If multiple buttons meet these criteria, the selector may not uniquely identify the intended submit button. Consider refining the selector for uniqueness.

Suggested change
submit = Text(
".//button[@data-ouia-component-id='submit-btn' or @type='submit' or @ng-click='ok()']"
)
submit = Text(
# Prefer the unique data-ouia-component-id, otherwise fallback to the first visible submit button
".//button[@data-ouia-component-id='submit-btn'] | (.//button[(@type='submit' or @ng-click='ok()') and not(@data-ouia-component-id)])[1]"
)

Comment thread airgun/views/common.py
submit = Text(
".//button[@data-ouia-component-id='submit-btn' or @type='submit' or @ng-click='ok()']"
)
cancel = Text(".//button[@data-ouia-component-id='cancel-btn' or normalize-space(.)='Cancel']")

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.

suggestion: The cancel button selector could be more robust to localization.

Relying on button text may fail in localized environments. Use data-ouia-component-id or another stable attribute instead.

Suggested change
cancel = Text(".//button[@data-ouia-component-id='cancel-btn' or normalize-space(.)='Cancel']")
cancel = Text(".//button[@data-ouia-component-id='cancel-btn']")

@Satellite-QE Satellite-QE added the PRT-Failed Indicates that latest PRT run is failed for the PR label Jul 31, 2025
@lhellebr

Copy link
Copy Markdown
Contributor Author

The only tests failing in PRT are the [Host] ones. At the first glance, I don't see why. But these tests have been failing long pre-PF5 so I think this is mergeable.

@lhellebr
lhellebr requested review from a team July 31, 2025 13:54
@Gauravtalreja1
Gauravtalreja1 merged commit 09c54ea into SatelliteQE:master Aug 14, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No-CherryPick PR doesnt need CherryPick to previous branches PRT-Failed Indicates that latest PRT run is failed for the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants