test grouping
This commit is contained in:
@@ -298,8 +298,13 @@
|
||||
<h2>Tests & suites</h2>
|
||||
<div class="testing-controls">
|
||||
<input id="testing-filter" type="search" placeholder="filter tests…" oninput="renderTestTargets()" aria-label="Filter tests">
|
||||
<select id="testing-tag-filter" onchange="renderTestTargets()" aria-label="filter by test tag">
|
||||
<option value="">all tags</option>
|
||||
</select>
|
||||
<button class="small" type="button" data-test-target="suite:all">Run all tests</button>
|
||||
<button class="small" type="button" onclick="reloadTestTargets()">re-collect</button>
|
||||
</div>
|
||||
<div id="testing-tag-actions" class="testing-tags"></div>
|
||||
<div id="testing-targets" class="empty">admin login required</div>
|
||||
</section>
|
||||
<section data-tab="testing" data-admin-only class="wide">
|
||||
@@ -1016,7 +1021,7 @@ function renderConsole(data) {
|
||||
|
||||
// ---- testing tab (opt-in tracker test runner, dashboard-test-runner US-002) ----
|
||||
|
||||
let testCollection = { tests: [], suites: [] };
|
||||
let testCollection = { tests: [], test_metadata: [], suites: [], tags: [] };
|
||||
let testRun = null;
|
||||
let testRunStarting = false;
|
||||
|
||||
@@ -1122,21 +1127,39 @@ function renderTestTargets() {
|
||||
const el = $("testing-targets");
|
||||
if (!el) return;
|
||||
const filter = ($("testing-filter")?.value || "").trim().toLowerCase();
|
||||
const selectedTag = ($("testing-tag-filter")?.value || "").trim().toLowerCase();
|
||||
const metadata = testCollection.test_metadata || testCollection.tests.map(id => ({ id, description: id, tags: [] }));
|
||||
const suites = (testCollection.suites || [])
|
||||
.map(s => ({ id: s.id, label: `${s.name} (${(s.paths || []).join(", ")})`, suite: true }));
|
||||
const tests = (testCollection.tests || []).map(t => ({ id: t, label: t, suite: false }));
|
||||
.map(s => ({ id: s.id, label: `${s.name} (${(s.paths || []).join(", ")})`, description: "Approved test suite", tags: ["suite"], suite: true }));
|
||||
const tests = metadata.map(t => ({ ...t, label: t.id, suite: false }));
|
||||
const targets = [...suites, ...tests]
|
||||
.filter(t => !filter || t.label.toLowerCase().includes(filter));
|
||||
.filter(t => !filter || `${t.label} ${t.description} ${(t.tags || []).join(" ")}`.toLowerCase().includes(filter))
|
||||
.filter(t => !selectedTag || t.suite || (t.tags || []).includes(selectedTag));
|
||||
const disabled = testRunActive() ? " disabled" : "";
|
||||
const tagFilter = $("testing-tag-filter");
|
||||
if (tagFilter) {
|
||||
const value = tagFilter.value;
|
||||
tagFilter.innerHTML = '<option value="">all tags</option>' +
|
||||
(testCollection.tags || []).map(t => `<option value="${esc(t.name)}">${esc(t.name)} (${esc(t.count)})</option>`).join("");
|
||||
tagFilter.value = value;
|
||||
}
|
||||
const tagActions = $("testing-tag-actions");
|
||||
if (tagActions) {
|
||||
tagActions.innerHTML = (testCollection.tags || []).map(t =>
|
||||
`<button class="small" type="button" data-test-target="${esc(t.id)}"${disabled}>Run ${esc(t.name)} (${esc(t.count)})</button>`
|
||||
).join("");
|
||||
}
|
||||
if (!targets.length) {
|
||||
el.className = "empty";
|
||||
el.innerHTML = filter ? "no targets match the filter" : "no tests collected";
|
||||
el.innerHTML = filter || selectedTag ? "no tests match the filter" : "no tests collected";
|
||||
return;
|
||||
}
|
||||
const disabled = testRunActive() ? " disabled" : "";
|
||||
el.className = "testing-list";
|
||||
el.innerHTML = targets.map(t =>
|
||||
`<div class="testing-row">` +
|
||||
`<span class="testing-target">${t.suite ? '<span class="pill">suite</span> ' : ""}${esc(t.label)}</span>` +
|
||||
`<span class="testing-target"><strong>${t.suite ? '<span class="pill">suite</span> ' : ""}${esc(t.label)}</strong>` +
|
||||
`<br><span class="dim">${esc(t.description || "")}</span>` +
|
||||
`${(t.tags || []).map(tag => ` <span class="pill">${esc(tag)}</span>`).join("")}</span>` +
|
||||
`<button class="small" type="button" data-test-target="${esc(t.id)}"${disabled}>Run</button>` +
|
||||
`</div>`
|
||||
).join("");
|
||||
@@ -1183,7 +1206,12 @@ async function loadTestTargets(refresh) {
|
||||
$("testing-targets").innerHTML = "test targets unavailable";
|
||||
return false;
|
||||
}
|
||||
testCollection = { tests: result.data.tests || [], suites: result.data.suites || [] };
|
||||
testCollection = {
|
||||
tests: result.data.tests || [],
|
||||
test_metadata: result.data.test_metadata || [],
|
||||
suites: result.data.suites || [],
|
||||
tags: result.data.tags || [],
|
||||
};
|
||||
renderTestTargets();
|
||||
return true;
|
||||
}
|
||||
@@ -1214,9 +1242,7 @@ async function pollTestRunIfActive() {
|
||||
}
|
||||
|
||||
function bindTestingControls() {
|
||||
const list = $("testing-targets");
|
||||
if (!list) return;
|
||||
list.addEventListener("click", event => {
|
||||
document.addEventListener("click", event => {
|
||||
const button = event.target.closest("[data-test-target]");
|
||||
if (!button || button.disabled) return;
|
||||
event.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user