Render health API names without label keys

This commit is contained in:
ms2k 2026-09-16 18:44:13 +09:00
commit d5fe7407da
2 changed files with 18 additions and 8 deletions

View file

@ -65,7 +65,7 @@ function renderRow(record, recordIndex, dates, select) {
}
function renderGroup(group, groupIndex, records, dates, select) {
const [header, labels, values] = group;
const [header, names, values] = group;
const section = document.createElement("section");
section.className = "health-group";
@ -75,11 +75,7 @@ function renderGroup(group, groupIndex, records, dates, select) {
section.setAttribute("aria-labelledby", heading.id);
section.append(heading);
for (const [seriesIndex, metric] of labels.entries()) {
const name =
Object.entries(metric)
.map(([key, value]) => `${key}=${value}`)
.join(", ") || "{}";
for (const [seriesIndex, name] of names.entries()) {
const record = { name, values: values[seriesIndex] };
const recordIndex = records.length;

View file

@ -15,8 +15,8 @@ days[3] = 0;
const snapshot = [
1786838400,
[
["Nodes", [{ node: "one" }, { node: "two" }], [days, days]],
["Public services", [{ service: "code" }], [days]],
["Nodes", ["one", "two"], [days, days]],
["Public services", ["Code"], [days]],
],
];
@ -56,6 +56,11 @@ async function checkHealth(page, width, mode) {
);
if (healthy) {
assert.deepEqual(await page.locator(".health-row h3").allTextContents(), [
"Code",
"one",
"two",
]);
assert.match(
await page.locator(".health-group h2").first().textContent(),
/Public services/,
@ -63,6 +68,15 @@ async function checkHealth(page, width, mode) {
await page.locator(".bar").nth(2).click();
assert.match(await page.locator("#detail").textContent(), /95\.83%/);
assert.match(await page.locator("#detail").textContent(), /^Code ·/);
assert.equal(
await page.locator("#target option").first().textContent(),
"Public services · Code",
);
assert.match(
await page.locator(".bar").first().getAttribute("aria-label"),
/^Code ·/,
);
} else {
assert.equal(await page.locator("#observed").textContent(), "No data");
}