mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Update test with Claude
This commit is contained in:
committed by
Benoit Marty
parent
25989135a8
commit
eb37c7bd55
+12
-3
@@ -568,7 +568,10 @@ class MessagesViewTest : RobolectricTest() {
|
||||
setMessagesView(
|
||||
state = aMessagesState(
|
||||
timelineState = aTimelineState(
|
||||
sendFailureDialogState = SendFailureDialogState.Show(event = timelineItem, message = "Error"),
|
||||
sendFailureDialogState = SendFailureDialogState.Show(
|
||||
event = timelineItem,
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.Error("Error"),
|
||||
),
|
||||
eventSink = timelineEventsRecorder,
|
||||
),
|
||||
eventSink = messagesEventsRecorder,
|
||||
@@ -590,7 +593,10 @@ class MessagesViewTest : RobolectricTest() {
|
||||
setMessagesView(
|
||||
state = aMessagesState(
|
||||
timelineState = aTimelineState(
|
||||
sendFailureDialogState = SendFailureDialogState.Show(event = timelineItem, message = "Error"),
|
||||
sendFailureDialogState = SendFailureDialogState.Show(
|
||||
event = timelineItem,
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.Error("Error"),
|
||||
),
|
||||
eventSink = timelineEventsRecorder,
|
||||
),
|
||||
eventSink = messagesEventsRecorder,
|
||||
@@ -612,7 +618,10 @@ class MessagesViewTest : RobolectricTest() {
|
||||
setMessagesView(
|
||||
state = aMessagesState(
|
||||
timelineState = aTimelineState(
|
||||
sendFailureDialogState = SendFailureDialogState.Show(event = timelineItem, message = "Error"),
|
||||
sendFailureDialogState = SendFailureDialogState.Show(
|
||||
event = timelineItem,
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.Error("Error"),
|
||||
),
|
||||
eventSink = timelineEventsRecorder,
|
||||
),
|
||||
eventSink = messagesEventsRecorder,
|
||||
|
||||
+15
-12
@@ -1404,7 +1404,10 @@ class TimelinePresenterTest {
|
||||
initialState.eventSink(TimelineEvent.ShowSendFailureDialog(event))
|
||||
awaitItem().also { state ->
|
||||
assertThat(state.sendFailureDialogState).isEqualTo(
|
||||
SendFailureDialogState.Show(event = event, message = "An error")
|
||||
SendFailureDialogState.Show(
|
||||
event = event,
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.Error("An error"),
|
||||
)
|
||||
)
|
||||
state.eventSink(TimelineEvent.HideSendFailureDialog)
|
||||
}
|
||||
@@ -1416,39 +1419,39 @@ class TimelinePresenterTest {
|
||||
|
||||
@Test
|
||||
fun `present - show send failure dialog - unknown error with a blank reason`() {
|
||||
assertSendFailureDialogMessage(
|
||||
assertSendFailureType(
|
||||
sendState = LocalEventSendState.Failed.Unknown(error = ""),
|
||||
expectedMessage = "Unknown error",
|
||||
expectedSendFailureType = SendFailureDialogState.SendFailureType.Unknown,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `present - show send failure dialog - invalid mime type`() {
|
||||
assertSendFailureDialogMessage(
|
||||
assertSendFailureType(
|
||||
sendState = LocalEventSendState.Failed.InvalidMimeType(mimeType = "invalid/mimeType"),
|
||||
expectedMessage = "Invalid mime type: invalid/mimeType",
|
||||
expectedSendFailureType = SendFailureDialogState.SendFailureType.InvalidMimeType("invalid/mimeType"),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `present - show send failure dialog - missing media content`() {
|
||||
assertSendFailureDialogMessage(
|
||||
assertSendFailureType(
|
||||
sendState = LocalEventSendState.Failed.MissingMediaContent,
|
||||
expectedMessage = "Missing media content",
|
||||
expectedSendFailureType = SendFailureDialogState.SendFailureType.MissingMediaContent,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `present - show send failure dialog - sending from unverified device`() {
|
||||
assertSendFailureDialogMessage(
|
||||
assertSendFailureType(
|
||||
sendState = LocalEventSendState.Failed.SendingFromUnverifiedDevice,
|
||||
expectedMessage = "Sending from unverified device",
|
||||
expectedSendFailureType = SendFailureDialogState.SendFailureType.SendingFromUnverifiedDevice,
|
||||
)
|
||||
}
|
||||
|
||||
private fun assertSendFailureDialogMessage(
|
||||
private fun assertSendFailureType(
|
||||
sendState: LocalEventSendState.Failed,
|
||||
expectedMessage: String,
|
||||
expectedSendFailureType: SendFailureDialogState.SendFailureType,
|
||||
) = runTest {
|
||||
val presenter = createTimelinePresenter()
|
||||
val event = aMessageEvent(sendState = sendState)
|
||||
@@ -1456,7 +1459,7 @@ class TimelinePresenterTest {
|
||||
val initialState = awaitFirstItem()
|
||||
initialState.eventSink(TimelineEvent.ShowSendFailureDialog(event))
|
||||
assertThat(awaitItem().sendFailureDialogState).isEqualTo(
|
||||
SendFailureDialogState.Show(event = event, message = expectedMessage)
|
||||
SendFailureDialogState.Show(event = event, sendFailureType = expectedSendFailureType)
|
||||
)
|
||||
cancelAndIgnoreRemainingEvents()
|
||||
}
|
||||
|
||||
+51
-7
@@ -14,12 +14,14 @@ import androidx.compose.ui.test.AndroidComposeUiTest
|
||||
import androidx.compose.ui.test.ExperimentalTestApi
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.v2.runAndroidComposeUiTest
|
||||
import io.element.android.features.messages.impl.R
|
||||
import io.element.android.features.messages.impl.timeline.aTimelineItemEvent
|
||||
import io.element.android.features.messages.impl.timeline.model.TimelineItem
|
||||
import io.element.android.libraries.matrix.api.timeline.item.event.LocalEventSendState
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
import io.element.android.tests.testutils.EnsureNeverCalled
|
||||
import io.element.android.tests.testutils.EnsureNeverCalledWithParam
|
||||
import io.element.android.tests.testutils.assertNodeWithTextIsDisplayed
|
||||
import io.element.android.tests.testutils.clickOn
|
||||
import io.element.android.tests.testutils.ensureCalledOnce
|
||||
import io.element.android.tests.testutils.ensureCalledOnceWithParam
|
||||
@@ -37,12 +39,54 @@ class SendFailureDialogViewTest : RobolectricTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `show state renders the failure reason`() = runAndroidComposeUiTest {
|
||||
fun `show state renders the error failure reason`() = runAndroidComposeUiTest {
|
||||
setSendFailureDialogView(
|
||||
sendFailureDialogState = aSendFailureDialogStateShow(message = "A failure reason"),
|
||||
sendFailureDialogState = aSendFailureDialogStateShow(
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.Error("A failure reason"),
|
||||
),
|
||||
)
|
||||
onNodeWithText(activity!!.getString(CommonStrings.common_sending_failed)).assertExists()
|
||||
onNodeWithText("A failure reason").assertExists()
|
||||
assertNodeWithTextIsDisplayed(CommonStrings.common_sending_failed)
|
||||
onNodeWithText(activity!!.getString(R.string.error_sending_failure_other, "A failure reason")).assertExists()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `show state renders the invalid mime type failure reason`() = runAndroidComposeUiTest {
|
||||
setSendFailureDialogView(
|
||||
sendFailureDialogState = aSendFailureDialogStateShow(
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.InvalidMimeType("invalid/mimeType"),
|
||||
),
|
||||
)
|
||||
onNodeWithText(activity!!.getString(R.string.error_sending_failure_invalid_mime_type, "invalid/mimeType")).assertExists()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `show state renders the missing media content failure reason`() = runAndroidComposeUiTest {
|
||||
setSendFailureDialogView(
|
||||
sendFailureDialogState = aSendFailureDialogStateShow(
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.MissingMediaContent,
|
||||
),
|
||||
)
|
||||
onNodeWithText(activity!!.getString(R.string.error_sending_failure_missing_media_content)).assertExists()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `show state renders the sending from unverified device failure reason`() = runAndroidComposeUiTest {
|
||||
setSendFailureDialogView(
|
||||
sendFailureDialogState = aSendFailureDialogStateShow(
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.SendingFromUnverifiedDevice,
|
||||
),
|
||||
)
|
||||
onNodeWithText(activity!!.getString(R.string.error_sending_failure_sending_from_unverified_device)).assertExists()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `show state renders the unknown failure reason`() = runAndroidComposeUiTest {
|
||||
setSendFailureDialogView(
|
||||
sendFailureDialogState = aSendFailureDialogStateShow(
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.Unknown,
|
||||
),
|
||||
)
|
||||
onNodeWithText(activity!!.getString(R.string.error_sending_failure_unknown)).assertExists()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,10 +125,10 @@ class SendFailureDialogViewTest : RobolectricTest() {
|
||||
}
|
||||
|
||||
private fun aSendFailureDialogStateShow(
|
||||
message: String = "A failure reason",
|
||||
sendFailureType: SendFailureDialogState.SendFailureType = SendFailureDialogState.SendFailureType.Unknown,
|
||||
) = SendFailureDialogState.Show(
|
||||
event = aTimelineItemEvent(sendState = LocalEventSendState.Failed.Unknown(message)),
|
||||
message = message,
|
||||
event = aTimelineItemEvent(sendState = LocalEventSendState.Failed.Unknown("")),
|
||||
sendFailureType = sendFailureType,
|
||||
)
|
||||
|
||||
private fun AndroidComposeUiTest<ComponentActivity>.setSendFailureDialogView(
|
||||
|
||||
Reference in New Issue
Block a user