From 82d2128efa9f251d96e75f106d571669aec65d66 Mon Sep 17 00:00:00 2001 From: Marius Kittler Date: Fri, 4 Oct 2024 17:18:26 +0200 Subject: [PATCH] Fix race condition in `t/ui/18-tests-details.t` * The synchronization via `wait_for_ajax_and_animations` did likely not work because there is probably still asynchronicity going on despite the attempt to disable animations explicitly. Note that the relevant Ajax code still uses jQuery so this is *not* a regression of 87a7e36. * Use `wait_for_element` like in many other cases. * Avoid running into `Can't call method "is_enabled" on an undefined value` in case the test fails. * Remove code that attempted to find more than one element by ID. (Even if the ID was not unique the test would not be able to find this violation.) * See https://progress.opensuse.org/issues/167656 --- t/ui/18-tests-details.t | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/t/ui/18-tests-details.t b/t/ui/18-tests-details.t index ea64e2beb98..b765a3e10a9 100644 --- a/t/ui/18-tests-details.t +++ b/t/ui/18-tests-details.t @@ -77,13 +77,12 @@ sub current_tab { $driver->find_element('.nav.nav-tabs .active')->get_text } # returns the contents of the candidates combo box as hash (key: tag, value: array of needle names) sub find_candidate_needles { # ensure the candidates menu is visible - my @candidates_menus = $driver->find_elements('#candidatesMenu'); - is(scalar @candidates_menus, 1, 'exactly one candidates menu present at a time'); + my $candidates_menu = wait_for_element(selector => '#candidatesMenu', is_displayed => 1) or return {}; # save implicit waiting time as long as we are only looking for elements # that should be visible already disable_timeout; - return {} unless $candidates_menus[0]->is_enabled; - $candidates_menus[0]->click(); + return {} unless $candidates_menu->is_enabled; + $candidates_menu->click; # read the tags/needles from the HTML structure my @section_elements = $driver->find_elements('#needlediff_selector ul table'); @@ -611,7 +610,6 @@ sub test_with_error { # check whether candidates are displayed as expected my $random_number = int(rand(100000)); $driver->get("/tests/99946?prevent_caching=$random_number#step/yast2_lan/1"); - wait_for_ajax_and_animations; is_deeply(find_candidate_needles, $expect, $test_name // 'candidates displayed as expected'); }