Repository navigation
fix: Fix playwright gateway action tests - #3995
Conversation
afd253c to
bc92ac9
Compare
bc92ac9 to
b86256c
Compare
marekdano
left a comment
There was a problem hiding this comment.
The test tests/playwright/test_gateways.py::TestGatewayActions::test_gateway_row_actions_visible fails with the error
def test_gateway_row_actions_visible(self, gateways_page: GatewaysPage):
"""Test that all gateway row action buttons are visible."""
gateways_page.navigate_to_gateways_tab()
gateways_page.wait_for_gateways_table_loaded()
# Skip if no gateways exist
if gateways_page.get_gateway_count() == 0:
pytest.skip("No gateways available for testing")
# Get first gateway row
first_row = gateways_page.get_gateway_row(0)
# Verify all action buttons exist
> expect(first_row.locator('button:has-text("Test")')).to_be_visible()
E AssertionError: Locator expected to be visible
E Actual value: hidden
E Call log:
E - Expect "to_be_visible" with timeout 5000ms
E - waiting for locator("#gateways-table-body").locator("tr").first.locator("button:has-text(\"Test\")")
E 9 × locator resolved to <button type="button" role="menuitem" @click="menuOpen = false; testGateway("http://fast_time_server:8080/sse")" class="w-full flex items-center px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700">Test</button>
E - unexpected value "hidden"
tests/playwright/test_gateways.py:528: AssertionErrorThe test is failing because the action buttons (Test, View, Edit, etc.) are inside a dropdown menu that is hidden by default. According to PR #3802 mentioned in the page object, all action buttons were moved inside an Alpine.js-controlled dropdown with menuOpen: false by default.
To fix this error, the test_gateway_row_actions_visible test should be updated with
# Open the action dropdown (PR #3802 moved buttons inside dropdown)
gateways_page._open_action_dropdown(first_row)
# Verify all action buttons exist in the dropdown menu
expect(first_row.locator('button[role="menuitem"]:has-text("Test")')).to_be_visible()
expect(first_row.locator('button[role="menuitem"]:has-text("View")')).to_be_visible()
expect(first_row.locator('button[role="menuitem"]:has-text("Edit")')).to_be_visible()
# Either Activate or Deactivate should be visible
activate_btn = first_row.locator('button[role="menuitem"]:text-is("Activate")')
deactivate_btn = first_row.locator('button[role="menuitem"]:text-is("Deactivate")')
assert activate_btn.is_visible() or deactivate_btn.is_visible()
# Delete button should be visible (inside a form)
expect(first_row.locator('form[action*="/delete"] button[type="submit"]:has-text("Delete")')).to_be_visible()b86256c to
761db51
Compare
Signed-off-by: Gabriel Costa <[email protected]>
The delete_gateway_by_url method was missing the _open_action_dropdown call added by the previous commit. Since PR #3802 moved all action buttons (including Delete) inside an Alpine.js dropdown menu, the delete button is not directly clickable without first opening the menu. Closes #3982 Signed-off-by: Mihai Criveti <[email protected]>
…ject Three test files directly click gateway action buttons without going through the GatewaysPage page object, so they were also broken by PR #3802's move to the Alpine.js overflow menu: - test_rbac_permissions.py: test_admin_delete_gateway bypassed page object to inspect HTTP response status directly - test_admin_url_context.py: _get_delete_gateway_btn helper used by multiple URL-context tests and iframe delete tests - test_iframe_embedding_security.py: delete and toggle tests operated directly on iframe FrameLocator Each now opens the actions dropdown before clicking the menu item. Signed-off-by: Mihai Criveti <[email protected]>
ba64137 to
25baf89
Compare
crivetimihai
left a comment
There was a problem hiding this comment.
Looks good, nice catch on the regression from PR #3802.
I rebased onto main (clean, no conflicts) and added two follow-up commits:
Commit 2 — fix: add missing _open_action_dropdown call in delete_gateway_by_url
delete_gateway_by_url()was the one action method in the page object that was missed — it also clicks the Delete button which lives inside the dropdown now. Added the_open_action_dropdowncall + black/isort formatting cleanup.
Commit 3 — fix: open action dropdown in remaining test files that bypass page object
- Three other test files click gateway action buttons directly (bypassing the page object), so they were broken by the same #3802 change:
test_rbac_permissions.py—test_admin_delete_gatewaylocated the delete button on the row directlytest_admin_url_context.py—_get_delete_gateway_btnhelper used by multiple URL-context and iframe delete teststest_iframe_embedding_security.py— delete and toggle iframe tests operated onFrameLocatordirectly
- Each now opens the actions dropdown before clicking. Added
wait_for(state="attached")guards in the iframe tests and moved the skip guard before the dropdown interaction in_get_delete_gateway_btn.
Selectors verified against gateways_partial.html — all match (button[aria-expanded], [role="menu"], button[role="menuitem"], form[action*="/delete"]).
* fix: Fix playwright gateway action tests Signed-off-by: Gabriel Costa <[email protected]> * fix: add missing _open_action_dropdown call in delete_gateway_by_url The delete_gateway_by_url method was missing the _open_action_dropdown call added by the previous commit. Since PR #3802 moved all action buttons (including Delete) inside an Alpine.js dropdown menu, the delete button is not directly clickable without first opening the menu. Closes #3982 Signed-off-by: Mihai Criveti <[email protected]> * fix: open action dropdown in remaining test files that bypass page object Three test files directly click gateway action buttons without going through the GatewaysPage page object, so they were also broken by PR #3802's move to the Alpine.js overflow menu: - test_rbac_permissions.py: test_admin_delete_gateway bypassed page object to inspect HTTP response status directly - test_admin_url_context.py: _get_delete_gateway_btn helper used by multiple URL-context tests and iframe delete tests - test_iframe_embedding_security.py: delete and toggle tests operated directly on iframe FrameLocator Each now opens the actions dropdown before clicking the menu item. Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: Gabriel Costa <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> Co-authored-by: Mihai Criveti <[email protected]>
* fix: Fix playwright gateway action tests Signed-off-by: Gabriel Costa <[email protected]> * fix: add missing _open_action_dropdown call in delete_gateway_by_url The delete_gateway_by_url method was missing the _open_action_dropdown call added by the previous commit. Since PR #3802 moved all action buttons (including Delete) inside an Alpine.js dropdown menu, the delete button is not directly clickable without first opening the menu. Closes #3982 Signed-off-by: Mihai Criveti <[email protected]> * fix: open action dropdown in remaining test files that bypass page object Three test files directly click gateway action buttons without going through the GatewaysPage page object, so they were also broken by PR #3802's move to the Alpine.js overflow menu: - test_rbac_permissions.py: test_admin_delete_gateway bypassed page object to inspect HTTP response status directly - test_admin_url_context.py: _get_delete_gateway_btn helper used by multiple URL-context tests and iframe delete tests - test_iframe_embedding_security.py: delete and toggle tests operated directly on iframe FrameLocator Each now opens the actions dropdown before clicking the menu item. Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: Gabriel Costa <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> Co-authored-by: Mihai Criveti <[email protected]>
🐛 Bug-fix PR
📌 Summary
Closes #3982
🔁 Reproduction Steps
🐞 Root Cause
The playwright test updates got lost on a PR rework.
💡 Fix Description
Added a step to open the overflow menu to the gateway action tests
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)