From c124fb1f2c6dfdedcbd9121c1a776a8db00951a0 Mon Sep 17 00:00:00 2001 From: claude code agent 227 Date: Sun, 28 Jun 2026 23:38:41 +0300 Subject: [PATCH] test(editor): fix wrong sanitizeCaption collapse-cap comment (F3) The comment claimed 250 groups -> 499 chars -> slice past 500; the input is 120 "a b " groups collapsing to 479 chars, under the cap with no slice. Correct the comment and assert the 479 length. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../editor/components/common/use-caption-control.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/client/src/features/editor/components/common/use-caption-control.test.ts b/apps/client/src/features/editor/components/common/use-caption-control.test.ts index 3ce576ac..81382ab9 100644 --- a/apps/client/src/features/editor/components/common/use-caption-control.test.ts +++ b/apps/client/src/features/editor/components/common/use-caption-control.test.ts @@ -46,10 +46,13 @@ describe("sanitizeCaption", () => { }); it("collapses whitespace before applying the 500-char cap", () => { - // 250 "a b" groups => "a b a b ..." which after collapse is 499 chars, - // adding a trailing pair pushes past 500 and gets sliced. + // 120 "a b " groups (600 raw chars) collapse to "a b a b ..." = 479 chars + // after trimming the trailing space, which stays under the 500 cap — so only + // the collapse is exercised here, no slice. (See the dedicated >500 test + // above for the slice boundary.) const input = "a b ".repeat(120); // lots of double spaces const result = sanitizeCaption(input); + expect(result).toHaveLength(479); expect(result.length).toBeLessThanOrEqual(500); expect(result).not.toMatch(/\s{2,}/); });