diff --git a/phpbb-test-board/feature_checks.py b/phpbb-test-board/feature_checks.py index 4385416..46a7b51 100755 --- a/phpbb-test-board/feature_checks.py +++ b/phpbb-test-board/feature_checks.py @@ -11,6 +11,7 @@ Exit status: 0 if every check passed, 1 if any failed, 2 for bad arguments. """ import argparse +import json import re import secrets import shutil @@ -138,6 +139,10 @@ def check_documentation(b: Board) -> None: ok(False, "docs build path is configured") return build = b.root / rows[0][0] + # store/ isn't reset between runs the way ext/ is, so start from an + # empty build rather than whatever an earlier run left there. + if build.resolve().is_relative_to(b.root.resolve()): + shutil.rmtree(build, ignore_errors=True) for sub, marker in (("en", "PROBE-DOCS-HOME"), ("en/userguide", "PROBE-DOCS-SECTION")): (build / sub).mkdir(parents=True, exist_ok=True) (build / sub / "index.html").write_text( @@ -155,6 +160,18 @@ def check_documentation(b: Board) -> None: ok(r.status_code == 200 and "PROBE-DOCS-HOME" in r.text, f"guest can read the docs home ({r.status_code})") r = g.get(f"{b.base}/app.php/documentation/en/userguide") ok(r.status_code == 200 and "PROBE-DOCS-SECTION" in r.text, f"guest can read a section page ({r.status_code})") + # Versions with a server-side search fallback answer a search without + # JavaScript from /
/search-index.json. + helper = b.root / "ext/phpbbmodders/documentation/controller/documentation_helper.php" + if "SEARCH_INDEX_FILE" in helper.read_text(encoding="utf-8"): + (build / "en/userguide/search-index.json").write_text(json.dumps( + [{"url": "/en/userguide/", "title": "PROBE-SEARCH-TITLE", "text": "probe searchable words"}])) + r = g.get(f"{b.base}/app.php/documentation-search/en", params={"q": "searchable words"}) + ok(r.status_code == 200 and "PROBE-SEARCH-TITLE" in r.text and "documentation/en/userguide" in r.text, + f"search without JavaScript returns server results ({r.status_code})") + r = g.get(f"{b.base}/app.php/documentation-search/en", params={"q": "nothing matches this"}) + ok(r.status_code == 200 and "PROBE-SEARCH-TITLE" not in r.text and 'role="status"' in r.text, + f"search without JavaScript reports no results ({r.status_code})") # A guest who loses access gets the login form rather than a bare 403. b.sql("DELETE FROM phpbb_acl_groups " "WHERE group_id = (SELECT group_id FROM phpbb_groups WHERE group_name = 'GUESTS') "