diff --git a/CHANGES.rst b/CHANGES.rst index 287dd03a..d3dc3604 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,6 +3,10 @@ Release Notes **2.1.2 (unreleased)** +* Make the ``Results`` table ``Links`` column sortable (`#242 `_) + + * Thanks to `@vashirov `_ for reporting and `@gnikonorov `_ for the fix + * Fix issue with missing image or video in extras. (`#265 `_ and `pytest-selenium#237 `_) * Thanks to `@p00j4 `_ and `@anothermattbrown `_ for reporting and `@christiansandberg `_ and `@superdodd `_ and `@dhalperi `_ for the fix diff --git a/pytest_html/plugin.py b/pytest_html/plugin.py index 00eca557..2996c344 100644 --- a/pytest_html/plugin.py +++ b/pytest_html/plugin.py @@ -498,7 +498,7 @@ def generate_summary_item(self): html.th("Result", class_="sortable result initial-sort", col="result"), html.th("Test", class_="sortable", col="name"), html.th("Duration", class_="sortable numeric", col="duration"), - html.th("Links"), + html.th("Links", class_="sortable links", col="links"), ] session.config.hook.pytest_html_results_table_header(cells=cells) diff --git a/pytest_html/resources/main.js b/pytest_html/resources/main.js index d2be8b8a..c06cb455 100644 --- a/pytest_html/resources/main.js +++ b/pytest_html/resources/main.js @@ -32,6 +32,8 @@ function sort_column(elem) { key = key_num; } else if (elem.classList.contains('result')) { key = key_result; + } else if (elem.classList.contains('links')) { + key = key_link; } else { key = key_alpha; } @@ -178,6 +180,13 @@ function key_num(col_index) { }; } +function key_link(col_index) { + return function(elem) { + dataCell = elem.childNodes[1].childNodes[col_index].firstChild + return dataCell == null ? "" : dataCell.innerText.toLowerCase(); + }; +} + function key_result(col_index) { return function(elem) { var strings = ['Error', 'Failed', 'Rerun', 'XFailed', 'XPassed', diff --git a/testing/js_test_report.html b/testing/js_test_report.html index a4a9e309..25a539e3 100644 --- a/testing/js_test_report.html +++ b/testing/js_test_report.html @@ -20,7 +20,7 @@ Result Test Duration - Links + Links No results found. Try to check the filters @@ -30,7 +30,7 @@ Rerun rerun.py::test_rexample_1 1.00 - + URL
@pytest.mark.flaky(reruns=5)
def test_example():
import random
> assert random.choice([True, False])
E assert False
E + where False = <bound method Random.choice of <random.Random object at 0x7fe80b85f420>>([True, False])
E + where <bound method Random.choice of <random.Random object at 0x7fe80b85f420>> = <module 'random' from '/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.pyc'>.choice

rerun.py:6: AssertionError
diff --git a/testing/test.js b/testing/test.js index f5f77d9b..4ec1600e 100644 --- a/testing/test.js +++ b/testing/test.js @@ -48,6 +48,12 @@ 'rerun results-table-row', 'passed results-table-row'); sort_column_test('[col=duration]', 'passed results-table-row', 'rerun results-table-row'); + + //links + sort_column_test('[col=links]', + 'rerun results-table-row', 'passed results-table-row'); + sort_column_test('[col=links]', + 'passed results-table-row', 'rerun results-table-row'); }); QUnit.test('filter_table', function(assert){ @@ -123,6 +129,6 @@ QUnit.test('find', function (assert) { }); QUnit.test('find_all', function(assert) { - assert.equal(find_all('.sortable').length, 3); + assert.equal(find_all('.sortable').length, 4); assert.equal(find_all('.not-in-table').length, 0); });