Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions tests/admin_changelist/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2046,6 +2046,17 @@ class PlaywrightTests(AdminPlaywrightTestCase):
def setUp(self):
User.objects.create_superuser(username="super", password="secret", email=None)

def collapse_filter(self, detail):
"""Collapse a filter and wait for its state to be stored."""
title = detail.get_attribute("data-filter-title")
detail.locator("summary").click()
self.expect(detail).not_to_have_attribute("open")
self.page.wait_for_function(
"title => JSON.parse(sessionStorage.getItem("
"'django.admin.filtersState'))?.[title] === false",
arg=title,
)

def test_add_row_selection(self):
"""
The status line for selected rows gets updated correctly (#22038).
Expand Down Expand Up @@ -2254,8 +2265,7 @@ def test_collapse_filters(self):
self.expect(detail).to_have_attribute("open")
# Collapse "staff' and "superuser" filters.
for detail in details[:2]:
detail.locator("summary").click()
self.expect(detail).not_to_have_attribute("open")
self.collapse_filter(detail)
# Filters are in the same state after refresh.
self.page.reload()
self.expect(
Expand All @@ -2271,7 +2281,8 @@ def test_collapse_filters(self):
self.page.goto(
self.live_server_url + reverse("admin:admin_changelist_band_changelist")
)
self.page.locator("summary").click()
detail = self.page.locator("[data-filter-title='number of members']")
self.collapse_filter(detail)
# Go to Users view and then, back again to Bands view.
self.page.goto(self.live_server_url + reverse("admin:auth_user_changelist"))
self.page.goto(
Expand All @@ -2288,8 +2299,7 @@ def test_collapse_filter_with_unescaped_title(self):
self.page.goto(self.live_server_url + changelist_url)
# Title is escaped.
filter_title = self.page.locator("[data-filter-title='It\\'s OK']")
filter_title.locator("summary").click()
self.expect(filter_title).not_to_have_attribute("open")
self.collapse_filter(filter_title)
# Filter is in the same state after refresh.
self.page.reload()
self.expect(
Expand Down
Loading