From 134cde8415b3a9118262ef4ea34cf798c258be03 Mon Sep 17 00:00:00 2001 From: nessita <124304+nessita@users.noreply.github.com> Date: Tue, 28 Nov 2023 19:06:17 -0300 Subject: [PATCH] Removed hard-coded expected results in SeleniumTests.test_select_multiple test. This ensures that both tests, test_select() and test_select_multiple(), use analogous calculations for the expected amount of results, and for the iteration when pressing "arrow down" and waiting for the ajax call to complete. --- tests/admin_views/test_autocomplete_view.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/admin_views/test_autocomplete_view.py b/tests/admin_views/test_autocomplete_view.py index 68bfacb0168e..8f56dd831402 100644 --- a/tests/admin_views/test_autocomplete_view.py +++ b/tests/admin_views/test_autocomplete_view.py @@ -461,8 +461,8 @@ def test_select(self): ) search = self.selenium.find_element(By.CSS_SELECTOR, ".select2-search__field") # Load next page of results by scrolling to the bottom of the list. - with self.select2_ajax_wait(): - for _ in range(PAGINATOR_SIZE + 1): + for _ in range(PAGINATOR_SIZE + 1): + with self.select2_ajax_wait(): search.send_keys(Keys.ARROW_DOWN) # All objects are now loaded. self.assertCountSeleniumElements( @@ -532,7 +532,9 @@ def test_select_multiple(self): with self.select2_ajax_wait(): search.send_keys(Keys.ARROW_DOWN) self.assertCountSeleniumElements( - ".select2-results__option", 31, root_element=result_container + ".select2-results__option", + PAGINATOR_SIZE + 11, + root_element=result_container, ) # Limit the results with the search field. with self.select2_ajax_wait(): @@ -540,7 +542,9 @@ def test_select_multiple(self): # Ajax request is delayed. self.assertIs(result_container.is_displayed(), True) self.assertCountSeleniumElements( - ".select2-results__option", 32, root_element=result_container + ".select2-results__option", + PAGINATOR_SIZE + 12, + root_element=result_container, ) self.assertIs(result_container.is_displayed(), True)