Commit cb7be838 authored by Andrew Shu's avatar Andrew Shu Committed by Deimos

Build HTML Tidy, validate homepage HTML in tests

Adds the HTML Tidy library to the dev version, along with the pytidylib
wrapper for it, and a couple of tests that use it to validate the HTML
of the home page.

Includes a fix to the GitLab "Planned features" link that Tidy considers
invalid because it includes some un-encoded characters.
parent f41bd1ea
{% set tidy_version = '5.7.28' %}
unpack-tidy:
archive.extracted:
- name: /tmp/tidy-{{ tidy_version }}
- source:
- https://github.com/htacg/tidy-html5/archive/{{ tidy_version }}.tar.gz
- source_hash: sha256=5caa2c769204f506e24ea4986a45abe23f71d14f0fe968314f20065f342ffdba
- unless: /usr/local/bin/tidy --version | grep 'version {{ tidy_version }}'
- options: --strip-components=1
- enforce_toplevel: False
install-tidy:
pkg.installed:
- pkgs:
- build-essential
cmd.run:
- cwd: /tmp/tidy-{{ tidy_version }}/build/cmake
- names:
- cmake ../.. -DCMAKE_BUILD_TYPE=Release
- make
- make install
- ldconfig
- onchanges:
- archive: unpack-tidy
......@@ -30,6 +30,7 @@ base:
- development
- prometheus
- nodejs
- tidy
'prod':
- nginx.shortener-config
- nginx.static-sites-config
......
......@@ -6,5 +6,6 @@ prospector
pyramid-debugtoolbar
pytest
pytest-mock
pytidylib
testing.redis
webtest
......@@ -81,6 +81,7 @@ pytest-mock==3.2.0
pytest==6.0.0
python-dateutil==2.8.1
python-editor==1.0.4 # via alembic
pytidylib==0.3.2
pyyaml==5.3.1
qrcode==6.1
redis==3.5.3
......
# Copyright (c) 2020 Tildes contributors <[email protected]>
# SPDX-License-Identifier: AGPL-3.0-or-later
from tidylib import tidy_document
def test_homepage_tidy_loggedout(webtest_loggedout):
"""Validate HTML5 using Tidy on the Tildes homepage, logged out."""
homepage = webtest_loggedout.get("/")
_document, errors = tidy_document(homepage.body)
assert not errors
def test_homepage_tidy_loggedin(webtest):
"""Validate HTML5 using Tidy on the Tildes homepage, logged in."""
homepage = webtest.get("/")
_document, errors = tidy_document(homepage.body)
assert not errors
......@@ -130,7 +130,7 @@
<li class="site-footer-link"><a href="https://blog.tildes.net">Blog</a></li>
<li class="site-footer-link"><a href="https://docs.tildes.net/contact">Contact</a></li>
<li class="site-footer-link"><a href="https://gitlab.com/tildes/tildes">Source code</a></li>
<li class="site-footer-link"><a href="https://gitlab.com/tildes/tildes/issues?label_name[]=Feature+Request&label_name[]=Stage%3A%3AAccepted&scope=all&sort=priority&state=opened">Planned features</a> / <a href="https://gitlab.com/tildes/tildes/issues">All issues</a></li>
<li class="site-footer-link"><a href="https://gitlab.com/tildes/tildes/issues?label_name%5B%5D=Feature+Request&amp;label_name%5B%5D=Stage%3A%3AAccepted&amp;scope=all&amp;sort=priority&amp;state=opened">Planned features</a> / <a href="https://gitlab.com/tildes/tildes/issues">All issues</a></li>
<li class="site-footer-link"><a href="https://docs.tildes.net/policies/privacy-policy">Privacy policy</a></li>
<li class="site-footer-link"><a href="https://docs.tildes.net/policies/terms-of-use">Terms of use</a></li>
</ul>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment