Fix flaky work package activity journal filter spec#24032
Draft
myabc wants to merge 1 commit into
Draft
Conversation
Strengthens `filter_journals` to wait until the journals wrapper reflects the requested filter, mirroring `set_journal_sorting`. The bare `wait_for_turbo_stream` resolved on the first rendered stream, which a concurrent activity-poll stream could satisfy early, so the helper returned while the DOM still showed the previous filter and raced the assertions that followed.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR stabilizes flaky feature specs around the Work Package activity journal filter by making the filter_journals helper wait for a deterministic DOM post-condition (the journals wrapper reflecting the requested filter/sorting) instead of relying on the first Turbo stream event, which can be satisfied by concurrent polling updates.
Changes:
- Extend
filter_journalsto accept an optionalsorting:keyword (default:asc) so it can wait for the precise wrapper selector. - After triggering the filter change, wait until
op-wp-journals-<filter>-<sorting>is present, mirroring the deterministic pattern already used byset_journal_sorting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stabilises
spec/features/activities/work_package/activities_spec.rb[1:5:2:1]and[1:5:2:2]("filters the activities based on type" / "resets an only_changes filter if a comment is added by the user"), the most frequently reported flaky feature spec in CI over the last 24h (10 hits).Root cause
The activity tab auto-polls every 10s, and
update_attributesarms an extra poll ~2s later. Each poll re-fetches and re-renders the whole journals list, reading the active filter at request time.The shared helper
filter_journalswrapped its menu clicks in a singlewait_for_turbo_stream, which resolves on the firstop:turbo-stream-renderedevent. A concurrent polling stream can satisfy that wait before the filter's own stream renders, so the helper returned while the DOM still showed the previous filter — and the absence assertions that follow (expect_no_journal_changed_attribute,expect_no_journal_notes) then raced a late render.Fix
After the menu interaction, block until the journals wrapper actually reflects the requested filter via its
op-wp-journals-<filter>-<sorting>test selector — the same deterministic post-conditionset_journal_sortingalready uses. This waits through any stale poll render until the correct filter lands.Spec-only change; no production code touched.
Verification
script/bulk_run_rspec spec/features/activities/work_package/activities_spec.rb --run-count 20(pending — relying on CI)Known limitation / follow-up (separate PR, not in scope)
[1:5:2:2]exercises a genuine production race:polling.controller.tsupdateActivitiesListhas no AbortController/generation guard, so a poll response captured under the old filter can be applied after the filter changed (a staleonly_changespoll can re-remove a freshly added comment). The helper change reduces but may not fully close[1:5:2:2]. A complete fix discards/aborts poll responses whose requestedfilter/sortByno longer match the current outlet values; tracked separately.