Fix flaky runner pause/resume spec by waiting for enabled button
What does this MR do and why?
Fixes the flaky 'pauses and resumes runner' shared example
(spec/features/groups/runners/owner_manages_runners_spec.rb via
spec/support/shared_examples/features/runners_shared_examples.rb), reported in
gitlab-org/quality/test-failure-issues#43165.
Root cause
The test clicks Resume and then asserts the button flips to Pause and the "Paused" badge disappears. It failed flakily on the resume half with two faces of one race:
expected to find button "Pause" that is not disabled ... but there were no matchesexpected not to find text "Paused" in "Online Paused Idle ..."
The Pause/Resume button is disabled (loading) while the runnerTogglePaused mutation is in flight
(runner_pause_action.vue sets loading, runner_pause_button.vue binds :loading on the
GlButton). Both the button label and the "Paused" badge derive from the same Apollo-cached
runner.paused. A bare have_button 'Pause' matched the button while it was still disabled
(mid-mutation), so the following negative assertions ran before the re-render settled.
A prior fix (commit 78d8abbb) reordered positive matchers before negative ones, but kept the bare
have_button, which still matched the transitional disabled button — so the flake persisted.
Fix
Assert the destination button is present and enabled (disabled: false) on both halves. This
waits out the in-flight mutation before the dependent assertions run. Because the button and the
badge derive from the same updated data, once the button is enabled the badge has re-rendered too.
Prevent recurrence
Documents the pattern in the testing best practices guide ("Wait for a control to be enabled, not just present"), so future feature specs wait for an enabled control after an async action rather than just its presence.
Scope
I reviewed all specs touched by the related assertion-reorder fix (!240958 (merged)). Only the runner
pause/resume button attribute-disables during its mutation, so it is the only spec that needs the
disabled: false hardening; the others (emoji awards, label subscribe) either do not disable their
control or disable via a CSS class that Capybara's disabled: filter does not match. The
documentation change covers the general class of issue.
Related
- Related to gitlab-org/quality/test-failure-issues#43165
- Follow-up to !240958 (merged)