diff --git a/tests/test_pwa.py b/tests/test_pwa.py
index 3619080..fa2b9ee 100644
--- a/tests/test_pwa.py
+++ b/tests/test_pwa.py
@@ -2,8 +2,7 @@
The service worker caches only the shell, the manifest describes the app, and
every page links the manifest and the icon. The icon is the retro SVG of
-section 32.1, served with ``sizes: "any"``; the 192 and 512 px PNGs still need a
-rasterizer, and only the manifest and its icons entry change when they arrive.
+section 32.1, listed first, with the 192 and 512 px PNGs beside it.
"""
from http.server import ThreadingHTTPServer
@@ -63,9 +62,9 @@ class ServiceWorkerTests(unittest.TestCase):
# The quoted path is what matters: "/health-check" is a shell path, while
# "/health" and "/login" are not, and must not appear.
self.assertNotIn('\"/health\"', body)
- self.assertNotIn('\"/login\"', body)
- # The shell it does cache is the five pages, their assets, and the two
- # files the browser reads when the app is installed.
+ self.assertNotIn('"/login"', body)
+ # The shell it does cache is the five pages, their assets, and the
+ # manifest and icons the browser reads when the app is installed.
for path in (
"/",
"/setup",
@@ -75,6 +74,8 @@ class ServiceWorkerTests(unittest.TestCase):
"/styles.css",
"/manifest.webmanifest",
"/icon.svg",
+ "/icon-192.png",
+ "/icon-512.png",
):
self.assertIn(f'"{path}"', body)
@@ -105,11 +106,12 @@ class ServiceWorkerTests(unittest.TestCase):
class IconTests(unittest.TestCase):
- """The favicon and the top-bar brand mark (section 32.1).
+ """The favicon, the top-bar brand mark, and the two raster icons (32.1).
Every page links the icon, and the brand mark is the icon image itself. The
class name ``brand-mark`` is kept, because the stylesheet styles it by that
- name.
+ name. The PNGs are rasterized from the package icon at the repository root,
+ so the two SVG files have to carry the same drawing.
"""
PAGES = (
@@ -123,10 +125,18 @@ class IconTests(unittest.TestCase):
ICON_LINK = ''
BRAND_MARK = ''
LETTER_MARK = 'V'
+ PNG_SIGNATURE = b"\x89PNG\r\n\x1a\n"
def read_static(self, filename):
return (ROOT / "static" / filename).read_text(encoding="utf-8")
+ def png_size(self, filename):
+ """Return the width and height a PNG file declares in its IHDR chunk."""
+ data = (ROOT / "static" / filename).read_bytes()
+ self.assertEqual(data[:8], self.PNG_SIGNATURE, filename)
+ self.assertEqual(data[12:16], b"IHDR", filename)
+ return int.from_bytes(data[16:20], "big"), int.from_bytes(data[20:24], "big")
+
def test_every_page_links_the_icon(self):
# The favicon is the same retro drawing as the manifest icon, and every
# page links it, including the login page, which links no manifest
@@ -160,9 +170,26 @@ class IconTests(unittest.TestCase):
self.assertIn("flex-direction: column", styles)
self.assertIn("main { flex: 1 1 auto; }", styles)
+ def test_the_served_icon_carries_the_same_drawing_as_the_package_icon(self):
+ # The package icon at the repository root is the source of truth, and the
+ # file the PWA serves is the same drawing. Only the leading comment may
+ # differ, so the comparison starts at the root