From b4b46a0a791a281bd55e9d169d6c5d11138605ec Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 29 Apr 2026 01:21:38 +0200 Subject: [PATCH] test(person-mention): boundary cases for whitespace + newline triggers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tester #5506 nit pile: - '@Aug @Bert' with cursor past the second @ — confirm the most recent @ wins (this is the canonical case for typing two mentions separated by a space). - '@Aug\\nfoo' with cursor exactly at the newline (index 4) — the query still reads 'Aug' because the newline is past the cursor. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/lib/utils/personMention.spec.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frontend/src/lib/utils/personMention.spec.ts b/frontend/src/lib/utils/personMention.spec.ts index 64684bd8..7101c27c 100644 --- a/frontend/src/lib/utils/personMention.spec.ts +++ b/frontend/src/lib/utils/personMention.spec.ts @@ -42,6 +42,18 @@ describe('detectPersonMention', () => { expect(detectPersonMention('@Aug@bar', 8)).toBeNull(); }); + it('uses the most recent @ when separated by whitespace', () => { + // '@Aug @Bert' with cursor at end — the second @ is the trigger. + expect(detectPersonMention('@Aug @Bert', 10)).toBe('Bert'); + }); + + it('returns the query when the cursor sits exactly at a newline boundary', () => { + // '@Aug\nfoo' with cursor at index 4 — right at the newline before it + // is consumed. The query is still 'Aug' because nothing past the cursor + // counts. + expect(detectPersonMention('@Aug\nfoo', 4)).toBe('Aug'); + }); + it('returns null when cursor is before the @', () => { expect(detectPersonMention('@Hans', 0)).toBeNull(); });