Skip to content

Commit

Permalink
Fix stability of check for scroll-up button in t/ui/14-dashboard.t
Browse files Browse the repository at this point in the history
  • Loading branch information
Martchus committed Jul 29, 2021
1 parent 588eaf7 commit b2fd271
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions t/ui/14-dashboard.t
Expand Up @@ -43,18 +43,18 @@ my @build_headings = $driver->find_elements('.h4', 'css');
is(scalar @build_headings, 4, '4 builds shown');

subtest 'Back to top button' => sub {
my $back_to_top = $driver->find_element('#back-to-top');
ok $back_to_top, 'back to top button exists';
ok !$back_to_top->is_displayed, 'button is not visible';
my $check_visibility
= sub { $driver->execute_script('return getComputedStyle(document.getElementById("back-to-top")).display') };
is $check_visibility->(), 'none', 'button is not visible';
# scroll down resizing the jumbotron to ensure there's enough content for scrolling down
$driver->execute_script(
'document.getElementsByClassName("jumbotron")[0].style.height = "10000px";
window.scrollTo(0, document.body.scrollHeight);'
);
$back_to_top = $driver->find_element('#back-to-top');
ok $back_to_top->is_displayed, 'button is visible after scrolling down';
$back_to_top->click();
ok !$back_to_top->is_displayed, 'button is not visible anymore after using it';
# wait until button is shown (even with disabled animations it might now show up instantly, see poo#95839)
wait_until sub { $check_visibility->() eq 'none' }, 'button is visible after scrolling down', 10;
$driver->find_element('#back-to-top')->click;
is $check_visibility->(), 'none', 'button is not visible anymore after using it';
};

# click on last build which should be Build0091
Expand Down

0 comments on commit b2fd271

Please sign in to comment.