| 1 | """Tests for site icon metadata.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import json |
| 6 | from pathlib import Path |
| 7 | |
| 8 | REPO_ROOT = Path(__file__).resolve().parent.parent |
| 9 | |
| 10 | |
| 11 | def test_head_favicons_use_claracle_image_asset() -> None: |
| 12 | """Head template must derive browser icons from the Claracle image asset.""" |
| 13 | head = (REPO_ROOT / "layouts" / "partials" / "head.html").read_text(encoding="utf-8") |
| 14 | assert 'resources.Get "images/claracle.jpeg"' in head |
| 15 | assert '.Fill "16x16 png"' in head |
| 16 | assert '.Fill "32x32 png"' in head |
| 17 | assert '.Fill "180x180 png"' in head |
| 18 | assert "/images/squadscope-icon.svg" not in head |
| 19 | assert "/favicon-16x16.png" not in head |
| 20 | assert "/favicon-32x32.png" not in head |
| 21 | assert "/apple-touch-icon.png" not in head |
| 22 | |
| 23 | |
| 24 | def test_web_manifest_uses_claracle_image_icon() -> None: |
| 25 | """Web app manifest must point at compatible PNG site icons.""" |
| 26 | manifest = json.loads((REPO_ROOT / "static" / "site.webmanifest").read_text(encoding="utf-8")) |
| 27 | icons = manifest["icons"] |
| 28 | assert icons == [ |
| 29 | {"src": "/android-chrome-192x192.png", "sizes": "192x192", "type": "image/png"}, |
| 30 | { |
| 31 | "src": "/android-chrome-512x512.png", |
| 32 | "sizes": "512x512", |
| 33 | "type": "image/png", |
| 34 | "purpose": "any maskable", |
| 35 | }, |
| 36 | ] |
| 37 | |
| 38 | |
| 39 | def test_static_icon_png_files_exist() -> None: |
| 40 | """All browser and app icon files must exist as PNG files.""" |
| 41 | for icon_path in ( |
| 42 | "favicon-16x16.png", |
| 43 | "favicon-32x32.png", |
| 44 | "apple-touch-icon.png", |
| 45 | "android-chrome-192x192.png", |
| 46 | "android-chrome-512x512.png", |
| 47 | ): |
| 48 | icon = REPO_ROOT / "static" / icon_path |
| 49 | assert icon.is_file() |
| 50 | assert icon.read_bytes().startswith(b"\x89PNG\r\n\x1a\n") |