From a7cdd9f0de344d891e0f282e11c244a469491db7 Mon Sep 17 00:00:00 2001 From: ai-bot Date: Wed, 14 Oct 2026 12:48:20 +0000 Subject: [PATCH] BR-007: regression test for the shell cache guard --- tests/test_pwa.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_pwa.py b/tests/test_pwa.py index 2603af9..523b72f 100644 --- a/tests/test_pwa.py +++ b/tests/test_pwa.py @@ -77,6 +77,18 @@ class ServiceWorkerTests(unittest.TestCase): ): self.assertIn(f'"{path}"', body) + def test_the_service_worker_only_stores_a_successful_same_origin_answer(self): + # A page fetched without a session answers 302 -> /login, and fetch + # follows it, so the login page would replace the cached shell unless the + # stored answer is checked first. The worker stores a response only when + # it is successful, same-origin and not redirected (section 31 point 6). + body = self.read_static("sw.js") + + self.assertIn("isCacheable", body) + self.assertIn("response.ok", body) + self.assertIn("response.type", body) + self.assertIn("!response.redirected", body) + def test_the_dashboard_registers_the_service_worker(self): body = self.read_static("app.js")