diff options
| author | Cauê Thenório <caue@thenorio.com.br> | 2023-07-07 10:58:07 -0300 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-07-10 10:09:07 +0200 |
| commit | f7cfa48283c94018861688f17ab3935d588fbcc3 (patch) | |
| tree | 63b32dcc1da8cae23de4635b8ca8b947b7e7f3db /tests/admin_changelist | |
| parent | 99bd373367e54790da25b64c1d21610ac0f9feda (diff) | |
Fixed #34696 -- Updated selection counter in admin changelist on Chrome.
Diffstat (limited to 'tests/admin_changelist')
| -rw-r--r-- | tests/admin_changelist/tests.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py index 8fdd343b18..a926f9d826 100644 --- a/tests/admin_changelist/tests.py +++ b/tests/admin_changelist/tests.py @@ -1741,6 +1741,41 @@ class SeleniumTests(AdminSeleniumTestCase): self.assertIs(c.get_property("checked"), True) self.assertIs(checkboxes[-1].get_property("checked"), False) + def test_selection_counter_is_synced_when_page_is_shown(self): + from selenium.webdriver.common.by import By + + self.admin_login(username="super", password="secret") + self.selenium.get(self.live_server_url + reverse("admin:auth_user_changelist")) + + form_id = "#changelist-form" + first_row_checkbox_selector = ( + f"{form_id} #result_list tbody tr:first-child .action-select" + ) + selection_indicator_selector = f"{form_id} .action-counter" + selection_indicator = self.selenium.find_element( + By.CSS_SELECTOR, selection_indicator_selector + ) + row_checkbox = self.selenium.find_element( + By.CSS_SELECTOR, first_row_checkbox_selector + ) + # Select a row. + row_checkbox.click() + self.assertEqual(selection_indicator.text, "1 of 1 selected") + # Go to another page and get back. + self.selenium.get( + self.live_server_url + reverse("admin:admin_changelist_parent_changelist") + ) + self.selenium.back() + # The selection indicator is synced with the selected checkboxes. + selection_indicator = self.selenium.find_element( + By.CSS_SELECTOR, selection_indicator_selector + ) + row_checkbox = self.selenium.find_element( + By.CSS_SELECTOR, first_row_checkbox_selector + ) + selected_rows = 1 if row_checkbox.is_selected() else 0 + self.assertEqual(selection_indicator.text, f"{selected_rows} of 1 selected") + def test_select_all_across_pages(self): from selenium.webdriver.common.by import By |
