From 39dd037daee6979b095ce82c317fbba768ea9a27 Mon Sep 17 00:00:00 2001 From: Marc Shaw Date: Wed, 17 Dec 2025 17:39:56 +0100 Subject: [PATCH 1/2] Fix flaky test: wait for frontend updates before asserting pipeline status The test was failing intermittently because it set the pipeline status to 'success' in the database but immediately asserted on the page content without waiting for the frontend to poll and update. This created a race condition where: - Usually: Frontend polls quickly and updates before assertion - Rarely: Frontend doesn't poll in time, causing 30s timeout The fix adds wait_for_requests before the first assertion to ensure any pending frontend updates (GraphQL queries, polling) complete before checking the page content. Fixes: https://gitlab.com/gitlab-org/quality/test-failure-issues/-/issues/2299 --- .../merge_request/user_merges_only_if_pipeline_succeeds_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb b/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb index 62414700f01048..dd1c9c2fe33d09 100644 --- a/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb +++ b/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb @@ -147,6 +147,8 @@ end it 'the MR gets merged' do + wait_for_requests + expect(page).to have_content("Pipeline ##{pipeline.id} passed") wait_for_requests -- GitLab From 57855c9990f0ca09f990e7644f0ab4e5c3bd3096 Mon Sep 17 00:00:00 2001 From: Marc Shaw Date: Wed, 17 Dec 2025 18:42:54 +0100 Subject: [PATCH 2/2] Add wait_for_requests to second flaky test Apply the same fix to line 243 that was applied to line 149. Both test cases have identical structure and suffer from the same race condition where the frontend needs time to poll and update the pipeline status after set_status('success'). --- .../merge_request/user_merges_only_if_pipeline_succeeds_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb b/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb index dd1c9c2fe33d09..eef4d361e8d53f 100644 --- a/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb +++ b/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb @@ -241,6 +241,8 @@ end it 'the MR gets merged' do + wait_for_requests + expect(page).to have_content("Pipeline ##{pipeline.id} passed") wait_for_requests -- GitLab