@@ -39,6 +39,7 @@ import io.getstream.chat.android.models.SyncStatus
3939import io.getstream.chat.android.models.User
4040import io.getstream.chat.android.randomAttachment
4141import io.getstream.chat.android.randomMessage
42+ import io.getstream.chat.android.randomString
4243import io.getstream.chat.android.randomUser
4344import io.getstream.chat.android.test.MockRetrofitCall
4445import io.getstream.chat.android.test.TestCoroutineExtension
@@ -903,7 +904,7 @@ internal class MessageComposerControllerTest {
903904 @Test
904905 fun `Given edit mode When selectCommand called Then activeCommand is not set and event is emitted` () = runTest {
905906 // Given
906- val command = Command (" giphy " , " Search GIFs " , " [text] " , " fun_set" )
907+ val command = Command (name = randomString(), description = randomString(), args = randomString(), set = " fun_set" )
907908 val editedMessage = randomMessage(cid = CID )
908909 val editAction = Edit (editedMessage)
909910 val controller = Fixture ()
@@ -935,7 +936,12 @@ internal class MessageComposerControllerTest {
935936 fun `Given reply mode When selectCommand called with moderation command Then command is not set and event is emitted` () =
936937 runTest {
937938 // Given
938- val muteCommand = Command (" mute" , " Mute user" , " [@username]" , " moderation_set" )
939+ val muteCommand = Command (
940+ name = randomString(),
941+ description = randomString(),
942+ args = randomString(),
943+ set = " moderation_set" ,
944+ )
939945 val repliedMessage = randomMessage(cid = CID )
940946 val replyAction = Reply (repliedMessage)
941947 val controller = Fixture ()
@@ -965,7 +971,12 @@ internal class MessageComposerControllerTest {
965971 @Test
966972 fun `Given reply mode When selectCommand then clearActiveCommand called Then reply action is preserved` () = runTest {
967973 // Given
968- val giphyCommand = Command (" giphy" , " Search GIFs" , " [text]" , " fun_set" )
974+ val giphyCommand = Command (
975+ name = randomString(),
976+ description = randomString(),
977+ args = randomString(),
978+ set = " fun_set" ,
979+ )
969980 val repliedMessage = randomMessage(cid = CID )
970981 val replyAction = Reply (repliedMessage)
971982 val controller = Fixture ()
@@ -987,7 +998,7 @@ internal class MessageComposerControllerTest {
987998 controller.clearActiveCommand()
988999 advanceUntilIdle()
9891000
990- // Then: reply action survives the enter/cancel round trip
1001+ // Then
9911002 assertEquals(replyAction, controller.state.value.action)
9921003 assertNull(controller.state.value.activeCommand)
9931004 }
@@ -1021,7 +1032,7 @@ internal class MessageComposerControllerTest {
10211032 @Test
10221033 fun `Given edit mode When user types slash Then suggestions stay empty and event is emitted` () = runTest {
10231034 // Given
1024- val command = Command (" giphy " , " Search GIFs " , " [text] " , " fun_set" )
1035+ val command = Command (name = randomString(), description = randomString(), args = randomString(), set = " fun_set" )
10251036 val editedMessage = randomMessage(cid = CID , text = " " )
10261037 val editAction = Edit (editedMessage)
10271038 val controller = Fixture ()
@@ -1050,9 +1061,19 @@ internal class MessageComposerControllerTest {
10501061
10511062 @Test
10521063 fun `Given slash typed When action becomes Reply Then suggestions re-sort by availability` () = runTest {
1053- // Given: moderation command listed first, fun command second (default server order)
1054- val muteCommand = Command (" mute" , " Mute user" , " [@username]" , " moderation_set" )
1055- val giphyCommand = Command (" giphy" , " Search GIFs" , " [text]" , " fun_set" )
1064+ // Given
1065+ val muteCommand = Command (
1066+ name = randomString(),
1067+ description = randomString(),
1068+ args = randomString(),
1069+ set = " moderation_set" ,
1070+ )
1071+ val giphyCommand = Command (
1072+ name = randomString(),
1073+ description = randomString(),
1074+ args = randomString(),
1075+ set = " fun_set" ,
1076+ )
10561077 val repliedMessage = randomMessage(cid = CID )
10571078 val controller = Fixture ()
10581079 .givenConfig(MessageComposerController .Config (activeCommandEnabled = true ))
@@ -1066,14 +1087,13 @@ internal class MessageComposerControllerTest {
10661087 .get()
10671088 controller.setMessageInput(" /" )
10681089 advanceUntilIdle()
1069- // Sanity: with no action, server order is preserved.
10701090 assertEquals(listOf (muteCommand, giphyCommand), controller.state.value.commandSuggestions)
10711091
10721092 // When
10731093 controller.performMessageAction(Reply (repliedMessage))
10741094 advanceUntilIdle()
10751095
1076- // Then: available (giphy) first, unavailable (mute) last
1096+ // Then
10771097 assertEquals(listOf (giphyCommand, muteCommand), controller.state.value.commandSuggestions)
10781098 }
10791099
0 commit comments