Customize collapsed rows with a query param
This commit is contained in:
parent
54ddfdebf9
commit
d81d1563cb
10
README.rst
10
README.rst
|
@ -12,7 +12,7 @@ HTML report for the test results.
|
|||
:alt: PyPI
|
||||
.. image:: https://img.shields.io/conda/vn/conda-forge/pytest-html.svg
|
||||
:target: https://anaconda.org/conda-forge/pytest-html
|
||||
:alt: Conda Forge
|
||||
:alt: Conda Forge
|
||||
.. image:: https://img.shields.io/travis/pytest-dev/pytest-html.svg
|
||||
:target: https://travis-ci.org/pytest-dev/pytest-html/
|
||||
:alt: Travis
|
||||
|
@ -240,6 +240,14 @@ additional HTML and log output with a notice that the log is empty:
|
|||
del data[:]
|
||||
data.append(html.div('No log output captured.', class_='empty log'))
|
||||
|
||||
Display options
|
||||
---------------
|
||||
|
||||
By default, all rows in the **Results** table will be expanded except those that have :code:`Passed`.
|
||||
|
||||
This behavior can be customized with a query parameter: :code:`?collapsed=Passed,XFailed,Skipped`.
|
||||
|
||||
|
||||
Screenshots
|
||||
-----------
|
||||
|
||||
|
|
|
@ -78,9 +78,10 @@ function add_collapse() {
|
|||
|
||||
// Add show/hide link to each result
|
||||
find_all('.col-result').forEach(function(elem) {
|
||||
var collapsed = get_query_parameter('collapsed') || 'Passed';
|
||||
var extras = elem.parentNode.nextElementSibling;
|
||||
var expandcollapse = document.createElement("span");
|
||||
if (elem.innerHTML === 'Passed') {
|
||||
if (collapsed.includes(elem.innerHTML)) {
|
||||
extras.classList.add("collapsed");
|
||||
expandcollapse.classList.add("expander");
|
||||
} else {
|
||||
|
@ -98,6 +99,11 @@ function add_collapse() {
|
|||
})
|
||||
}
|
||||
|
||||
function get_query_parameter(name) {
|
||||
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
|
||||
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
|
||||
}
|
||||
|
||||
function init () {
|
||||
reset_sort_headers();
|
||||
|
||||
|
|
Loading…
Reference in New Issue