"""Every SVG the browser loads from `frontend/public/` must parse as XML. A browser renders an SVG used as an image only if it is well-formed XML, and when it is not, nothing reports it: no console error in most browsers, no failed build, no failed request — the icon is simply blank. `favicon.svg` shipped that way (merge #251) because its comment contained a CSS custom property name, and `--` is illegal inside an XML comment. Both the tab icon and the nav brand mark went missing, and only a person looking at the page noticed. """ from __future__ import annotations import xml.etree.ElementTree as ET from pathlib import Path import pytest PUBLIC = Path(__file__).resolve().parent.parent / "frontend" / "public" SVGS = sorted(PUBLIC.rglob("*.svg")) def test_the_public_dir_has_svgs_to_check(): """Guards the guard: a moved directory would otherwise pass vacuously.""" assert {p.name for p in SVGS} >= {"favicon.svg", "logo.svg"} @pytest.mark.parametrize("svg", SVGS, ids=lambda p: p.name) def test_svg_is_well_formed_xml(svg): root = ET.parse(svg).getroot() assert root.tag == "{http://www.w3.org/2000/svg}svg" def test_the_parser_rejects_the_shape_that_broke_the_favicon(): """Positive control: the exact defect must fail this parser, or the parametrized test above proves nothing.""" broken = ( '' "" ) with pytest.raises(ET.ParseError): ET.fromstring(broken)