Commit 87dce83f authored by Andrew Shu's avatar Andrew Shu Committed by Deimos

Install html5validator, validate HTML in tests

Installs the Nu Html Checker and starts using it to validate the home
page's HTML: https://validator.github.io/validator/

Also includes fixes to some lists that were nested in an invalid way.
parent 9ff86bed
java-openjdk:
pkg.installed:
- name: openjdk-8-jre
......@@ -30,6 +30,7 @@ base:
- development
- prometheus
- nodejs
- java
'prod':
- nginx.shortener-config
- nginx.static-sites-config
......
-r requirements.in
black
freezegun
html5validator
mypy
prospector
pyramid-debugtoolbar
......
......@@ -21,6 +21,7 @@ flake8==3.8.3 # via flake8-polyfill
freezegun==0.3.15
gunicorn==20.0.4
html5lib==1.1
html5validator==0.3.3
hupper==1.10.2 # via pyramid
idna==2.10 # via requests
iniconfig==1.0.0 # via pytest
......
......@@ -12,6 +12,7 @@
.nav {
margin-left: 0;
margin-top: 0;
li {
margin-top: 0.2rem;
......
# Copyright (c) 2020 Tildes contributors <[email protected]>
# SPDX-License-Identifier: AGPL-3.0-or-later
import subprocess
def test_homepage_html_loggedout(webtest_loggedout):
"""Validate HTML5 on the Tildes homepage, logged out."""
homepage = webtest_loggedout.get("/")
_run_html5validator(homepage.body)
def test_homepage_html_loggedin(webtest):
"""Validate HTML5 on the Tildes homepage, logged in."""
homepage = webtest.get("/")
_run_html5validator(homepage.body)
def _run_html5validator(html):
"""Raises CalledProcessError on validation error."""
result = subprocess.run(["html5validator", "-"], input=html)
result.check_returncode()
......@@ -55,11 +55,13 @@
<li>Groups</li>
{% endif %}
<ul class="nav nav-group-list">
{% for group in groups|sort %}
<li class="nav-item">{{ link_to_group(group) }}</li>
{% endfor %}
</ul>
<li>
<ul class="nav nav-group-list">
{% for group in groups|sort %}
<li class="nav-item">{{ link_to_group(group) }}</li>
{% endfor %}
</ul>
</li>
</ul>
<a href="/groups" class="btn btn-primary">Browse the list of groups</a>
{% endif %}
......@@ -70,25 +72,27 @@
<ul class="nav">
<li>User settings</li>
<ul class="nav">
{% if not unfiltered %}
<li><details>
<summary>Filtered topic tags ({{ request.user.filtered_topic_tags|length }})</summary>
<ul class="topic-tags">
{% for tag in request.user.filtered_topic_tags %}
<li class="label label-topic-tag">
<a href="/?tag={{tag}}">{{ tag }}</a>
</li>
{% else %}
<li class="label label-topic-tag">No filtered tags</li>
{% endfor %}
</ul>
<a class="btn btn-link" href="/settings/filters">Edit filtered tags</a>
</details></li>
{% endif %}
<li class="nav-item ml-2"><a href="/settings">Settings page</a></li>
</ul>
<li>
<ul class="nav">
{% if not unfiltered %}
<li><details>
<summary>Filtered topic tags ({{ request.user.filtered_topic_tags|length }})</summary>
<ul class="topic-tags">
{% for tag in request.user.filtered_topic_tags %}
<li class="label label-topic-tag">
<a href="/?tag={{tag}}">{{ tag }}</a>
</li>
{% else %}
<li class="label label-topic-tag">No filtered tags</li>
{% endfor %}
</ul>
<a class="btn btn-link" href="/settings/filters">Edit filtered tags</a>
</details></li>
{% endif %}
<li class="nav-item ml-2"><a href="/settings">Settings page</a></li>
</ul>
</li>
</ul>
{% endif %}
{% endblock %}
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