Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix typos and query parsing
  • Loading branch information
gnikonorov committed Dec 20, 2020
commit fd69c9ee8c19b09feb6eeefab12ebf67ff202a2c
8 changes: 4 additions & 4 deletions docs/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,15 @@ or by setting the :code:`render_collapsed` in a configuration file (pytest.ini,

**NOTE:** Setting :code:`render_collapsed` will, unlike the query parameter, affect all statuses.

Controlling Test Result Visability Via Query Params
Controlling Test Result Visibility Via Query Params
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

By default, all tests are visible, regardless of their results. It is possible to control which tests are visible on
page load by passing the :code:`visible` query parameter. To use this parameter, please pass a comma separated list
of test results you wish to be visible. For exmaple, passing :code:`?visible=passed,skipped` will show only those
tests in the report that have outcome :code:`passed`, or :code:`skipped`.
of test results you wish to be visible. For example, passing :code:`?visible=passed,skipped` will show only those
tests in the report that have outcome :code:`passed` or :code:`skipped`.

Note that this match is case insenstive, so passing :code:`PASSED` and :code:`passed` has the same effect.
Note that this match is case insensitive, so passing :code:`PASSED` and :code:`passed` has the same effect.

The following query parameters may be passed:

Expand Down
9 changes: 5 additions & 4 deletions src/pytest_html/resources/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ function hideExtras(colresultElem) {
}

function showFilters() {
let checked = getQueryParameter('visible') || 'all';
checked = checked.toLowerCase();
let visibleString = getQueryParameter('visible') || 'all';
visibleString = visibleString.toLowerCase();
const checkedItems = visibleString.split(',');

const filterItems = document.getElementsByClassName('filter');
for (let i = 0; i < filterItems.length; i++) {
filterItems[i].hidden = false;

if (checked != 'all') {
filterItems[i].checked = checked.includes(filterItems[i].getAttribute('data-test-result'));
if (visibleString != 'all') {
filterItems[i].checked = checkedItems.includes(filterItems[i].getAttribute('data-test-result'));
filterTable(filterItems[i]);
} else
filterItems[i].checked = true;
Expand Down