Skip to content

test(playwright): absorb the Keycloak reload bounce in notification specs - #3772

Draft
EmilyRagan wants to merge 2 commits into
mainfrom
fix/notifications-reload-flake
Draft

test(playwright): absorb the Keycloak reload bounce in notification specs#3772
EmilyRagan wants to merge 2 commits into
mainfrom
fix/notifications-reload-flake

Conversation

@EmilyRagan

@EmilyRagan EmilyRagan commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Problem

notifications.s.spec.tsun-acked alerts survive a page reload (must-ack persists) is flaky on Enterprise CI. Seen in cosmos-enterprise run 32395585458 (attempt 2) — it failed, retried, and passed, so the run reported 1 flaky.

Locator: locator('[data-test=toast]').filter({ hasText: 'Playwright reload persist test' })
Expected: visible
Timeout: 20000ms
Error: element(s) not found

Call log:
  - waiting for locator('[data-test=toast]')...
    - waiting for ".../tools/scriptrunner?file=__TEMP__/..." navigation to finish...
    - navigated to ".../tools/scriptrunner?file=...#state=330de028-...&session_state=...&iss=http%3A%2F%2Floca…"

Root cause

Not a product bug, and not slowness in the message-stream replay.

page.reload() resolves on the load event of the pre-redirect document. In Enterprise, OpenC3Auth.init() then kicks off the Keycloak redirect round trip, so that bounce happens after reload() returns and lands inside whatever assertion comes next. The call log above shows the entire 20s budget spent in "waiting for navigation to finish", with the OIDC callback URL (#state=…&session_state=…) arriving at the moment of timeout — leaving zero budget for app boot, cable resubscribe, and stream replay.

The trace from the passing retry confirms the normal path: reload at t=27.6s, toast visible at t=34.9s, i.e. ~7s is needed after the bounce completes. The failing screenshot shows the app booted with an empty notification badge — the replay simply hadn't arrived yet.

Changes

  • reloadAndWaitForApp reloads with waitUntil: 'domcontentloaded' and waits 60s (was 30s) for the app bar, so the Keycloak bounce is absorbed there instead of eating the toast timeout. The old comment estimated the bounce at "roughly 4s"; the observed CI worst case is 20s+.
  • test.setTimeout 120000 → 180000 on both reload tests, so the worst case each step is now allowed (20s emit + 60s reload + 30s replay) can't overflow into an opaque test timeout.
  • Assert localStorage.notificationStreamOffset matches /^\d+-\d+$/ before the reload. The re-toast depends entirely on that offset having been lowered below the un-acked alert; checking it turns an offset-bookkeeping regression — or a malformed <ms>-<seq> id, which makes the server-side XREAD fail and deliver nothing at all — into a named failure instead of a missing toast 30s later.

Test-only change; no product code touched.

🤖 Generated with Claude Code

…pecs

page.reload() resolves on the load event of the pre-redirect document, so in
Enterprise the Keycloak redirect round trip runs after it and was landing inside
the toast assertion. On a saturated CI runner that bounce alone took 20s, so the
un-acked-alert reload test timed out before the app could boot and replay the
message stream (the passing retry needed ~7s after the bounce).

Wait for the app bar with a 60s budget after reload, raise the reload tests to a
180s timeout, and assert the persisted stream offset before reloading so an
offset-bookkeeping regression fails by name rather than as a missing toast.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.10%. Comparing base (758a8a8) to head (8b13116).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3772      +/-   ##
==========================================
- Coverage   79.13%   79.10%   -0.03%     
==========================================
  Files         894      894              
  Lines       66865    66865              
  Branches     2551     2599      +48     
==========================================
- Hits        52911    52892      -19     
- Misses      13293    13312      +19     
  Partials      661      661              
Flag Coverage Δ
frontend 65.90% <ø> (-0.15%) ⬇️
python 79.28% <ø> (+<0.01%) ⬆️
ruby-api 82.01% <ø> (-0.05%) ⬇️
ruby-backend 84.44% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@EmilyRagan EmilyRagan self-assigned this Aug 26, 2026
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant