History

health: wrap the misconfigured detail instead of truncating it

The remediation text is the payload - the enable-API console link was clipped by the one-line truncate. The scenario now asserts the text wraps un-clipped and the link sits inside the visible box.

Rhys Sullivan committed 4 months ago

Commit d87e84f1 parent ee67b0e2 files · +24 −3Browse files

Unified · Split

2 files
  1. e2e/scenarios/google-disabled-api.test.ts +18 −1
  2. packages/react/src/components/accounts-section.tsx +6 −2
e2e/scenarios/google-disabled-api.test.ts+18−1
@@ -304,7 +304,8 @@ scenario( · 303 unmodified lines
304304 await step(
305305 "The row carries Google's own instruction, console link included",
306306 async () => {
307− await connections.getByText(/has not been used in project/).waitFor();
307+ const detail = connections.getByText(/has not been used in project/);
308+ await detail.waitFor();
308309 const consoleLink = connections.getByRole("link", {
309310 name: /console\.developers\.google\.com/,
310311 });
@@ -313,6 +314,22 @@ scenario( · 2 unmodified lines
313314 await consoleLink.getAttribute("href"),
314315 "the enable-API console link is clickable",
315316 ).toContain("console.developers.google.com");
317+ // Visible in FULL, not just present in the DOM: a one-line
318+ // truncate keeps the link in the tree while clipping it from
319+ // view, which is exactly the regression this guards against.
320+ // A clipped element overflows horizontally; a wrapped one
321+ // grows taller instead.
322+ const clipped = await detail.evaluate(
323+ (el) =>
324+ el.scrollWidth > el.clientWidth + 1 || el.scrollHeight > el.clientHeight + 1,
325+ );
326+ expect(clipped, "the remediation text wraps instead of clipping").toBe(false);
327+ const linkVisible = await consoleLink.evaluate((el) => {
328+ const rect = el.getBoundingClientRect();
329+ const detailRect = el.closest("p")?.getBoundingClientRect();
330+ return detailRect ? rect.right <= detailRect.right + 1 : false;
331+ });
332+ expect(linkVisible, "the console link sits inside the visible detail box").toBe(true);
316333 },
317334 );
318335
packages/react/src/components/accounts-section.tsx+6−2
@@ -192,9 +192,13 @@ function AccountRow(props: { · 191 unmodified lines
192192 </CardStackEntryDescription>
193193 ) : null}
194194 {misconfigured && probe?.detail ? (
195− <CardStackEntryDescription className="mt-1 text-xs text-muted-foreground">
195+ // Not CardStackEntryDescription: that truncates to one line, and this
196+ // text IS the remediation (the enable-API console link must stay
197+ // visible in full). Wrap instead; break anywhere so the long URL
198+ // cannot overflow the row.
199+ <p className="mt-1 whitespace-normal text-xs text-muted-foreground [overflow-wrap:anywhere]">
196200 <DetailWithLinks text={probe.detail} />
197− </CardStackEntryDescription>
201+ </p>
198202 ) : null}
199203 {needsReconsent ? (
200204 <CardStackEntryDescription className="mt-1 text-xs text-muted-foreground">