mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 16:12:11 +00:00
fix(admin): api-tokens table truncate-with-tooltip (no scrollbar 4th attempt)
Marc has now reported a residual scrollbar on `/admin/api-tokens` four times running. Earlier fixes addressed the obvious overflow culprits (column-hide in v1.4.15, mobile card-list in v1.4.16, admin-shell mobile-strip `no-scrollbar` in v1.4.18), but the section itself still leaked a few quirks: - The mobile token-name span carried `truncate` and `break-all` on the same element. `truncate` sets `white-space: nowrap`, which beats `word-break: break-all` per CSS spec — `break-all` was dead code AND it was misleading. Remove it. - The desktop table had no per-column upper bound. A long token name could expand the row past the card on 768-1024 px viewports. Lock the layout with `table-fixed` + `<colgroup>` widths. - Permission badges had no `max-width` cap. A single long permission string (`measurements:write:audit:legacy:extended`) could push the cell past the card. Cap each badge with `max-w-full truncate` and a native `title` attribute. Wrap every potentially-long string (token name, username, permission badge) in a small `<TruncatedCell>` helper that pairs the visual truncation with a radix tooltip. The tooltip is the discoverable hover/long-press path so the full value is still readable; the native `title` attribute is a graceful fallback for screen readers and right-click → "view full name" on desktop. Adds an e2e regression that walks every element inside the mobile card-list and asserts none of them carry `scrollWidth > clientWidth`, exercised against a worst-case payload (long token name + long username + long permission string). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
088832aa39
commit
dd8212e202
3 files changed
+454
-168
No files matched your search
@@ -118,4 +118,90 @@ test.describe("/admin/api-tokens mobile no-overflow", () => {
|
||||
}));
|
||||
expect(stripDims.scrollWidth).toBeGreaterThan(stripDims.clientWidth);
|
||||
});
|
||||
|
||||
// v1.4.19 phase A7 (4th attempt) — even with the mobile-strip
|
||||
// `no-scrollbar` fix from v1.4.18, Marc still reported a painted
|
||||
// scrollbar. The card body itself must not contribute any
|
||||
// horizontal-overflow culprit: every element inside the api-tokens
|
||||
// section must satisfy `scrollWidth <= clientWidth + 1`. Pads with
|
||||
// a long token name + long username + a long permission to exercise
|
||||
// the worst case.
|
||||
test("Pixel-5 viewport: nothing inside the api-tokens card overflows horizontally", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.route("**/api/admin/tokens", (route) =>
|
||||
route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
data: [
|
||||
{
|
||||
id: "tok1",
|
||||
name: "iOS auto-login 2026-05-05T19:42:11Z device-AABBCCDDEEFF-marathon",
|
||||
permissions: [
|
||||
"measurements:write:audit:legacy:extended",
|
||||
"medications:read",
|
||||
"*",
|
||||
],
|
||||
lastUsedAt: "2026-05-08T12:00:00Z",
|
||||
expiresAt: null,
|
||||
createdAt: "2026-05-01T08:00:00Z",
|
||||
revoked: false,
|
||||
user: {
|
||||
id: "u1",
|
||||
username: "marc-the-very-long-username-that-overflows",
|
||||
},
|
||||
},
|
||||
],
|
||||
error: null,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
await page.goto("/admin/api-tokens", { waitUntil: "domcontentloaded" });
|
||||
await page.waitForLoadState("networkidle");
|
||||
await expect(page.getByTestId("admin-tokens-mobile-list")).toBeVisible({
|
||||
timeout: 10_000,
|
||||
});
|
||||
|
||||
// Walk every element inside the mobile card-list and assert no
|
||||
// child has a wider scrollWidth than its container. This is the
|
||||
// Pixel-5 worst-case Marc kept hitting.
|
||||
const culprits = await page
|
||||
.getByTestId("admin-tokens-mobile-list")
|
||||
.evaluate((root) => {
|
||||
const out: Array<{
|
||||
tag: string;
|
||||
klass: string;
|
||||
scrollWidth: number;
|
||||
clientWidth: number;
|
||||
}> = [];
|
||||
for (const el of root.querySelectorAll("*")) {
|
||||
if (el.scrollWidth > el.clientWidth + 1) {
|
||||
out.push({
|
||||
tag: el.tagName,
|
||||
klass:
|
||||
typeof el.className === "string"
|
||||
? el.className.slice(0, 80)
|
||||
: "",
|
||||
scrollWidth: el.scrollWidth,
|
||||
clientWidth: el.clientWidth,
|
||||
});
|
||||
}
|
||||
}
|
||||
return out;
|
||||
});
|
||||
expect(
|
||||
culprits,
|
||||
`overflow culprits: ${JSON.stringify(culprits, null, 2)}`,
|
||||
).toEqual([]);
|
||||
|
||||
// Document-level horizontal overflow — the page must not paint
|
||||
// any horizontal scroll, period.
|
||||
const dims = await page.evaluate(() => ({
|
||||
scrollWidth: document.documentElement.scrollWidth,
|
||||
innerWidth: window.innerWidth,
|
||||
}));
|
||||
expect(dims.scrollWidth).toBeLessThanOrEqual(dims.innerWidth + 1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user