Emoji Insertion Test - Robust Cursor Position

Test 1: Insert emoji at cursor position (middle of text)

  1. Type "Hello World" in the editor
  2. Click between "Hello" and "World" to position cursor
  3. Click the emoji button and select an emoji
  4. Expected: Emoji appears between "Hello" and "World"

Test 2: Insert emoji when editor loses focus

  1. Type "Hello" in the editor
  2. Click outside the editor (this loses focus)
  3. Click the emoji button and select an emoji
  4. Expected: Emoji appears at the end after "Hello"

Test 3: Insert emoji in empty editor

  1. Don't type anything
  2. Click the emoji button and select an emoji
  3. Expected: Emoji appears at position 0

Test 4: Multiple emoji insertions

  1. Type "ABC" in the editor
  2. Position cursor after "A"
  3. Insert an emoji
  4. Position cursor at the end
  5. Insert another emoji
  6. Expected: Should see "A[emoji]BC[emoji]"