diff --git a/tests/test_site_r2_gate.py b/tests/test_site_r2_gate.py new file mode 100644 index 00000000..3a08cfa8 --- /dev/null +++ b/tests/test_site_r2_gate.py @@ -0,0 +1,273 @@ +"""Gate of the second site round, read from the built site (website/dist). + +Each package of the round was checked on its own. These checks hold the +merged site to what the round set out to fix: no sidebar label a number, no +"Next" tip, a sidebar label that is the page's own title, a card's link icon +kept out of the heading a search indexes, crumbs that lead to a tab or a +section, phone tables stacked where the reading level asks for it, and every +page under 15,000 elements and 600 KB of HTML. The integration items of the +round are held too: the platform logo beside the title, a section for every +letter of the emulators index, system links to the section of the system's +own name, dates in words and the moved getting-started page. + +Skips when the site is not built. +""" + +from __future__ import annotations + +import json +import re +import sys +import unittest +from html import unescape +from pathlib import Path + +import yaml + +REPO_ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(REPO_ROOT / "scripts")) + +DIST = REPO_ROOT / "website" / "dist" +DOCS = REPO_ROOT / "website" / "src" / "content" / "docs" +SIDEBAR = REPO_ROOT / "website" / "src" / "generated" / "sidebar.json" +BASE = "/retrobios/" + +PAGE_BYTES = 600_000 +PAGE_ELEMENTS = 15_000 +PHONE_COLUMN = 358 +READER_LEVELS = {"start", "setup"} +# The size from which a table is a list scanned by column and keeps its +# scroll (website/src/plugins/rehype-stack-tables.mjs, RECORD_ROWS). +RECORD_ROWS = 20 + +_SCRIPT = re.compile(r"<(script|style)\b[^>]*>.*?", re.S | re.I) +_ELEMENT = re.compile(r"<[a-zA-Z][a-zA-Z0-9-]*[\s/>]") +_TAGS = re.compile(r"<[^>]+>") +_TABLE = re.compile(r"[^>]*)>(?P.*?)", re.S) +_CURRENT = re.compile(r']*aria-current="page"[^>]*>(?P