Preview-only documentation
" + "Release-specific review pages are generated after validation.
" + "From a60e5f57f1e2a56295c8036399a0157fee63896b Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Mon, 9 Nov 2026 19:45:09 +0000 Subject: [PATCH] fix(docs): make legacy route preview checks environment-safe Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- tests/test_seo.py | 25 ++++++++++++++++++++++++- versioning/build.py | 9 +++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/tests/test_seo.py b/tests/test_seo.py index 47975801..eb6e7717 100644 --- a/tests/test_seo.py +++ b/tests/test_seo.py @@ -55,7 +55,8 @@ def test_legacy_redirects_keep_individual_targets_across_new_stable(self): (self.site / "versions.json").write_text( json.dumps(self.catalog), encoding="utf-8") self.page("index.html", '
') - with patch("versioning.build.version_overview", return_value=self.page("index.html").read_text()): + with patch.dict("os.environ", {"LIBRESIGN_DOC_BASE_PATH": ""}), \ + patch("versioning.build.version_overview", return_value=self.page("index.html").read_text()): legacy_redirects(self.site, "15", routes={ "user_manual/index.html": "15/user_manual/index.html", "user_manual/functionality.html": "main/user_manual/functionality.html", @@ -64,6 +65,28 @@ def test_legacy_redirects_keep_individual_targets_across_new_stable(self): self.assertIn("url=/main/user_manual/functionality.html", redirect) self.assertNotIn("url=/15/user_manual/index.html", redirect) + def test_preview_legacy_routes_and_placeholder_are_not_indexable(self): + self.page("15/index.html") + self.page("main/user_manual/functionality.html") + self.page("index.html") + (self.site / "versions.json").write_text(json.dumps(self.catalog)) + prefix = "/site-preview/docs-preview/pr-7" + with patch.dict("os.environ", { + "LIBRESIGN_DOC_BASE_PATH": prefix, + "LIBRESIGN_PREVIEW_PR": "7", + }), patch("versioning.build.version_overview", + return_value=self.page("index.html").read_text()): + legacy_redirects(self.site, "15", routes={ + "user_manual/functionality.html": "main/user_manual/functionality.html", + }) + apply_seo(self.site, self.catalog, preview=True) + + redirect = (self.site / "user_manual/functionality.html").read_text() + self.assertIn(f"url={prefix}/main/user_manual/functionality.html", redirect) + self.assertEqual(verify_seo(self.site, self.catalog, preview=True), []) + self.assertIn('name="robots" content="noindex,follow"', + (self.site / "_review/index.html").read_text()) + def test_missing_redirect_destination_fails_before_deploy(self): self.page("15/index.html") (self.site / "versions.json").write_text(json.dumps(self.catalog)) diff --git a/versioning/build.py b/versioning/build.py index 27683bce..f80eb910 100644 --- a/versioning/build.py +++ b/versioning/build.py @@ -162,10 +162,11 @@ def legacy_redirects(output: Path, current: str, *, routes: dict[str, str] | Non entry = output / "_review/index.html" entry.parent.mkdir(parents=True, exist_ok=True) entry.write_text( - "" - "Release-specific review pages are generated after validation.
", + "" + "Release-specific review pages are generated after validation.
" + "