Skip to content

Commit 3234f1a

Browse files
authored
test: Validate HTML rendered during tests (ietf-tools#3782)
1 parent db254f7 commit 3234f1a

333 files changed

Lines changed: 4148 additions & 4303 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,38 @@
44

55
root = true
66

7-
# Settings for IETF datatracker
7+
# Global settings for IETF datatracker
88
# ---------------------------------------------------------
99
# PEP8 Style
1010

1111
[*]
12-
indent_style = space
1312
indent_size = 4
14-
end_of_line = lf
1513
charset = utf-8
16-
# to avoid tripping Henrik's commit hook:
17-
trim_trailing_whitespace = false
18-
insert_final_newline = false
14+
trim_trailing_whitespace = true
15+
insert_final_newline = true
16+
17+
# Specializations below *add to* the above defaults
1918

2019
# Settings for .github folder
2120
# ---------------------------------------------------------
2221
# GitHub Markdown Style
2322

2423
[.github/**]
25-
indent_style = space
2624
indent_size = 2
27-
end_of_line = lf
28-
charset = utf-8
29-
trim_trailing_whitespace = false
30-
insert_final_newline = true
3125

3226
# Settings for client-side JS / Vue files
3327
# ---------------------------------------------------------
3428
# StandardJS Style
3529

3630
[client/**]
37-
indent_style = space
3831
indent_size = 2
39-
end_of_line = lf
40-
charset = utf-8
41-
trim_trailing_whitespace = true
42-
insert_final_newline = true
4332

4433
[package.json]
45-
indent_style = space
4634
indent_size = 2
47-
end_of_line = lf
48-
charset = utf-8
49-
trim_trailing_whitespace = true
50-
insert_final_newline = true
5135

5236
# Settings for cypress tests
5337
# ---------------------------------------------------------
5438
# StandardJS Style
5539

5640
[cypress/**]
57-
indent_style = space
5841
indent_size = 2
59-
end_of_line = lf
60-
charset = utf-8
61-
trim_trailing_whitespace = true
62-
insert_final_newline = true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
*.#*
1515
.*.swp
1616
.DS_store
17+
datatracker.sublime-project
18+
datatracker.sublime-workspace
1719
# Simulated Subversion default ignores end here
1820
/.coverage
1921
/.factoryboy_random_state

dev/tests/Dockerfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ RUN apt-get install -qy \
2424
build-essential \
2525
curl \
2626
docker-ce-cli \
27-
default-jdk \
2827
enscript \
2928
gawk \
3029
gcc \
@@ -46,7 +45,6 @@ RUN apt-get install -qy \
4645
libxtst6 \
4746
libmagic-dev \
4847
libmariadb-dev \
49-
libtidy-dev \
5048
locales \
5149
mariadb-client \
5250
netcat \
@@ -109,9 +107,6 @@ RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requ
109107
# Turn off rsyslog kernel logging (doesn't work in Docker)
110108
RUN sed -i '/imklog/s/^/#/' /etc/rsyslog.conf
111109

112-
# Install the Nu Html Checker (v.Nu)
113-
ADD https://github.com/validator/validator/releases/download/latest/vnu.jar /
114-
115110
# Fetch wait-for utility
116111
ADD https://raw.githubusercontent.com/eficode/wait-for/v2.1.3/wait-for /usr/local/bin/
117112
RUN chmod +rx /usr/local/bin/wait-for

docker/app.Dockerfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ RUN apt-get install -qy \
3131
bash \
3232
build-essential \
3333
curl \
34-
default-jdk \
3534
docker-ce-cli \
3635
enscript \
3736
fish \
@@ -56,7 +55,6 @@ RUN apt-get install -qy \
5655
libmagic-dev \
5756
libmariadb-dev \
5857
libmemcached-tools \
59-
libtidy-dev \
6058
locales \
6159
mariadb-client \
6260
memcached \
@@ -125,9 +123,6 @@ RUN sed -i '/imklog/s/^/#/' /etc/rsyslog.conf
125123
# Colorize the bash shell
126124
RUN sed -i 's/#force_color_prompt=/force_color_prompt=/' /root/.bashrc
127125

128-
# Install the Nu Html Checker (v.Nu)
129-
ADD https://github.com/validator/validator/releases/download/latest/vnu.jar /
130-
131126
ADD https://raw.githubusercontent.com/eficode/wait-for/v2.1.3/wait-for /usr/local/bin/
132127
RUN chmod +rx /usr/local/bin/wait-for
133128

ietf/dbtemplate/templates/dbtemplate/template_show.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ <h2>Meta information</h2>
3333

3434
<h2>Template content</h2>
3535

36-
<div class = "card">
37-
<p class='pasted'>{{ template.content }}</p>
36+
<div class="card">
37+
<p class="pasted">{{ template.content }}</p>
3838
</div>
3939

40-
{% endblock %}
40+
{% endblock %}

ietf/doc/templatetags/ballot_icon.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,15 @@ def sort_key(t):
109109
else:
110110
typename = "IESG"
111111

112-
res = ['<a %s href="%s" data-bs-toggle="modal" data-bs-target="#modal-%d" title="%s positions (click to show more)" class="ballot-icon"><table' % (
112+
res = ['<a %s href="%s" data-bs-toggle="modal" data-bs-target="#modal-%d" aria-label="%s positions" title="%s positions (click to show more)" class="ballot-icon"><table' % (
113113
right_click_string,
114114
urlreverse("ietf.doc.views_doc.ballot_popup", kwargs=dict(name=doc.name, ballot_id=ballot.pk)),
115115
ballot.pk,
116+
typename,
116117
typename,)]
117118
if my_blocking:
118119
res.append(' class="is-blocking" ')
119-
res.append('>')
120+
res.append('><tbody>')
120121

121122
res.append("<tr>")
122123

@@ -137,7 +138,7 @@ def sort_key(t):
137138
res.append('<td class="position-empty"></td>')
138139
i = i + 1
139140

140-
res.append("</tr></table></a>")
141+
res.append("</tr></tbody></table></a>")
141142
res.append('<div id="modal-%d" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-dialog modal-dialog-scrollable modal-xl"><div class="modal-content"></div></div></div>' % ballot.pk)
142143

143144
return mark_safe("".join(res))

ietf/doc/templatetags/ietf_filters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,13 @@ def format_snippet(text, trunc_words=25):
413413
full = keep_spacing(collapsebr(linebreaksbr(mark_safe(sanitize_fragment(text)))))
414414
snippet = truncatewords_html(full, trunc_words)
415415
if snippet != full:
416-
return mark_safe('<div class="snippet">%s<button class="btn btn-sm btn-primary show-all"><i class="bi bi-caret-down"></i></button></div><div class="visually-hidden full">%s</div>' % (snippet, full))
416+
return mark_safe('<div class="snippet">%s<button type="button" aria-label="Expand" class="btn btn-sm btn-primary show-all"><i class="bi bi-caret-down"></i></button></div><div class="visually-hidden full">%s</div>' % (snippet, full))
417417
return mark_safe(full)
418418

419419
@register.simple_tag
420420
def doc_edit_button(url_name, *args, **kwargs):
421421
"""Given URL name/args/kwargs, looks up the URL just like "url" tag and returns a properly formatted button for the document material tables."""
422-
return mark_safe('<a class="btn btn-primary btn-sm" role="button" href="%s">Edit</a>' % (urlreverse(url_name, args=args, kwargs=kwargs)))
422+
return mark_safe('<a class="btn btn-primary btn-sm" type="button" href="%s">Edit</a>' % (urlreverse(url_name, args=args, kwargs=kwargs)))
423423

424424
@register.filter
425425
def textify(text):

ietf/doc/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ def test_document_ballot_popup_unique_anchors_per_doc(self):
15951595
href = q(f'div.balloter-name a[href$="{author_slug}"]').attr('href')
15961596
ids = [
15971597
target.attr('id')
1598-
for target in q(f'h5[id$="{author_slug}"]').items()
1598+
for target in q(f'p.h5[id$="{author_slug}"]').items()
15991599
]
16001600
self.assertEqual(len(ids), 1, 'Should be exactly one link for the balloter')
16011601
self.assertEqual(href, f'#{ids[0]}', 'Anchor href should match ID')

ietf/doc/tests_ballot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,9 +1196,9 @@ def test_ballotpositiondocevent_any_email_sent(self):
11961196
)
11971197

11981198
def _assertBallotMessage(self, q, balloter, expected):
1199-
heading = q(f'h5[id$="_{slugify(balloter.plain_name())}"]')
1199+
heading = q(f'p.h5[id$="_{slugify(balloter.plain_name())}"]')
12001200
self.assertEqual(len(heading), 1)
1201-
# <h5/> is followed by a panel with the message of interest, so use next()
1201+
# <p.h5/> is followed by a panel with the message of interest, so use next()
12021202
self.assertEqual(
12031203
len(heading.next().find(
12041204
f'*[title="{expected}"]'
@@ -1379,4 +1379,4 @@ def test_document_ballot_content_without_send_email_values(self):
13791379
q = PyQuery(content)
13801380
self._assertBallotMessage(q, balloters[0], 'No email send requests for this discuss')
13811381
self._assertBallotMessage(q, balloters[1], 'No ballot position send log available')
1382-
self._assertBallotMessage(q, old_balloter, 'No ballot position send log available')
1382+
self._assertBallotMessage(q, old_balloter, 'No ballot position send log available')

ietf/doc/tests_draft.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def test_change_state(self):
106106
self.assertEqual(len(q('form select[name=state]')), 1)
107107

108108
if next_states:
109-
self.assertEqual(len(q('[type=submit][value="%s"]' % next_states[0].name)), 1)
109+
self.assertEqual(len(q('[type=submit]:contains("%s")' % next_states[0].name)), 1)
110110

111111

112112
# faulty post
@@ -148,7 +148,7 @@ def test_change_state(self):
148148
r = self.client.get(url)
149149
self.assertEqual(r.status_code, 200)
150150
q = PyQuery(r.content)
151-
self.assertEqual(len(q('form [type=submit][value="%s"]' % first_state.name)), 1)
151+
self.assertEqual(len(q('form [type=submit]:contains("%s")' % first_state.name)), 1)
152152

153153
def test_pull_from_rfc_queue(self):
154154
ad = Person.objects.get(user__username="ad")
@@ -1383,7 +1383,7 @@ def verify_can_see(username):
13831383
r = self.client.get(url)
13841384
self.assertEqual(r.status_code,200)
13851385
q = PyQuery(r.content)
1386-
self.assertEqual(len(q('form input[name="confirm"]')),1)
1386+
self.assertEqual(len(q('form button[name="confirm"]')),1)
13871387

13881388
url = urlreverse('ietf.doc.views_draft.to_iesg', kwargs=dict(name=self.docname))
13891389

0 commit comments

Comments
 (0)