|
@@ -431,17 +431,20 @@ class SeleniumTests(AdminSeleniumTestCase):
|
|
|
self.live_server_url + reverse("autocomplete_admin:admin_views_answer_add")
|
|
|
)
|
|
|
elem = self.selenium.find_element(By.CSS_SELECTOR, ".select2-selection")
|
|
|
- elem.click() # Open the autocomplete dropdown.
|
|
|
+ with self.select2_ajax_wait():
|
|
|
+ elem.click() # Open the autocomplete dropdown.
|
|
|
results = self.selenium.find_element(By.CSS_SELECTOR, ".select2-results")
|
|
|
self.assertTrue(results.is_displayed())
|
|
|
option = self.selenium.find_element(By.CSS_SELECTOR, ".select2-results__option")
|
|
|
self.assertEqual(option.text, "No results found")
|
|
|
- elem.click() # Close the autocomplete dropdown.
|
|
|
+ with self.select2_ajax_wait():
|
|
|
+ elem.click() # Close the autocomplete dropdown.
|
|
|
q1 = Question.objects.create(question="Who am I?")
|
|
|
Question.objects.bulk_create(
|
|
|
Question(question=str(i)) for i in range(PAGINATOR_SIZE + 10)
|
|
|
)
|
|
|
- elem.click() # Reopen the dropdown now that some objects exist.
|
|
|
+ with self.select2_ajax_wait():
|
|
|
+ elem.click() # Reopen the dropdown now that some objects exist.
|
|
|
result_container = self.selenium.find_element(
|
|
|
By.CSS_SELECTOR, ".select2-results"
|
|
|
)
|
|
@@ -478,7 +481,8 @@ class SeleniumTests(AdminSeleniumTestCase):
|
|
|
".select2-results__option", 1, root_element=result_container
|
|
|
)
|
|
|
# Select the result.
|
|
|
- search.send_keys(Keys.RETURN)
|
|
|
+ with self.select2_ajax_wait():
|
|
|
+ search.send_keys(Keys.RETURN)
|
|
|
select = Select(self.selenium.find_element(By.ID, "id_question"))
|
|
|
self.assertEqual(
|
|
|
select.first_selected_option.get_attribute("value"), str(q1.pk)
|
|
@@ -500,12 +504,14 @@ class SeleniumTests(AdminSeleniumTestCase):
|
|
|
self.assertTrue(results.is_displayed())
|
|
|
option = self.selenium.find_element(By.CSS_SELECTOR, ".select2-results__option")
|
|
|
self.assertEqual(option.text, "No results found")
|
|
|
- elem.click() # Close the autocomplete dropdown.
|
|
|
+ with self.select2_ajax_wait():
|
|
|
+ elem.click() # Close the autocomplete dropdown.
|
|
|
Question.objects.create(question="Who am I?")
|
|
|
Question.objects.bulk_create(
|
|
|
Question(question=str(i)) for i in range(PAGINATOR_SIZE + 10)
|
|
|
)
|
|
|
- elem.click() # Reopen the dropdown now that some objects exist.
|
|
|
+ with self.select2_ajax_wait():
|
|
|
+ elem.click() # Reopen the dropdown now that some objects exist.
|
|
|
result_container = self.selenium.find_element(
|
|
|
By.CSS_SELECTOR, ".select2-results"
|
|
|
)
|
|
@@ -536,12 +542,13 @@ class SeleniumTests(AdminSeleniumTestCase):
|
|
|
self.assertCountSeleniumElements(
|
|
|
".select2-results__option", 1, root_element=result_container
|
|
|
)
|
|
|
- # Select the result.
|
|
|
- search.send_keys(Keys.RETURN)
|
|
|
- # Reopen the dropdown and add the first result to the selection.
|
|
|
- elem.click()
|
|
|
- search.send_keys(Keys.ARROW_DOWN)
|
|
|
- search.send_keys(Keys.RETURN)
|
|
|
+ with self.select2_ajax_wait():
|
|
|
+ # Select the result.
|
|
|
+ search.send_keys(Keys.RETURN)
|
|
|
+ # Reopen the dropdown and add the first result to the selection.
|
|
|
+ elem.click()
|
|
|
+ search.send_keys(Keys.ARROW_DOWN)
|
|
|
+ search.send_keys(Keys.RETURN)
|
|
|
select = Select(self.selenium.find_element(By.ID, "id_related_questions"))
|
|
|
self.assertEqual(len(select.all_selected_options), 2)
|
|
|
|