Browse Source

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.
merge-requests/126/merge
Andrew Shu 4 years ago
committed by Deimos
parent
commit
87dce83f26
  1. 3
      salt/salt/java.sls
  2. 1
      salt/salt/top.sls
  3. 1
      tildes/requirements-dev.in
  4. 1
      tildes/requirements-dev.txt
  5. 1
      tildes/scss/modules/_nav.scss
  6. 22
      tildes/tests/webtests/test_w3_validator.py
  7. 4
      tildes/tildes/templates/home.jinja2

3
salt/salt/java.sls

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

1
salt/salt/top.sls

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

1
tildes/requirements-dev.in

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

1
tildes/requirements-dev.txt

@ -21,6 +21,7 @@ flake8==3.8.3 # via flake8-polyfill
freezegun==0.3.15 freezegun==0.3.15
gunicorn==20.0.4 gunicorn==20.0.4
html5lib==1.1 html5lib==1.1
html5validator==0.3.3
hupper==1.10.2 # via pyramid hupper==1.10.2 # via pyramid
idna==2.10 # via requests idna==2.10 # via requests
iniconfig==1.0.0 # via pytest iniconfig==1.0.0 # via pytest

1
tildes/scss/modules/_nav.scss

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

22
tildes/tests/webtests/test_w3_validator.py

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

4
tildes/tildes/templates/home.jinja2

@ -55,11 +55,13 @@
<li>Groups</li> <li>Groups</li>
{% endif %} {% endif %}
<li>
<ul class="nav nav-group-list"> <ul class="nav nav-group-list">
{% for group in groups|sort %} {% for group in groups|sort %}
<li class="nav-item">{{ link_to_group(group) }}</li> <li class="nav-item">{{ link_to_group(group) }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
</li>
</ul> </ul>
<a href="/groups" class="btn btn-primary">Browse the list of groups</a> <a href="/groups" class="btn btn-primary">Browse the list of groups</a>
{% endif %} {% endif %}
@ -70,6 +72,7 @@
<ul class="nav"> <ul class="nav">
<li>User settings</li> <li>User settings</li>
<li>
<ul class="nav"> <ul class="nav">
{% if not unfiltered %} {% if not unfiltered %}
<li><details> <li><details>
@ -89,6 +92,7 @@
<li class="nav-item ml-2"><a href="/settings">Settings page</a></li> <li class="nav-item ml-2"><a href="/settings">Settings page</a></li>
</ul> </ul>
</li>
</ul> </ul>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
Loading…
Cancel
Save