pytest-html icon indicating copy to clipboard operation
pytest-html copied to clipboard

.col-results.collapsed issue if results table order changed

Open volkan-aslan opened this issue 1 year ago • 2 comments

Discussed in https://github.com/pytest-dev/pytest-html/discussions/801

Originally posted by volkan-aslan March 7, 2024 Hello,

My pytest-html version is: 4.1.1

I am using below code in my conftest file to move results section to right-hand side.

def pytest_html_results_table_header(cells):
    cells.append(cells.pop(0))

def pytest_html_results_table_row(report, cells):
    cells.append(cells.pop(0))

But i noticed that, doing this breaking the following part of the report and it always shows "hide details" even its collapsed. (This was not a case with version 3.2.0),

.col-result:hover::after {
  content: " (hide details)";
}

.col-result.collapsed:hover::after {
  content: " (show details)";
}

When I inspect the html report, I noticed that it's adding the 'collapsed' class to the first td of .collapsible. This is OK if col-result is the first row, but in my case i moved it to the last so first row is col-testId, therefore it adds collapsed to col-testId.

if (collapsed) {
            resultBody.querySelector('.collapsible > td')?.classList.add('collapsed')
            resultBody.querySelector('.extras-row').classList.add('hidden')
        } else {
            resultBody.querySelector('.collapsible > td')?.classList.remove('collapsed')
        }

If I change it to: resultBody.querySelector('.collapsible > col-result')?.classList.add('collapsed')

then it works as expected.

I am not a java script person, so I don't know if this is the ideal fix but it would be nice to have a solution for such a case. If there's anything I've done wrong, I'd appreciate it if you could help.

Thanks.

ss

volkan-aslan avatar Apr 09 '24 10:04 volkan-aslan

https://github.com/pytest-dev/pytest-html/pull/807

volkan-aslan avatar Apr 09 '24 12:04 volkan-aslan

Thank you for reporting this. It is a known issue, but was never high on the todo because I never in a million years thought anyone would want the result column anywhere but first. 😆

BeyondEvil avatar Apr 09 '24 13:04 BeyondEvil