Skip to content

Commit

Permalink
fix: keep the composed message when replying [WPB-982] (#2969)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorhugods authored May 3, 2024
1 parent 933883e commit a0ae53d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class MessageComposerStateHolder(
}

fun toReply(message: UIMessage.Regular) {
messageCompositionHolder.clearMessage()
messageCompositionHolder.setReply(message)
messageCompositionInputStateHolder.toComposing()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ class MessageComposerStateHolderTest {
runTest {
// given
// when
state.toReply(
message = mockMessageWithText
)
state.toReply(mockMessageWithText)

// then
assertEquals(
Expand All @@ -133,6 +131,22 @@ class MessageComposerStateHolderTest {
)
}

@Test
fun `given some message was being composed, when setting toReply, then input continues with the current text`() = runTest {
// given
val currentTextField = TextFieldValue("Potato")
messageCompositionHolder.setMessageText(currentTextField, {}, {}, {})

// when
state.toReply(mockMessageWithText)

// then
assertEquals(
currentTextField.text,
messageCompositionHolder.messageComposition.value.messageTextFieldValue.text
)
}

@Test
fun `given state, when input focus change to false, then clear focus`() = runTest {
// given
Expand Down

0 comments on commit a0ae53d

Please sign in to comment.