feat: pwa

This commit is contained in:
2026-07-14 20:23:48 +02:00
parent 4040b4fdd9
commit 9a795dc3c9
10 changed files with 178 additions and 0 deletions
+22
View File
@@ -229,3 +229,25 @@ class TodayPageTests(TrackerTestCase):
response = self.client.get(reverse("tracker:today"))
self.assertContains(response, "<polyline")
self.assertContains(response, "180.0 bpm") # average
class PwaTests(TrackerTestCase):
def test_the_service_worker_is_served_from_the_root(self):
# Scope: under /static/ it could not control the /admin/ pages it caches.
response = self.client.get("/sw.js")
self.assertEqual(response.status_code, 200)
self.assertEqual(response["Content-Type"], "application/javascript")
def test_the_page_links_the_manifest_and_registers_the_worker(self):
self.client.force_login(self.user)
response = self.client.get(reverse("tracker:today"))
self.assertContains(response, 'rel="manifest"')
self.assertContains(response, "serviceWorker.register")
def test_the_login_page_is_installable_too(self):
# The app opens on the login screen when the session lapses.
response = self.client.get("/admin/login/")
self.assertContains(response, 'rel="manifest"')