Skip to content

Fix flaky glossary hierarchy test and websocket cross-talk in ChangeParentHierarchy (#33440) (2.0 backport) - #33472

Merged
anuj-kumary merged 2 commits into
2.0from
claude/backport-33440-2.0
Sep 17, 2026
Merged

anuj-kumary merged 2 commits into
2.0from
claude/backport-33440-2.0

Conversation

@anuj-kumary

@anuj-kumary anuj-kumary commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Backport of #33440 to 2.0.

Fixes the flaky should move term to root of different glossary E2E test (2/11 pass rate in main's merge queue) by addressing three root causes:

1. Missing async move poll (test-side)
changeTermHierarchyFromModal calls the moveAsync API which returns 200 immediately — the actual glossary-term move is processed asynchronously on the backend. The test navigated to glossary2 and asserted the moved term without waiting for the backend to finish. Added an expect.poll that waits up to 60s for the term's glossary.fullyQualifiedName to reflect the target glossary (same pattern already used by the passing H-M05 test).

2. Unfiltered websocket events (component-side bug)
ChangeParentHierarchy's websocket handler listened to all events on MOVE_GLOSSARY_TERM_CHANNEL without filtering by job ID. When multiple glossary moves happen concurrently (parallel tests, or multiple users), a COMPLETED event from a different operation would trigger handleMoveSuccess, which calls navigate() — closing the modal prematurely. Fixed by tracking the submitted job ID in a ref and only processing matching events.

3. Early terminal websocket event race (component-side bug)
If the backend processes the move and broadcasts the COMPLETED event before the HTTP response assigns submittedJobId, the job-ID guard would discard the only terminal notification — leaving the modal stuck in the saving state indefinitely. Fixed by buffering websocket events that arrive while the HTTP response is in flight (awaitingResponse ref), keyed by jobId in a bounded Map (capped at 100 entries). When the HTTP response resolves, any buffered event matching the job ID is replayed.

Also added test.slow() since the cross-glossary move with async polling needs more than the 60s default timeout under load.

Backport notes

  • The playwright/QUARANTINE.md change from the original PR is not included — 2.0 has no quarantine file or @quarantine tag mechanism, so there is nothing to un-quarantine here.
  • Consequently the spec diff is smaller than main's: main's 51/40 line churn was mostly de-indenting the test out of its { tag: '@quarantine' } wrapper. On 2.0 the change is just test.slow(true) + the expect.poll, plus removal of two stale // Skipped due to known issue: #24794 comments that sat above tests which were not actually skipped on this branch.
  • ChangeParentHierarchy.component.tsx applies byte-identically to main's diff (verified by diff-of-diffs); only hunk line offsets differ.
  • prettier --check passes on both changed files.

Test plan

  • GlossaryHierarchy.spec.ts passes in CI (all 7 tests, especially H-M04)
  • No regressions in the Glossary shard

🤖 Generated with Claude Code

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no outstanding findings after the manually resolved review threads.

Summary

This backport stabilizes glossary hierarchy moves by waiting for asynchronous backend completion and isolating websocket updates by job ID.

  • Polls the glossary-term API before asserting the cross-glossary move.
  • Filters websocket events to the submitted move job.
  • Buffers bounded early events until the move API returns its job ID.
  • Extends the affected Playwright test’s timeout budget.
Diagram
sequenceDiagram
    participant U as User
    participant C as ChangeParentHierarchy
    participant API as Move API
    participant WS as WebSocket

    U->>C: Submit hierarchy move
    C->>C: Mark response pending
    C->>API: moveGlossaryTerm(...)
    API-->>WS: Early job event
    WS-->>C: Event with job ID
    C->>C: Buffer event while response is pending
    API-->>C: Return submitted job ID
    C->>C: Replay matching buffered event
    C->>U: Show completion and navigate
Loading

Reviews (2) · Last reviewed commit: "Merge branch '2.0' into claude/backport-..."

…arentHierarchy (#33440)

* Fix flaky glossary hierarchy test: async move race and websocket cross-talk

Two root causes behind the 2/11 failure rate:

1. The test navigated to verify the moved term without waiting for the async
   move to complete — moveAsync returns 200 immediately while the backend
   processes the hierarchy change asynchronously. Added expect.poll (matching
   the pattern from the passing H-M05 test) to wait for the term's glossary
   FQN to update before asserting the UI.

2. ChangeParentHierarchy's websocket handler processed ALL move events on the
   MOVE_GLOSSARY_TERM_CHANNEL regardless of job ID. Under parallel execution,
   a COMPLETED event from another move operation caused the modal to navigate
   away prematurely. Added job ID filtering via a ref so only the submitted
   job's events are processed.

Also added test.slow() since the cross-glossary move with async poll needs
more than the default 60s budget under load.

Verified: 40/40 green at --repeat-each=20 --workers=6 (previously 2/11).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Buffer early websocket events to prevent dropped terminal notifications

If the backend processes the move and broadcasts the COMPLETED websocket
event before the HTTP response assigns submittedJobId, the job-ID guard
would discard the only terminal notification — leaving the modal stuck
in the saving state indefinitely.

Track an awaitingResponse flag around the moveGlossaryTerm call and
buffer any websocket events that arrive during that window. When the
HTTP response resolves and provides the job ID, replay the buffered
event if it matches.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Buffer websocket events by jobId to prevent overwrite by concurrent moves

Use a Map<jobId, event> instead of a single ref so concurrent move events
from different operations cannot overwrite each other during the brief
HTTP-response window. The map is cleared after replay.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix formatting from ui-checkstyle

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Cap websocket event buffer at 100 entries

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
(cherry picked from commit 1bf046f)
@anuj-kumary anuj-kumary added UI UI specific issues safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check labels Sep 17, 2026
@anuj-kumary
anuj-kumary requested a review from a team as a code owner September 17, 2026 07:27
@anuj-kumary anuj-kumary self-assigned this Sep 17, 2026
@gitar-bot

gitar-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Backport of flaky glossary hierarchy test fix addressing three root causes: missing async move poll in the test, unfiltered websocket events in ChangeParentHierarchy that caused premature modal closure on concurrent moves, and a race condition where terminal websocket events could arrive before the HTTP response assigned the job ID. Includes event buffering and job-ID filtering to handle concurrent operations correctly. No issues found.

Review coverage

Rules No rules evaluated

Functional validation Not enabled · Set up

Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@github-actions

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 67%
67.33% (81019/120322) 52.01% (49943/96019) 52.81% (14832/28083)

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 72af3af3577700c0ca57517ad566860f921a7d74 in Playwright run 35198975031, attempt 1.

✅ 53 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 38m 55s

⏱️ Max setup 1m 41s · max shard execution 5m 54s · max shard-job elapsed before upload 9m 29s · reporting 3s

🌐 142.89 requests/attempt · 1.35 app boots/UI scenario · 0.00% common-shard skew

Optimization targets still in progress:

  • Application boot ratio was 1.35 per UI scenario (74 boots / 55 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 53 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@anuj-kumary
anuj-kumary merged commit 9c92f5d into 2.0 Sep 17, 2026
81 of 82 checks passed
@anuj-kumary
anuj-kumary deleted the claude/backport-33440-2.0 branch September 17, 2026 09:02

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants