Skip to content

Commit

Permalink
Removed hard-coded expected results in SeleniumTests.test_select_mult…
Browse files Browse the repository at this point in the history
…iple 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.
  • Loading branch information
nessita authored Nov 28, 2023
1 parent 9e7ac58 commit 134cde8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/admin_views/test_autocomplete_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -532,15 +532,19 @@ 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():
search.send_keys("Who")
# 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)

Expand Down

0 comments on commit 134cde8

Please sign in to comment.