Skip to content

Agent Mesh

fix: console - CSP-safe label styling, add Services view UI coverage

Fernando Marino68267144d082
diff --git a/internal/console/public/app.js b/internal/console/public/app.js
index 503e5c1a..b11f55fe 100644
--- a/internal/console/public/app.js
+++ b/internal/console/public/app.js
@@ -350,7 +350,7 @@ function formatLabels(labels) {
function peerCell(peerID, labels) {
const labelText = formatLabels(labels);
const sub = labelText
- ? `<div style="color: var(--text-secondary); font-size: 0.85em;">${escapeHTML(labelText)}</div>`
+ ? `<div class="cell-subtext">${escapeHTML(labelText)}</div>`
: '';
return `<code>${escapeHTML(peerID)}</code>${sub}`;
}
diff --git a/internal/console/public/style.css b/internal/console/public/style.css
index 782e4264..e3b4105d 100644
--- a/internal/console/public/style.css
+++ b/internal/console/public/style.css
@@ -646,6 +646,13 @@ body {
border-bottom: none;
}
+/* An operator-declared label line under a bare peer ID (see peerCell in
+ app.js) - a class, not an inline style, so CSP style-src can stay strict. */
+.cell-subtext {
+ color: var(--text-secondary);
+ font-size: 0.85em;
+}
+
.text-center {
text-align: center;
}
diff --git a/tests/ui/console.spec.js b/tests/ui/console.spec.js
index ea2950fe..18b14dea 100644
--- a/tests/ui/console.spec.js
+++ b/tests/ui/console.spec.js
@@ -312,3 +312,28 @@ test('the served markup carries no inline style attribute', async ({ request })
const html = await (await request.get('/index.html')).text();
expect(html).not.toMatch(/<[^>]+\sstyle=/);
});
+
+// The Services view has no admin flow to seed it from the browser alone (a
+// real node has to self-report), so this only pins what is reachable without
+// one: the nav item routes there and the empty state renders without a JS
+// error. TestHandleNodeCatalog in internal/controlplane covers the reporting
+// endpoint itself, and TestReportNodeCatalog in internal/node covers the
+// node-side push.
+test('the Services view is reachable and renders its empty state', async ({ page }) => {
+ await login(page);
+
+ await page.click('.nav-item[data-target="services"]');
+ await expect(page).toHaveURL(/#services$/);
+ await expect(page.locator('#view-services')).toBeVisible();
+ await expect(page.locator('#table-services')).toContainText('No nodes have reported any services yet');
+});
+
+// A reload must survive on this view too, same as the other deep-linkable
+// views already covered above for #routers.
+test('the Services view is deep-linkable via the URL hash', async ({ page }) => {
+ await login(page);
+
+ await page.goto('/#services');
+ await expect(page.locator('#view-services')).toBeVisible();
+ await expect(page.locator('.nav-item[data-target="services"]')).toHaveAttribute('aria-current', 'page');
+});