Fix flaky new_project_spec CI/CD from repo URL test

What does this MR do?

We fixed three flaky tests in ee/spec/features/projects/new_project_spec.rb that all had the same root cause.

The problem

All three tests create a project by filling in a form and clicking "Create project". After the form submits, the browser navigates to a new page. The tests then call Project.last to get the created project — but they weren't properly waiting for the page navigation to finish. This meant Project.last sometimes returned nil because the database transaction hadn't committed yet, causing this error:

ActionController::UrlGenerationError: No route matches {:action=>"show", :controller=>"projects", :id=>nil, :namespace_id=>nil}

The fix (same pattern applied to all three tests):

  1. Added expect(page).to have_content("was successfully created") after clicking "Create project" — this waits for the flash message on the new page, which guarantees the project has been saved to the database before we try to read it.
  2. Added expect(created_project).to be_present as a safety check instead of letting project_path(nil) blow up with a confusing route error.
  3. Removed the quarantine tag from the "CI/CD project from repo URL" test (line 225) since the fix addresses the underlying flakiness.
  4. Moved page.within scope in the CI/CD test to close before the page navigates away — the #ci-cd-project-pane element doesn't exist on the project show page, so keeping assertions inside that scope was unreliable.

Tests fixed

Test Line Failures (last 14 days)
creates a new project in personal namespace 22 1
"Import project" tab creates projects with features enabled 43 33
creates CI/CD project from repo URL 225 previously quarantined, 171 historical

https://gitlab.com/gitlab-org/quality/test-failure-issues/-/work_items/7312

Quarantine flaky new_project_spec.rb (!228772 - closed) quarantines a test whose flakiness should be fixed in this MR

Edited by Carla Drago

Merge request reports

Loading