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.
This commit is contained in:
Andrew Shu
2020-08-01 16:47:38 -07:00
committed by Deimos
parent 9ff86bedb7
commit 87dce83f26
7 changed files with 56 additions and 23 deletions

3
salt/salt/java.sls Normal file
View File

@@ -0,0 +1,3 @@
java-openjdk:
pkg.installed:
- name: openjdk-8-jre

View File

@@ -30,6 +30,7 @@ base:
- development
- prometheus
- nodejs
- java
'prod':
- nginx.shortener-config
- nginx.static-sites-config

View File

@@ -1,6 +1,7 @@
-r requirements.in
black
freezegun
html5validator
mypy
prospector
pyramid-debugtoolbar

View File

@@ -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

View File

@@ -12,6 +12,7 @@
.nav {
margin-left: 0;
margin-top: 0;
li {
margin-top: 0.2rem;

View File

@@ -0,0 +1,22 @@
# Copyright (c) 2020 Tildes contributors <code@tildes.net>
# 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()

View File

@@ -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>
<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 class="nav-item ml-2"><a href="/settings">Settings page</a></li>
</ul>
</li>
</ul>
{% endif %}
{% endblock %}