diff options
| author | Yuriy Andamasov <yuriy@vyos.io> | 2026-07-10 17:08:59 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-10 17:08:59 +0300 |
| commit | aba8877795899edb51482a986619b2735f39543f (patch) | |
| tree | c46a2f1e859089f20bcf7f7b09eea7330cb9139d /tools/test_scrub.py | |
| parent | ab2a80041cc389013158fd3f6152bfb479e31b6d (diff) | |
| parent | 9b6c5d1ecc2eddd44db0beb556711a8be8f65f73 (diff) | |
| download | vyos-docs-legacy-snapshot-production.tar.gz vyos-docs-legacy-snapshot-production.zip | |
Merge pull request #1 from vyos/claude/legacy-snapshot-phase4HEADproduction
docs: legacy 1.2/1.3 static snapshot + Worker deploy pipeline
Diffstat (limited to 'tools/test_scrub.py')
| -rw-r--r-- | tools/test_scrub.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tools/test_scrub.py b/tools/test_scrub.py new file mode 100644 index 0000000..690fe86 --- /dev/null +++ b/tools/test_scrub.py @@ -0,0 +1,46 @@ +from tools import scrub + +RTD_HTML = """<html><head> +<script async src="https://assets.readthedocs.org/static/javascript/readthedocs-addons.js"></script> +<link rel="stylesheet" href="https://docs.vyos.io/en/1.3/_static/css/theme.css"/> +<script>READTHEDOCS_DATA = {"project": "vyos"};</script> +</head><body> +<div id="rtd-footer-container"></div> +<p>content</p> +</body></html>""" + + +def test_strips_rtd_platform_js_and_containers(): + out = scrub.scrub_html(RTD_HTML, slug="1.3") + assert "readthedocs-addons" not in out + assert "READTHEDOCS_DATA" not in out + assert "rtd-footer-container" not in out + assert "<p>content</p>" in out + + +def test_strips_analytics_ads_and_flyout(tmp_path=None): + html = """<html><head> + <script async src="https://www.googletagmanager.com/gtag/js?id=G-X"></script> + <script>gtag('config', 'G-X');</script> + <script src="https://media.ethicalads.io/media/client/ethicalads.min.js"></script> + </head><body> + <div id="ethical-ad-placement"></div> + <div class="rst-versions" data-toggle="rst-versions">flyout</div> + <p>keep</p></body></html>""" + out = scrub.scrub_html(html, slug="1.2") + assert "googletagmanager" not in out + assert "gtag(" not in out + assert "ethicalads" not in out and "ethical-ad-placement" not in out + assert "rst-versions" not in out + assert "<p>keep</p>" in out + + +def test_rewrites_absolute_self_urls_to_relative(): + out = scrub.scrub_html(RTD_HTML, slug="1.3") + assert 'href="/en/1.3/_static/css/theme.css"' in out + + +def test_injects_picker_bundle_once(): + out = scrub.scrub_html(RTD_HTML, slug="1.3") + assert out.count('js/version-picker.js') == 1 + assert 'id="vyos-version-picker"' in out |
