Skip to content

Commit cbae96a

Browse files
committed
Make the links column sortable
1 parent 4aaa875 commit cbae96a

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

pytest_html/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def generate_summary_item(self):
498498
html.th("Result", class_="sortable result initial-sort", col="result"),
499499
html.th("Test", class_="sortable", col="name"),
500500
html.th("Duration", class_="sortable numeric", col="duration"),
501-
html.th("Links"),
501+
html.th("Links", class_="sortable links", col="links"),
502502
]
503503
session.config.hook.pytest_html_results_table_header(cells=cells)
504504

pytest_html/resources/main.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ function sort_column(elem) {
3232
key = key_num;
3333
} else if (elem.classList.contains('result')) {
3434
key = key_result;
35+
} else if (elem.classList.contains('links')) {
36+
key = key_link;
3537
} else {
3638
key = key_alpha;
3739
}
@@ -178,6 +180,13 @@ function key_num(col_index) {
178180
};
179181
}
180182

183+
function key_link(col_index) {
184+
return function(elem) {
185+
dataCell = elem.childNodes[1].childNodes[col_index].firstChild
186+
return dataCell == null ? "" : dataCell.innerText.toLowerCase();
187+
};
188+
}
189+
181190
function key_result(col_index) {
182191
return function(elem) {
183192
var strings = ['Error', 'Failed', 'Rerun', 'XFailed', 'XPassed',

testing/js_test_report.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<th class="sortable result initial-sort" col="result">Result</th>
2121
<th class="sortable" col="name">Test</th>
2222
<th class="sortable numeric" col="duration">Duration</th>
23-
<th>Links</th></tr>
23+
<th class="sortable" col=links">Links</th></tr>
2424
<tr hidden="true" id="not-found-message">
2525
<th colspan="5">No results found. Try to check the filters</th>
2626
</tr>

0 commit comments

Comments
 (0)