Repository: wagtail/wagtail
File: wagtail/admin/tests/test_dashboard.py (Python)

Code before:

        with self.assertNumQueries(13):
            html = panel.render_html(parent_context)

        soup = self.get_soup(html)
        self.assertEqual(len(soup.select('svg use[href="#icon-lock"]')), 2)
        expected_titles = [
            "Some obj 2",
            "Some obj 1",
            "Saint Patrick (single event)",
            "Christmas",
            "Steal underpants",
            "Ameristralia Day",
        ]
        titles = [e.get_text(strip=True) for e in soup.select(".title-wrapper a")]
        self.assertEqual(titles, expected_titles)


class CommonAdminBaseTemplate(WagtailTestUtils, TestCase):
    def setUp(self):
        self.superuser = self.create_superuser(username="admin", password="password")
        self.client.login(username="admin", password="password")
        self.dummy_request = get_dummy_request()
        self.dummy_request.user = self.superuser

        profile, created = UserProfile.objects.get_or_create(user=self.superuser)
        profile.theme = "dark"
        profile.save()

    def test_common_admin_base_template(self):
        response = self.client.get(reverse("wagtailadmin_home"))
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, "wagtailadmin/skeleton.html")
        self.assertTemplateUsed(response, "wagtailadmin/admin_base.html")

    def test_meta_color_scheme(self):
        """
        Testing meta color scheme tag
        """
        response = self.client.get(reverse("wagtailadmin_home"))
        self.assertEqual(response.status_code, 200)
        soup = self.get_soup(response.content)
        meta_tag = soup.find("meta", attrs={"name": "color-scheme"})

        self.assertIsNotNone(meta_tag, "Meta color-scheme tag is missing")
        self.assertEqual(
            meta_tag["content"], "dark", "Meta color-scheme content is incorrect"
        )


Review comment (suggestion):
```suggestion
        profile = UserProfile.get_for_user(self.superuser)
```

Code after:

        with self.assertNumQueries(13):
            html = panel.render_html(parent_context)

        soup = self.get_soup(html)
        self.assertEqual(len(soup.select('svg use[href="#icon-lock"]')), 2)
        expected_titles = [
            "Some obj 2",
            "Some obj 1",
            "Saint Patrick (single event)",
            "Christmas",
            "Steal underpants",
            "Ameristralia Day",
        ]
        titles = [e.get_text(strip=True) for e in soup.select(".title-wrapper a")]
        self.assertEqual(titles, expected_titles)


class CommonAdminBaseTemplate(WagtailTestUtils, TestCase):
    def setUp(self):
        self.user = self.login()

    def test_common_admin_base_template(self):
        response = self.client.get(reverse("wagtailadmin_home"))
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, "wagtailadmin/skeleton.html")
        self.assertTemplateUsed(response, "wagtailadmin/admin_base.html")

    def test_meta_color_scheme(self):
        profile = UserProfile.get_for_user(self.user)
        profile.theme = "dark"
        profile.save()

        response = self.client.get(reverse("wagtailadmin_home"))
        self.assertEqual(response.status_code, 200)
        soup = self.get_soup(response.content)
        meta_tag = soup.find("meta", attrs={"name": "color-scheme"})

        self.assertIsNotNone(meta_tag)
        self.assertEqual(meta_tag["content"], "dark")