Draft : makes sure all existing tests passes
This commit is contained in:
parent
dfae2e50c9
commit
ece740322c
6 changed files with 29 additions and 31 deletions
|
|
@ -336,7 +336,7 @@ class MessagesPresenterTest {
|
||||||
val finalState = awaitItem()
|
val finalState = awaitItem()
|
||||||
assertThat(finalState.composerState.mode).isInstanceOf(MessageComposerMode.Reply::class.java)
|
assertThat(finalState.composerState.mode).isInstanceOf(MessageComposerMode.Reply::class.java)
|
||||||
val replyMode = finalState.composerState.mode as MessageComposerMode.Reply
|
val replyMode = finalState.composerState.mode as MessageComposerMode.Reply
|
||||||
assertThat(replyMode.replyToDetails).isInstanceOf(InReplyToDetails.Ready::class.java)
|
assertThat(replyMode.replyToDetails).isInstanceOf(InReplyToDetails.Loading::class.java)
|
||||||
assertThat(finalState.actionListState.target).isEqualTo(ActionListState.Target.None)
|
assertThat(finalState.actionListState.target).isEqualTo(ActionListState.Target.None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -369,7 +369,7 @@ class MessagesPresenterTest {
|
||||||
val finalState = awaitItem()
|
val finalState = awaitItem()
|
||||||
assertThat(finalState.composerState.mode).isInstanceOf(MessageComposerMode.Reply::class.java)
|
assertThat(finalState.composerState.mode).isInstanceOf(MessageComposerMode.Reply::class.java)
|
||||||
val replyMode = finalState.composerState.mode as MessageComposerMode.Reply
|
val replyMode = finalState.composerState.mode as MessageComposerMode.Reply
|
||||||
assertThat(replyMode.replyToDetails).isInstanceOf(InReplyToDetails.Ready::class.java)
|
assertThat(replyMode.replyToDetails).isInstanceOf(InReplyToDetails.Loading::class.java)
|
||||||
assertThat(finalState.actionListState.target).isEqualTo(ActionListState.Target.None)
|
assertThat(finalState.actionListState.target).isEqualTo(ActionListState.Target.None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -395,7 +395,7 @@ class MessagesPresenterTest {
|
||||||
val finalState = awaitItem()
|
val finalState = awaitItem()
|
||||||
assertThat(finalState.composerState.mode).isInstanceOf(MessageComposerMode.Reply::class.java)
|
assertThat(finalState.composerState.mode).isInstanceOf(MessageComposerMode.Reply::class.java)
|
||||||
val replyMode = finalState.composerState.mode as MessageComposerMode.Reply
|
val replyMode = finalState.composerState.mode as MessageComposerMode.Reply
|
||||||
assertThat(replyMode.replyToDetails).isInstanceOf(InReplyToDetails.Ready::class.java)
|
assertThat(replyMode.replyToDetails).isInstanceOf(InReplyToDetails.Loading::class.java)
|
||||||
assertThat(finalState.actionListState.target).isEqualTo(ActionListState.Target.None)
|
assertThat(finalState.actionListState.target).isEqualTo(ActionListState.Target.None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -741,7 +741,7 @@ class MessagesPresenterTest {
|
||||||
assertThat(finalState.composerState.mode).isInstanceOf(MessageComposerMode.Reply::class.java)
|
assertThat(finalState.composerState.mode).isInstanceOf(MessageComposerMode.Reply::class.java)
|
||||||
val replyMode = finalState.composerState.mode as MessageComposerMode.Reply
|
val replyMode = finalState.composerState.mode as MessageComposerMode.Reply
|
||||||
|
|
||||||
assertThat(replyMode.replyToDetails).isInstanceOf(InReplyToDetails.Ready::class.java)
|
assertThat(replyMode.replyToDetails).isInstanceOf(InReplyToDetails.Loading::class.java)
|
||||||
assertThat(finalState.actionListState.target).isEqualTo(ActionListState.Target.None)
|
assertThat(finalState.actionListState.target).isEqualTo(ActionListState.Target.None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,6 @@ class MessageComposerPresenterTest {
|
||||||
state.eventSink.invoke(MessageComposerEvents.SetMode(mode))
|
state.eventSink.invoke(MessageComposerEvents.SetMode(mode))
|
||||||
state = awaitItem()
|
state = awaitItem()
|
||||||
assertThat(state.mode).isEqualTo(mode)
|
assertThat(state.mode).isEqualTo(mode)
|
||||||
state = awaitItem()
|
|
||||||
assertThat(state.textEditorState.messageHtml()).isEqualTo(A_MESSAGE)
|
assertThat(state.textEditorState.messageHtml()).isEqualTo(A_MESSAGE)
|
||||||
state = backToNormalMode(state, skipCount = 1)
|
state = backToNormalMode(state, skipCount = 1)
|
||||||
|
|
||||||
|
|
@ -224,22 +223,6 @@ class MessageComposerPresenterTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `present - change mode to quote`() = runTest {
|
|
||||||
val presenter = createPresenter(this)
|
|
||||||
moleculeFlow(RecompositionMode.Immediate) {
|
|
||||||
presenter.present()
|
|
||||||
}.test {
|
|
||||||
var state = awaitFirstItem()
|
|
||||||
val mode = aQuoteMode()
|
|
||||||
state.eventSink.invoke(MessageComposerEvents.SetMode(mode))
|
|
||||||
state = awaitItem()
|
|
||||||
assertThat(state.mode).isEqualTo(mode)
|
|
||||||
assertThat(state.textEditorState.messageHtml()).isEqualTo("")
|
|
||||||
backToNormalMode(state)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - send message with rich text enabled`() = runTest {
|
fun `present - send message with rich text enabled`() = runTest {
|
||||||
val presenter = createPresenter(this)
|
val presenter = createPresenter(this)
|
||||||
|
|
@ -316,7 +299,6 @@ class MessageComposerPresenterTest {
|
||||||
assertThat(initialState.textEditorState.messageHtml()).isEqualTo("")
|
assertThat(initialState.textEditorState.messageHtml()).isEqualTo("")
|
||||||
val mode = anEditMode()
|
val mode = anEditMode()
|
||||||
initialState.eventSink.invoke(MessageComposerEvents.SetMode(mode))
|
initialState.eventSink.invoke(MessageComposerEvents.SetMode(mode))
|
||||||
skipItems(1)
|
|
||||||
val withMessageState = awaitItem()
|
val withMessageState = awaitItem()
|
||||||
assertThat(withMessageState.mode).isEqualTo(mode)
|
assertThat(withMessageState.mode).isEqualTo(mode)
|
||||||
assertThat(withMessageState.textEditorState.messageHtml()).isEqualTo(A_MESSAGE)
|
assertThat(withMessageState.textEditorState.messageHtml()).isEqualTo(A_MESSAGE)
|
||||||
|
|
@ -366,7 +348,6 @@ class MessageComposerPresenterTest {
|
||||||
assertThat(initialState.textEditorState.messageHtml()).isEqualTo("")
|
assertThat(initialState.textEditorState.messageHtml()).isEqualTo("")
|
||||||
val mode = anEditMode(eventId = null, transactionId = A_TRANSACTION_ID)
|
val mode = anEditMode(eventId = null, transactionId = A_TRANSACTION_ID)
|
||||||
initialState.eventSink.invoke(MessageComposerEvents.SetMode(mode))
|
initialState.eventSink.invoke(MessageComposerEvents.SetMode(mode))
|
||||||
skipItems(1)
|
|
||||||
val withMessageState = awaitItem()
|
val withMessageState = awaitItem()
|
||||||
assertThat(withMessageState.mode).isEqualTo(mode)
|
assertThat(withMessageState.mode).isEqualTo(mode)
|
||||||
assertThat(withMessageState.textEditorState.messageHtml()).isEqualTo(A_MESSAGE)
|
assertThat(withMessageState.textEditorState.messageHtml()).isEqualTo(A_MESSAGE)
|
||||||
|
|
@ -1085,7 +1066,6 @@ fun anEditMode(
|
||||||
) = MessageComposerMode.Edit(eventId, transactionId, message)
|
) = MessageComposerMode.Edit(eventId, transactionId, message)
|
||||||
|
|
||||||
fun aReplyMode() = MessageComposerMode.Reply(replyToDetails = InReplyToDetails.Loading(AN_EVENT_ID))
|
fun aReplyMode() = MessageComposerMode.Reply(replyToDetails = InReplyToDetails.Loading(AN_EVENT_ID))
|
||||||
fun aQuoteMode() = MessageComposerMode.Quote(AN_EVENT_ID, A_MESSAGE)
|
|
||||||
|
|
||||||
private suspend fun TextEditorState.setHtml(html: String) {
|
private suspend fun TextEditorState.setHtml(html: String) {
|
||||||
(this as? TextEditorState.Rich)?.richTextEditorState?.setHtml(html) ?: error("TextEditorState is not Rich")
|
(this as? TextEditorState.Rich)?.richTextEditorState?.setHtml(html) ?: error("TextEditorState is not Rich")
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ package io.element.android.libraries.matrix.api.room.draft
|
||||||
|
|
||||||
import io.element.android.libraries.matrix.api.core.EventId
|
import io.element.android.libraries.matrix.api.core.EventId
|
||||||
|
|
||||||
sealed class ComposerDraftType {
|
sealed interface ComposerDraftType {
|
||||||
data object NewMessage : ComposerDraftType()
|
data object NewMessage : ComposerDraftType
|
||||||
data class Reply(val eventId: EventId) : ComposerDraftType()
|
data class Reply(val eventId: EventId) : ComposerDraftType
|
||||||
data class Edit(val eventId: EventId) : ComposerDraftType()
|
data class Edit(val eventId: EventId) : ComposerDraftType
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,11 @@ plugins {
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "io.element.android.libraries.matrix.ui"
|
namespace = "io.element.android.libraries.matrix.ui"
|
||||||
|
testOptions {
|
||||||
|
unitTests {
|
||||||
|
isIncludeAndroidResources = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
anvil {
|
anvil {
|
||||||
|
|
@ -47,7 +52,15 @@ dependencies {
|
||||||
ksp(libs.showkase.processor)
|
ksp(libs.showkase.processor)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testImplementation(libs.test.junit)
|
||||||
|
testImplementation(libs.coroutines.test)
|
||||||
|
testImplementation(libs.molecule.runtime)
|
||||||
testImplementation(libs.test.truth)
|
testImplementation(libs.test.truth)
|
||||||
testImplementation(libs.test.robolectric)
|
testImplementation(libs.test.turbine)
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
|
testImplementation(projects.libraries.dateformatter.test)
|
||||||
|
testImplementation(projects.tests.testutils)
|
||||||
|
testImplementation(libs.test.mockk)
|
||||||
|
testImplementation(libs.test.robolectric)
|
||||||
|
testImplementation(libs.androidx.compose.ui.test.junit)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.element.android.features.messages.impl.timeline.model
|
package io.element.android.libraries.matrixui.messages.reply
|
||||||
|
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import io.element.android.libraries.matrix.api.timeline.item.event.FormattedBody
|
import io.element.android.libraries.matrix.api.timeline.item.event.FormattedBody
|
||||||
|
|
@ -28,6 +28,8 @@ import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
||||||
import io.element.android.libraries.matrix.test.A_USER_ID
|
import io.element.android.libraries.matrix.test.A_USER_ID
|
||||||
import io.element.android.libraries.matrix.test.permalink.FakePermalinkParser
|
import io.element.android.libraries.matrix.test.permalink.FakePermalinkParser
|
||||||
import io.element.android.libraries.matrix.test.timeline.aProfileTimelineDetails
|
import io.element.android.libraries.matrix.test.timeline.aProfileTimelineDetails
|
||||||
|
import io.element.android.libraries.matrix.ui.messages.reply.InReplyToDetails
|
||||||
|
import io.element.android.libraries.matrix.ui.messages.reply.map
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class InReplyToDetailTest {
|
class InReplyToDetailTest {
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.element.android.features.messages.impl.timeline.model
|
package io.element.android.libraries.matrixui.messages.reply
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
|
@ -60,6 +60,9 @@ import io.element.android.libraries.matrix.test.timeline.aProfileTimelineDetails
|
||||||
import io.element.android.libraries.matrix.ui.components.A_BLUR_HASH
|
import io.element.android.libraries.matrix.ui.components.A_BLUR_HASH
|
||||||
import io.element.android.libraries.matrix.ui.components.AttachmentThumbnailInfo
|
import io.element.android.libraries.matrix.ui.components.AttachmentThumbnailInfo
|
||||||
import io.element.android.libraries.matrix.ui.components.AttachmentThumbnailType
|
import io.element.android.libraries.matrix.ui.components.AttachmentThumbnailType
|
||||||
|
import io.element.android.libraries.matrix.ui.messages.reply.InReplyToDetails
|
||||||
|
import io.element.android.libraries.matrix.ui.messages.reply.InReplyToMetadata
|
||||||
|
import io.element.android.libraries.matrix.ui.messages.reply.metadata
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
Loading…
Add table
Add a link
Reference in a new issue