diff --git a/src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.render.test.tsx b/src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.render.test.tsx new file mode 100644 index 00000000..71dff257 --- /dev/null +++ b/src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.render.test.tsx @@ -0,0 +1,24 @@ +import { describe, expect, test } from "bun:test"; +import { renderToString } from "react-dom/server"; +import BotSuggestionChip from "./bot-suggestion-chip"; + +const longStep = + "Write a full launch plan for next quarter with owners, deadlines and the review checkpoints for every team"; + +function render({ step }: { step: string }) { + return renderToString(); +} + +describe("BotSuggestionChip", () => { + test("shows the step and keeps it inside the chip", () => { + const html = render({ step: longStep }); + + expect(html).toContain(longStep); + // The twui button's content wrapper is nowrap by default, which let a + // long step spill out of the button's outline on a phone. + expect(html).toContain("[&_.twui-button-content-wrapper]:whitespace-normal"); + expect(html).toContain("[&_.twui-button-content-wrapper]:min-w-0"); + expect(html).toContain("break-words"); + expect(html).toContain("max-w-full"); + }); +}); \ No newline at end of file diff --git a/src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.tsx b/src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.tsx index 98571cdd..02b8757c 100644 --- a/src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.tsx +++ b/src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.tsx @@ -22,10 +22,10 @@ export default function BotSuggestionChip({ step }: Props) { color="gray" size="smaller" title={`Put this in your input: ${step}`} - className="inline-flex h-auto max-w-full gap-1! flex-nowrap align-middle px-2! py-1! text-left text-[13px] font-normal whitespace-normal [&_.twui-button-content-wrapper]:min-w-0" + className="inline-flex h-auto max-w-full min-w-0 gap-1! flex-nowrap align-middle px-2! py-1! text-left text-[13px] font-normal whitespace-normal [&_.twui-button-content-wrapper]:min-w-0 [&_.twui-button-content-wrapper]:whitespace-normal" onClick={() => onUseSuggestion({ text: step })} > - {step} + {step} );