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(); });