Skip to content

Fix flaky spec/features/projects/environments/environments_spec.rb

Stan Hu requested to merge sh-fix-flaky-environment-spec into master

What does this MR do and why?

Previously this test would attempt to play a job in the environments page, but it did not actually wait for the GraphQL request to be sent. Now we wait for the transition from spinner back to play icon to ensure the request to JobsController#play has completed.

Closes #362880 (closed)

How to set up and validate locally

  1. Add a delay for JobsController#play:
diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb
index 557ac5667339..28a04c1a1e09 100644
--- a/app/controllers/projects/jobs_controller.rb
+++ b/app/controllers/projects/jobs_controller.rb
@@ -90,6 +90,8 @@ def play
 
     job = @build.play(current_user, play_params[:job_variables_attributes])
 
+    sleep 3
+
     if job.is_a?(Ci::Bridge)
       redirect_to pipeline_path(job.pipeline)
     else
  1. Run bundle exec rspec ./spec/features/projects/environments/environments_spec.rb:342.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Stan Hu

Merge request reports