Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expander to log output #721

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
58 changes: 44 additions & 14 deletions src/layout/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,51 @@ span.xpassed,
$extra-height: 240px;
$extra-media-width: 320px;

.log {
background-color: #e6e6e6;
border: $border-width solid #e6e6e6;
color: black;
display: block;
font-family: 'Courier New', Courier, monospace;
max-height: $extra-height - 2 * $spacing;
overflow-y: scroll;
padding: $spacing;
white-space: pre-wrap;

&:only-child {
height: inherit;
.logwrapper {
max-height: $extra-height - 2 * $spacing;
overflow-y: scroll;
background-color: #e6e6e6;
&.expanded {
max-height: none;
.logexpander {
&:after {
content: 'collapse [-]';
}
}
}
.logexpander {
z-index: 1;
position: sticky;
top: 10px;
width: max-content;
border: 1px solid;
border-radius: 3px;
padding: 5px 7px;
margin: 10px 0 10px calc(100% - 80px);
cursor: pointer;
background-color: #e6e6e6;
&:after {
content: 'expand [+]';
}
&:hover {
color: #000;
border-color: #000;
}
}
.log {
min-height: 40px;
position: relative;
top: -50px;
height: calc(100% + 50px);
border: $border-width solid #e6e6e6;
color: black;
display: block;
font-family: 'Courier New', Courier, monospace;
padding: $spacing;
padding-right: 80px;
white-space: pre-wrap;
}
}

div.media {
border: $border-width solid #e6e6e6;
float: right;
Expand Down Expand Up @@ -200,6 +229,7 @@ div.media {
}

.col-result {
width: 130px;
&:hover::after {
content: ' (hide details)';
}
Expand Down
5 changes: 4 additions & 1 deletion src/pytest_html/resources/index.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@
<div class="media__name"></div>
<div class="media__counter"></div>
</div>
<div class="log"></div>
<div class="logwrapper">
<div class="logexpander"></div>
<div class="log"></div>
</div>
</td>
</tr>
</tbody>
Expand Down
44 changes: 38 additions & 6 deletions src/pytest_html/resources/style.css

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

5 changes: 4 additions & 1 deletion src/pytest_html/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { dom, findAll } = require('./dom.js')
const { dom, find, findAll } = require('./dom.js')
const { manager } = require('./datamanager.js')
const { doSort } = require('./sort.js')
const { doFilter } = require('./filter.js')
Expand Down Expand Up @@ -67,6 +67,9 @@ const renderContent = (tests) => {
rows.forEach((row) => {
if (!!row) {
findAll('.collapsible td:not(.col-links', row).forEach(addItemToggleListener)
find('.logexpander', row).addEventListener('click',
(evt) => evt.target.parentNode.classList.toggle('expanded'),
)
newTable.appendChild(row)
}
})
Expand Down