mirror of
https://github.com/django/django.git
synced 2025-06-03 10:39:12 +00:00
Fixed #34696 -- Updated selection counter in admin changelist on Chrome.
This commit is contained in:
parent
99bd373367
commit
f7cfa48283
@ -179,6 +179,9 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Sync counter when navigating to the page, such as through the back
|
||||||
|
// button.
|
||||||
|
window.addEventListener('pageshow', (event) => updateCounter(actionCheckboxes, options));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Call function fn when the DOM is loaded and ready. If it is already
|
// Call function fn when the DOM is loaded and ready. If it is already
|
||||||
|
@ -1741,6 +1741,41 @@ class SeleniumTests(AdminSeleniumTestCase):
|
|||||||
self.assertIs(c.get_property("checked"), True)
|
self.assertIs(c.get_property("checked"), True)
|
||||||
self.assertIs(checkboxes[-1].get_property("checked"), False)
|
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):
|
def test_select_all_across_pages(self):
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user