Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: add a button to the alerts page that shows the pending, no-data and error instances

The page opens on the firing ones. The button lists every instance again,
with the state filter and the tones back, so the table's filtering is
visible. The saved-filters key goes back to its original name, since the
state column is a filter again.
This commit is contained in:
iris 2026-10-18 13:17:35 +02:00 • committed by mara
commit f0a6d6c042
4 changed files with 64 additions and 22 deletions

View file

@ -3,7 +3,12 @@
// is imported as it is.
import assert from "node:assert/strict";
import { test } from "node:test";
import { activeSinceMs, alertKey, firingAlerts } from "../src/pages/alerts.ts";
import {
activeSinceMs,
alertKey,
firingAlerts,
listedAlerts,
} from "../src/pages/alerts.ts";
const alert = (name, state, extra = {}) => ({
name,
@ -28,6 +33,22 @@ test("only instances in the Alerting state are listed", () => {
);
});
test("asking for the rest lists every instance, in order", () => {
const all = [
alert("a", "Pending"),
alert("b", "Alerting"),
alert("c", "Error"),
];
assert.deepEqual(
listedAlerts(all, true).map((a) => a.name),
["a", "b", "c"],
);
assert.deepEqual(
listedAlerts(all, false).map((a) => a.name),
["b"],
);
});
test("nothing firing leaves the list empty, and the input is not changed", () => {
const all = [alert("a", "Pending"), alert("b", "Error")];
assert.deepEqual(firingAlerts(all), []);