Co-authored-by: hy4ri <hy4ri@users.noreply.github.com>
This commit is contained in:
1 parent
5376d46683
commit
0823fe3117
3 files changed
+54
-18
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package com.m57.hermescontrol.ui.chat
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
@@ -89,4 +90,21 @@ class ChatInputPolicyTest {
|
||||
ChatInputPolicy.canSend("/stop", emptyList(), isConnected = true),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun commandFieldValue_placesCursorAtEnd() {
|
||||
val cmd = "/help"
|
||||
val value = ChatInputPolicy.commandFieldValue(cmd)
|
||||
assertEquals("command text must be preserved", cmd, value.text)
|
||||
assertEquals("cursor must be at the end, not the middle", cmd.length, value.selection.start)
|
||||
assertEquals("selection must be collapsed at the end", cmd.length, value.selection.end)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun commandFieldValue_endSelectionOnPrefixReplacement() {
|
||||
// Regression guard for issue #599: inserting /help over an existing /h
|
||||
// prefix must not leave the cursor at position 2 (middle of the text).
|
||||
val value = ChatInputPolicy.commandFieldValue("/help")
|
||||
assertTrue("cursor must be past the shared /h prefix", value.selection.start > 2)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user