Skip to content

Commit

Permalink
Feature: Make entire row collapsible (pytest-dev#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
BeyondEvil authored Apr 15, 2023
1 parent 60c81d8 commit a5da6fc
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/layout/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,13 @@ div.media {
cursor: pointer;
}

.col-result {
.collapsible td:not(.col-links) {
cursor: pointer;
&:hover::after {
@include rowToggle;
}
}

.col-result.collapser {
&:hover::after {
content: ' (hide details)';
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_html/resources/index.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</template>
<template id="template_results-table__tbody">
<tbody class="results-table-row">
<tr>
<tr class="collapsible">
<td class="col-result"></td>
<td class="col-name"></td>
<td class="col-duration"></td>
Expand Down
4 changes: 2 additions & 2 deletions src/pytest_html/resources/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/pytest_html/scripts/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ const dom = {
const resultBody = templateResult.content.cloneNode(true)
resultBody.querySelector('tbody').classList.add(resultLower)
resultBody.querySelector('tbody').id = testId
resultBody.querySelector('.collapsible').dataset.id = id
resultBody.querySelector('.col-result').innerText = result
resultBody.querySelector('.col-result').classList.add(`${collapsed ? 'expander' : 'collapser'}`)
resultBody.querySelector('.col-result').dataset.id = id
resultBody.querySelector('.col-name').innerText = testId

const formattedDuration = duration < 1 ? formatDuration(duration).ms : formatDuration(duration).formatted
Expand Down
4 changes: 2 additions & 2 deletions src/pytest_html/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ const renderContent = (tests) => {
redraw()
})
})
findAll('.col-result').forEach((elem) => {
findAll('.collapsible td:not(.col-links').forEach((elem) => {
elem.addEventListener('click', ({ target }) => {
manager.toggleCollapsedItem(target.dataset.id)
manager.toggleCollapsedItem(target.parentElement.dataset.id)
redraw()
})
})
Expand Down

0 comments on commit a5da6fc

Please sign in to comment.