Skip to content

Commit 134cde8

Browse files
authored
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.
1 parent 9e7ac58 commit 134cde8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/admin_views/test_autocomplete_view.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,8 @@ def test_select(self):
461461
)
462462
search = self.selenium.find_element(By.CSS_SELECTOR, ".select2-search__field")
463463
# Load next page of results by scrolling to the bottom of the list.
464-
with self.select2_ajax_wait():
465-
for _ in range(PAGINATOR_SIZE + 1):
464+
for _ in range(PAGINATOR_SIZE + 1):
465+
with self.select2_ajax_wait():
466466
search.send_keys(Keys.ARROW_DOWN)
467467
# All objects are now loaded.
468468
self.assertCountSeleniumElements(
@@ -532,15 +532,19 @@ def test_select_multiple(self):
532532
with self.select2_ajax_wait():
533533
search.send_keys(Keys.ARROW_DOWN)
534534
self.assertCountSeleniumElements(
535-
".select2-results__option", 31, root_element=result_container
535+
".select2-results__option",
536+
PAGINATOR_SIZE + 11,
537+
root_element=result_container,
536538
)
537539
# Limit the results with the search field.
538540
with self.select2_ajax_wait():
539541
search.send_keys("Who")
540542
# Ajax request is delayed.
541543
self.assertIs(result_container.is_displayed(), True)
542544
self.assertCountSeleniumElements(
543-
".select2-results__option", 32, root_element=result_container
545+
".select2-results__option",
546+
PAGINATOR_SIZE + 12,
547+
root_element=result_container,
544548
)
545549
self.assertIs(result_container.is_displayed(), True)
546550

0 commit comments

Comments
 (0)