fix: same broken metric-button line, plus a mangled location.reload()
ci/woodpecker/push/woodpecker Pipeline was successful

The dashboard carried the identical inline-handler line inside PAGE_HTML — the
served JS was a syntax error from there on, so the page loaded and then did
nothing — and a second casualty of the same sloppy one-shot replace:
`location.reload()` had become `location.rebuildMetricButtons()\nload()` inside
loadGuests(). Both are fixed, and the same gate fix applies (the gate now reads
PAGE_HTML via ast.literal_eval, i.e. the string the app serves, not the source
text between the quotes).

Buttons are delegated data-metric clicks now, the harness proves the click
reaches setTrendMetric, and the stub gained stateful attributes plus
addEventListener/__fire to make that possible.
This commit is contained in:
inference-admin committed 2026-11-13 21:14:03 +00:00
1 parent 36d8ba6e35
commit e2a5018150
3 files changed
+64 -11

No files matched your search

+19
View File
@@ -171,5 +171,24 @@ function mkDaily() {
buildMetricButtons();
}
// ---- the metric buttons are DELEGATED, so prove a click reaches setTrendMetric ----
// (An inline onclick inside PAGE_HTML is where a quote escape silently kills the
// whole page: it happened, and it shipped, because the gate read the raw source
// text instead of the string Python serves. Delegation removes that trap — and
// this is the check that the wiring still works.)
{
buildMetricButtons();
const rowEl = document.getElementById("trend-metrics");
assert(!!(rowEl.__handlers && rowEl.__handlers.click),
"the metric row has a delegated click listener");
setTrendMetric("members");
const fired = rowEl.__fire("click", { target: { closest: () => ({ getAttribute: () => "money" }) } });
assert(trendMetric === "money",
"clicking a metric button selects that metric (got " + trendMetric + ")");
setTrendMetric("members");
rowEl.__fire("click", { target: { closest: () => null } });
assert(trendMetric === "members", "a click that misses a button is ignored");
}
console.log("DASHBOARD CHART HARNESS OK: shared module tooltips, exact values, gaps, toggles");
})().catch((e) => { console.error("FAIL: " + (e && e.stack || e)); process.exit(1); });