Skip to content

Harden dropzone spec helpers

Nick Thomas requested to merge (removed):harden-dropzone-helpers into master

What does this MR do?

Capybara helpers such as click_link do not wait for JS + ajax to finish executing before returning. Instead, Capybara helpers wait on the input side instead - any elements referenced in the arguments will be waited for, but JS may still be running when the helper returns.

Not all Capybara helpers can wait for their inputs; in particular, execute_script take an arbitrary JSON blob. This is used extensively in our DropzoneHelper, and is a rich source of races.

This MR hardens the helpers so they wait for JS to finish executing before running the scripts. This allows them to be used in more contexts without exhibiting racy behaviour.

Observed while working on !24000 (merged) - with this change, I reliably get the same failure locally (Errno::ENOENT). Without it, running, e.g., spec/features/projects/wiki/user_creates_wiki_page_spec.rb[1:1:1:7:1:2:1], I often get a failure complaining that dropzone is undefined in JS instead.

We could insist that people call wait_for_requests prior to dropzone_file, etc, but that seems more failure-prone.

Longer-term, we might want to ban page.execute_script in favour of a helper that will do this for us.

Does this MR meet the acceptance criteria?

Conformity

Merge request reports

Loading