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

fix: "Show All Errors" button in results summary.html #683 #701

Merged
merged 3 commits into from
Jan 30, 2025
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ This job runs Test Suite tests on this branch against Reference Implementation (

- **Checkout OpenActive.Server.NET**: This step checks out the Reference Implementation in OpenActive.Server.NET and places it in a directory named "server".

- **Setup .NET Core SDK and Node.js**: These steps set up the required versions of .NET Core SDK (3.1.419) and Node.js (14.x).
- **Setup .NET Core SDK and Node.js**: These steps set up the required versions of .NET Core SDK (3.1.419) and Node.js (18.17.1).

- **Install OpenActive.Server.NET dependencies**: This step installs the dependencies of the "OpenActive.Server.NET" project.

@@ -98,7 +98,7 @@ This workflow defines one job: **build**.
#### Steps
- **Checkout OpenActive Test Suite**: This step checks out the OpenActive Test Suite code repository.

- **Setup Node.js 14.x**: This step sets up Node.js version 14.x in the job's environment.
- **Setup Node.js 18.17.1**: This step sets up Node.js version 18.17.1 in the job's environment.

- **Install OpenActive Test Suite**: This step runs `npm install` to install the dependencies of the OpenActive Test Suite.

@@ -127,7 +127,7 @@ This workflow defines one job: **generate**.
#### Steps
- **Checkout**: This step uses the actions/checkout action to clone the repository. It checks out the master branch and places the repository in a directory named "openactive-test-suite."
- **Setup Node.js 14.x**: This step uses the actions/setup-node action to set up Node.js version 14.x in the job's environment. This is necessary because Node.js is required for managing JavaScript dependencies.
- **Setup Node.js 18.17.1**: This step uses the actions/setup-node action to set up Node.js version 18.17.1 in the job's environment. This is necessary because Node.js is required for managing JavaScript dependencies.
- **Update openactive-integration-tests with latest data-models and validators**: This step runs npm install to update the openactive-data-models and data-model-validator dependencies to their latest versions. It targets the openactive-integration-tests package within the repository.
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
<head>
<style>
h2 {
cursor: pointer;
border-top-color: #CCC;
border-top-width: 1px;
border-top-style: solid;
padding-top: 5px;
h3 {
cursor: pointer;
}
h2:hover {
color: #0056b3; /* Example color change on hover */
h3:hover {
color: #0056b3; /* Example color change on hover */
}
/* New styling for collapsed sections */
section.collapsed > *:not(h3) {
display: none;
}
section {
border: 1px solid #CCC;
padding: 0.5em;
margin-bottom: 1em;
}
</style>
</head>

<button id="collapseH2Button">Collapse All Sections</button>
<button id="showH2Button">Show All Sections</button>
<button id="showOnlyErrorsButton">Show All Errors</button>
<button id="collapseH3Button">Collapse All Sections</button>
<button id="showH3Button">Show All Sections</button>
<label><input type="checkbox" id="hideSuccessToggle" checked> Hide successful results</label>


# Summary of Test Suite Results for '{{ bookingServiceName }}'
@@ -70,101 +77,122 @@ were found, that also includes a list of which tests failed as a result:

{{#eachSorted opportunityTypeGroups }}

### {{{ opportunityTypeName }}}

{{#each featureGroups }}
* {{{ validationIcon overallStatus }}} {{{ featureName }}} ({{implementedDisplayLabel}})
{{#each loggers}}
- {{{ validationIcon overallStatus }}} [{{{ suiteName }}}]({{{ htmlLocalPath }}}): ({{{ numFailed }}} failures, {{{ numWarnings }}} warnings, {{{ numSuggestions }}} suggestions, {{{ numPassed }}} passes)
<section>
<h3>▼ {{{ opportunityTypeName }}}</h3> {{!-- Indicate expanded by default --}}

<ul>
{{#each featureGroups }}
<li class="feature-group" data-status="{{overallStatus}}">
{{{ validationIcon overallStatus }}} {{{ featureName }}} ({{implementedDisplayLabel}})
<ul>
{{#each loggers}}
<li class="logger" data-status="{{overallStatus}}">
{{{ validationIcon overallStatus }}} <a href="{{{ htmlLocalPath }}}">{{{ suiteName }}}</a>: ({{{ numFailed }}} failures, {{{ numWarnings }}} warnings, {{{ numSuggestions }}} suggestions, {{{ numPassed }}} passes)
</li>
{{/each}}
</ul>
</li>
{{/each}}
{{/each}}
</ul>
<div class="all-tests-passing" style="display: none;">
<ul>
<li>✅ All tests passing</li>
</ul>
</div>
</section>

{{/eachSorted}}

---
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script>hljs.highlightAll();</script>

<script>
function collapseH2Section(nextElement) {
while (nextElement && nextElement.tagName !== 'H2') {
if (nextElement.style.display !== 'none') {
nextElement.style.display = 'none';
}
nextElement = nextElement.nextElementSibling;
}
}
document.addEventListener("DOMContentLoaded", function () {
// Toggle sections on H3 click
document.querySelectorAll("section h3").forEach(function(heading) {
heading.addEventListener("click", function() {
const section = heading.closest("section");
const collapsed = section.classList.toggle("collapsed");
// Update the emoji to reflect current state
heading.textContent = (collapsed ? "" : "") + heading.textContent.slice(2);
});
});
function showH2Section(nextElement) {
while (nextElement && nextElement.tagName !== 'H2') {
if (nextElement.style.display !== '') {
nextElement.style.display = '';
// Collapse All Sections
const collapseAllBtn = document.getElementById("collapseH3Button");
collapseAllBtn.addEventListener("click", function() {
document.querySelectorAll("section").forEach(function(section) {
if (!section.classList.contains("collapsed")) {
section.classList.add("collapsed");
const heading = section.querySelector("h3");
heading.textContent = "" + heading.textContent.slice(2);
}
nextElement = nextElement.nextElementSibling;
}
}
function toggleH2Section(nextElement) {
while (nextElement && nextElement.tagName !== 'H2') {
// Toggle visibility
nextElement.style.display = nextElement.style.display === 'none' ? '' : 'none';
nextElement = nextElement.nextElementSibling;
}
}
function collapseAllH2Sections() {
var h2Elements = document.querySelectorAll('h2');
h2Elements.forEach(function (h2) {
var nextElement = h2.nextElementSibling;
collapseH2Section(nextElement);
});
}
function showAllH2Sections() {
var h2Elements = document.querySelectorAll('h2');
h2Elements.forEach(function (h2) {
var nextElement = h2.nextElementSibling;
showH2Section(nextElement);
});
// Show All Sections
const showAllBtn = document.getElementById("showH3Button");
showAllBtn.addEventListener("click", function() {
document.querySelectorAll("section").forEach(function(section) {
if (section.classList.contains("collapsed")) {
section.classList.remove("collapsed");
const heading = section.querySelector("h3");
heading.textContent = "" + heading.textContent.slice(2);
}
});
}
function showOnlyErrorH2() {
var h2Elements = document.querySelectorAll('h2');
h2Elements.forEach(function (h2) {
var nextElement = h2.nextElementSibling;
if (nextElement.innerHTML.includes('❌')) {
showH2Section(nextElement);
});
// Hide successful results toggle
const hideSuccessToggle = document.getElementById("hideSuccessToggle");
const updateVisibility = function() {
const hideSuccess = hideSuccessToggle.checked;
document.querySelectorAll(".feature-group, .logger").forEach(function(el) {
const status = el.dataset.status || "";
if (hideSuccess && status !== "failed") {
el.style.display = "none";
} else {
collapseH2Section(nextElement);
el.style.display = "";
}
});
}
// Show/Hide each header section
document.querySelectorAll('h2').forEach(function (h2) {
h2.addEventListener('click', function () {
let nextElement = this.nextElementSibling;
toggleH2Section(nextElement)
// Show or hide "✅ All tests passing" if no feature groups are visible
document.querySelectorAll("section").forEach(function(sec) {
const featureGroups = Array.from(sec.querySelectorAll(".feature-group"));
const message = sec.querySelector(".all-tests-passing");
if (message) {
// If any feature group is visible, hide the message
const anyVisible = featureGroups.some(fg => fg.style.display !== "none");
message.style.display = anyVisible ? "none" : "";
}
});
});
// Show all header sections
document.getElementById('showH2Button').addEventListener('click', function () {
showAllH2Sections();
});
// Collapse all header sections
document.getElementById('collapseH2Button').addEventListener('click', function () {
collapseAllH2Sections();
});
// Show only error sections button
document.getElementById('showOnlyErrorsButton').addEventListener('click', function () {
showOnlyErrorH2();
});
};
hideSuccessToggle.addEventListener("change", updateVisibility);
// Initialize visibility on page load
updateVisibility();
// Collapse passing sections if there is at least one failing test
const collapsePassingSectionsIfAnyFailing = function() {
// Check if there's any failing test in the entire document
const anyFailing = document.querySelector(".feature-group[data-status='failed'], .logger[data-status='failed']");
// If there's a failing test, collapse any section that does NOT contain a failing feature-group/logger
if (anyFailing) {
document.querySelectorAll("section").forEach(function(section) {
const hasFailingChild = section.querySelector(".feature-group[data-status='failed'], .logger[data-status='failed']");
if (!hasFailingChild && !section.classList.contains("collapsed")) {
section.classList.add("collapsed");
const heading = section.querySelector("h3");
if (heading && heading.textContent.startsWith("")) {
heading.textContent = "" + heading.textContent.slice(2);
}
}
});
}
};
// Show only errors by default
showOnlyErrorH2();
// Apply the collapse logic right after the first visibility update
collapsePassingSectionsIfAnyFailing();
});
</script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script>hljs.highlightAll();</script>