Ensure that tests checking for th/td scope the checks to specific tables

pull/11714/head
LB Johnston 2024-03-05 07:10:00 +10:00 zatwierdzone przez sag​e
rodzic 049e7dad54
commit 269a0e4d90
2 zmienionych plików z 8 dodań i 6 usunięć

Wyświetl plik

@ -994,7 +994,7 @@ class TestHistoryView(WagtailTestUtils, TestCase):
)
response = self.client.get(self.url)
soup = self.get_soup(response.content)
rows = soup.select("tbody tr")
rows = soup.select("#listing-results tbody tr")
self.assertEqual(response.status_code, 200)
self.assertEqual(len(rows), 2)
@ -1084,7 +1084,7 @@ class TestUsageView(WagtailTestUtils, TestCase):
h1 = soup.select_one("h1")
self.assertEqual(h1.text.strip(), f"Usage: {self.object}")
tds = soup.select("tbody tr td")
tds = soup.select("#listing-results tbody tr td")
self.assertEqual(len(tds), 3)
self.assertEqual(tds[0].text.strip(), str(self.tbx))
self.assertEqual(tds[1].text.strip(), "Various on delete model")
@ -1132,7 +1132,7 @@ class TestUsageView(WagtailTestUtils, TestCase):
h1 = soup.select_one("h1")
self.assertEqual(h1.text.strip(), f"Usage: {self.object}")
tds = soup.select("tbody tr td")
tds = soup.select("#listing-results tbody tr td")
self.assertEqual(len(tds), 3)
self.assertEqual(tds[0].text.strip(), "(Private various on delete model)")
self.assertEqual(tds[1].text.strip(), "Various on delete model")
@ -1154,7 +1154,7 @@ class TestUsageView(WagtailTestUtils, TestCase):
h1 = soup.select_one("h1")
self.assertEqual(h1.text.strip(), f"Usage: {self.object}")
tds = soup.select("tbody tr td")
tds = soup.select("#listing-results tbody tr td")
self.assertEqual(len(tds), 3)
self.assertEqual(tds[0].text.strip(), str(self.tbx))
self.assertEqual(tds[1].text.strip(), "Various on delete model")

Wyświetl plik

@ -719,10 +719,12 @@ class TestListViewWithCustomColumns(BaseSnippetViewSetTests):
# One from the country code column, another from the custom foo column
self.assertContains(response, sort_country_code_url, count=2)
html = response.content.decode()
soup = self.get_soup(response.content)
headings = soup.select("#listing-results table th")
# The bulk actions column plus 6 columns defined in FullFeaturedSnippetViewSet
self.assertTagInHTML("<th>", html, count=7, allow_extra_attrs=True)
self.assertEqual(len(headings), 7)
def test_falsy_value(self):
# https://github.com/wagtail/wagtail/issues/10765