capybara/rspec already calls Capybara.reset_sessions! in an
`after` hook, but `block_and_wait_for_requests_complete` is called
before it so by calling it explicitely here, we prevent any new
requests from being fired.
See
ffb41cfad6/lib/capybara/rspec.rb (L20-L25)
Signed-off-by: Rémy Coutable <remy@rymai.me>
From logs in #33756, we that it's possible for an Ajax call to be made
before the middleware receives it. To prevent stray Ajax calls from
breaking other specs, we need to wait for all scheduled calls to finish.
Closes#33756
The idea is that after each feature spec example, we block all incoming
requests at the Rack level, go to the 'about:blank' page, and wait until
the current requests reach 0.
This should solve the problem where a request would end after database
cleaner performed the database truncation. The problem was that a GET
request can still lead to records creation (e.g. namespaces or routes).
Signed-off-by: Rémy Coutable <remy@rymai.me>