Test suite: fix wait_vanish()
commit3ec590aed35e84ac4e15f07fc4d3ea2671a4d8f9
authoranonym <anonym@riseup.net>
Thu, 28 Mar 2024 11:36:53 +0000 (28 12:36 +0100)
committeranonym <anonym@riseup.net>
Thu, 28 Mar 2024 11:56:03 +0000 (28 12:56 +0100)
tree1834a2ff1ecfe157f2e8be4d41705b415d24be1b
parent022fd0b072adf40a856c7923b46296aeb5b8e4b3
Test suite: fix wait_vanish()

Since try_for() considers an iteration a success (and returns) as long
as the block returns something true-ish (i.e. everything but false and
nil) we used to return from the try_for() when finding a match, since
that becomes the block's return value and is true-ish, which is the
opposite of what we want.

We can observe this in this debug log where I temporarily enabled
debug logging (which we explicitly disable) for find() and try_for()
so we can see more clearly what happens:

    Screen: waiting for TorBrowserStopButton.png to vanish
    try_for: attempt 1 (0.01s elapsed of 120s)...
    Screen: trying to find TorBrowserStopButton.png
    Screen[match_screen]: taking screenshot
    Screen[match_screen]: matching template to screenshot
    OpenCV: starting opencv_match_template.py
    Screen: found TorBrowserStopButton.png at (96, 97)
    try_for: success!
    Screen: TorBrowserStopButton.png has vanished

Whoops! So this method has been doing nothing except block execution
until it returns, which I guess has been enough in most cases it's
used, but this fix will probably fix some fragile tests.
features/support/helpers/screen.rb