Skip to content

Commit

Permalink
Implement the visible URL query parameter to control visibility of te…
Browse files Browse the repository at this point in the history
…st results on page load. (pytest-dev#433)

* enable control of test result visability via query params

* fix typos and query parsing

* Add changelog entry

* fix type in changelog
  • Loading branch information
gnikonorov authored and BeyondEvil committed Apr 3, 2023
1 parent 6af9dd0 commit 72cede0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.rst
Expand Up @@ -9,6 +9,10 @@ Version History
3.2.0 (unreleased)
~~~~~~~~~~~~~~~~~~

* Implement the ``visible`` URL query parameter to control visibility of test results on page load. (`#399 <https://github.com/pytest-dev/pytest-html/issues/399>`_)

* Thanks to `@TheCorp <https://github.com/TheCorp>`_ for reporting and `@gnikonorov <https://github.com/gnikonorov>`_ for the fix

* Make the report tab title reflect the report name. (`#412 <https://github.com/pytest-dev/pytest-html/issues/412>`_)

* Thanks to `@gnikonorov <https://github.com/gnikonorov>`_ for the PR
Expand Down
26 changes: 21 additions & 5 deletions src/pytest_html/resources/main.js
Expand Up @@ -49,11 +49,27 @@ function showExtras(colresultElem) {
}

function hideExtras(colresultElem) {
const extras = colresultElem.parentNode.nextElementSibling;
const expandcollapse = colresultElem.firstElementChild;
extras.classList.add('collapsed');
expandcollapse.classList.remove('collapser');
expandcollapse.classList.add('expander');
const extras = colresultElem.parentNode.nextElementSibling;
const expandcollapse = colresultElem.firstElementChild;
extras.classList.add('collapsed');
expandcollapse.classList.remove('collapser');
expandcollapse.classList.add('expander');
}

function showFilters() {
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 (visibleString != 'all') {
filterItems[i].checked = checkedItems.includes(filterItems[i].getAttribute('data-test-result'));
filterTable(filterItems[i]);
}
}
}

function addCollapse() {
Expand Down

0 comments on commit 72cede0

Please sign in to comment.