Files
loki/scripts/test/feedback-public-excerpt.ts
CatoandClaude 9c52553581 fix(public): readable homepage quotes, one 'Free' on pricing, a demo panel that belongs (#1032)
Found by crawling every public page at 390px and 1440px in a real browser.

- Homepage 'Notes in, fixes out' quoted a featured note sliced at 140
  chars, measurements and all, ending mid-word ('permanently o…').
  publicFeedbackExcerpt drops bracketed asides and ends on a sentence or
  a word. Pinned by scripts/test/feedback-public-excerpt.ts.
- /pricing printed 'Free' as the plan name and again as its price. The
  price is now a number: CHF 0 / mo.
- /sign-in: the demo was a bare orange stripe above the page, louder than
  the sign-in itself, and the tall page pressed its heading against the
  header. The demo is now a panel in the card's own shape, and the auth
  page has top padding.


Claude-Session: https://claude.ai/code/session_01TDTqcifctAar8o5hcbD3pE

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-03 17:30:42 -07:00

41 lines
1.8 KiB
TypeScript

// The homepage quotes featured feedback to strangers. Pins that the quote is
// readable: no measurement asides, and never cut inside a word.
import assert from "node:assert/strict";
import { publicFeedbackExcerpt } from "../../src/lib/feedback/public-excerpt";
// The note the homepage actually showed on 2026-10-04.
const real =
"On mobile (320px wide), the feedback widget's floating action button (fixed, 48x48px, z-index 2147483000, bottom-right corner) permanently overlaps the last pricing card and hides its button, so nobody on a phone can start the plan.";
const out = publicFeedbackExcerpt(real);
assert.ok(!out.includes("("), `asides dropped: ${out}`);
assert.ok(!out.includes("z-index"), `measurements dropped: ${out}`);
assert.ok(
out.startsWith("On mobile, the feedback widget's floating action button permanently"),
out,
);
assert.ok(out.length <= 141, `bounded: ${out.length}`);
assert.match(out, /\w…$|[.!?]$/, `ends on a word or a sentence: ${out}`);
// A short first sentence stands alone.
assert.equal(
publicFeedbackExcerpt(
"The menu hides the logo. Also the footer links are tiny on my phone and hard to tap.",
),
"The menu hides the logo.",
);
// Short text is returned whole, whitespace tidied.
assert.equal(publicFeedbackExcerpt(" Button text is cut off "), "Button text is cut off");
// A long text without spaces still ends with an ellipsis inside the bound.
const long = "x".repeat(300);
assert.equal(publicFeedbackExcerpt(long), `${"x".repeat(140)}…`);
// Cut on a word boundary, never mid-word.
const words = Array.from({ length: 60 }, (_, i) => `word${i}`).join(" ");
const w = publicFeedbackExcerpt(words);
assert.match(w, /word\d+…$/);
assert.ok(words.includes(w.slice(0, -1) + " "), "cut lands between two words");
console.log("feedback-public-excerpt: ok");