test(e2e): wait for the facet panel to settle before asserting - #6636
test(e2e): wait for the facet panel to settle before asserting#6636aditya-786 wants to merge 4 commits into
Conversation
After a reload or a timeframe change the facets panel briefly re-renders the same facet twice. assert_facet located the facet with a substring has_text match and asserted visibility immediately, so the strict locator resolved to two elements and raised a strict mode violation. The duplicate outlives the default 5s expect timeout, which is why test_filter_search_timeframe_combination_with_queryparams fails on every run. Wait for the facet locator to settle to a single element before asserting, using the 15s timeout already used for the count assertion in this file.
|
No linked issues found. Please add the corresponding issues in the pull request description. |
The incidents assert_facet is an identical copy with the same transient double-render issue (test_filter_timeframe_combination_with_queryparams hits it after reload), so it gets the same settle-to-one-facet guard.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6636 +/- ##
===========================================
+ Coverage 30.49% 46.42% +15.92%
===========================================
Files 101 178 +77
Lines 11741 18685 +6944
===========================================
+ Hits 3581 8674 +5093
- Misses 8160 10011 +1851 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The settle-wait was not enough. CI showed to_have_count(1) passing and the
very next to_be_visible() failing with a strict mode violation on two
elements, both of them the same facet (get_by_text("Status").first and
.nth(1)), so the panel re-renders between two consecutive assertions and
waiting once cannot hold.
Scope the facet locators to the first match instead. The locator is then
never ambiguous, and Playwright re-queries it on each retry so the value
and counter assertions still converge on the settled panel. The
not_to_be_visible checks after deleting a facet are left alone, since
first would change what they assert.
|
Thanks, pushed a fix. The previous approach was not enough and CI showed exactly why. My settle-wait ( So the facet panel re-renders between two consecutive assertions and waiting once for it to settle cannot hold. The duplicate is also gone by the time the failure artifact is captured, which is why the saved DOM only ever shows one facet. Now the facet locators are scoped to the first match, so the locator is never ambiguous. Playwright re-queries it on every retry, so the value and counter assertions still converge on the settled panel. I applied it to both the alerts and incidents copies of Worth noting the underlying behaviour is on the UI side: the facets panel briefly mounts two copies of the same facet while re-rendering after a reload or timeframe change. This PR only makes the tests robust to it. Happy to open a separate issue for the duplicate render if you want it tracked. |
|
CI update on the latest commit (7e59adf):
Both of the tests this PR targets now pass on both databases that completed: The mysql job failed at step 16, The only other red check is |
Why are these changes needed?
test_filter_search_timeframe_combination_with_queryparamscurrently fails on every run ofrun-tests(mysql, postgresql and sqlite), so it blocks CI on all open PRs.I root-caused it from the CI failure artifacts. The failure is a Playwright strict-mode violation, not a product bug:
What happens:
assert_facet(...)call right afterbrowser.reload(), where the filters are restored from the URL query params.assert_facetlocates the facet with a substringhas_text="severity"match and immediately callsto_be_visible(). With two matching elements, strict mode raises.to_be_visible()cannot ride it out and the failure is deterministic.What changed
assert_facetnow waits for the facet locator to settle to a single element before asserting visibility:The 15s timeout matches the existing count assertion in this same file (
assert_alerts_by_column). Tests where only one facet is ever present are unaffected (the count is already 1, so the wait returns immediately).The incidents test file (
test_filtering_sort_search_on_incidents.py) has an identicalassert_facethelper with the same transient-duplicate issue, so it gets the same guard. Verified on this PR's own CI: with only the alerts fix,test_filter_search_timeframe_combination_with_queryparamspassed and the failure moved to the incidents twintest_filter_timeframe_combination_with_queryparams, so both copies are fixed here.Note: this is a browser e2e test that needs the full docker stack, so I could not run it locally. The diagnosis is from the CI artifacts (DOM dump, console log, traceback) and the fix uses the settle-then-assert pattern already used elsewhere in this suite. The verification is this PR's own
run-testsrun.Checks