Introduce simulateLongTask to ensure that the Presenter State Loading is visible.

Also do some cleanup on the tests.
This commit is contained in:
Benoit Marty 2023-06-15 10:57:05 +02:00
parent 026baf9349
commit 9321a9f718
25 changed files with 169 additions and 180 deletions

View file

@ -69,7 +69,7 @@ internal class DefaultInviteStateDataSourceTest {
val client = FakeMatrixClient(invitesDataSource = matrixDataSource)
val seenStore = FakeSeenInvitesStore()
seenStore.publishRoomIds(setOf(A_ROOM_ID))
val dataSource = DefaultInviteStateDataSource(client, seenStore, testCoroutineDispatchers())
val dataSource = DefaultInviteStateDataSource(client, seenStore, testCoroutineDispatchers(useUnconfinedTestDispatcher = true))
moleculeFlow(RecompositionClock.Immediate) {
dataSource.inviteState()
@ -86,7 +86,7 @@ internal class DefaultInviteStateDataSourceTest {
val client = FakeMatrixClient(invitesDataSource = matrixDataSource)
val seenStore = FakeSeenInvitesStore()
seenStore.publishRoomIds(setOf(A_ROOM_ID))
val dataSource = DefaultInviteStateDataSource(client, seenStore, testCoroutineDispatchers())
val dataSource = DefaultInviteStateDataSource(client, seenStore, testCoroutineDispatchers(useUnconfinedTestDispatcher = true))
moleculeFlow(RecompositionClock.Immediate) {
dataSource.inviteState()

View file

@ -35,7 +35,6 @@ import io.element.android.libraries.matrix.test.AN_AVATAR_URL
import io.element.android.libraries.matrix.test.AN_EXCEPTION
import io.element.android.libraries.matrix.test.A_ROOM_ID
import io.element.android.libraries.matrix.test.A_ROOM_NAME
import io.element.android.libraries.matrix.test.A_SESSION_ID
import io.element.android.libraries.matrix.test.A_USER_ID
import io.element.android.libraries.matrix.test.A_USER_NAME
import io.element.android.libraries.matrix.test.FakeMatrixClient
@ -51,7 +50,7 @@ class RoomListPresenterTests {
@Test
fun `present - should start with no user and then load user with success`() = runTest {
val presenter = RoomListPresenter(
FakeMatrixClient(A_SESSION_ID),
FakeMatrixClient(),
createDateFormatter(),
FakeRoomLastMessageFormatter(),
FakeSessionVerificationService(),
@ -77,7 +76,6 @@ class RoomListPresenterTests {
fun `present - should start with no user and then load user with error`() = runTest {
val presenter = RoomListPresenter(
FakeMatrixClient(
A_SESSION_ID,
userDisplayName = Result.failure(AN_EXCEPTION),
userAvatarURLString = Result.failure(AN_EXCEPTION),
),
@ -102,7 +100,7 @@ class RoomListPresenterTests {
@Test
fun `present - should filter room with success`() = runTest {
val presenter = RoomListPresenter(
FakeMatrixClient(A_SESSION_ID),
FakeMatrixClient(),
createDateFormatter(),
FakeRoomLastMessageFormatter(),
FakeSessionVerificationService(),
@ -130,7 +128,6 @@ class RoomListPresenterTests {
val roomSummaryDataSource = FakeRoomSummaryDataSource()
val presenter = RoomListPresenter(
FakeMatrixClient(
sessionId = A_SESSION_ID,
roomSummaryDataSource = roomSummaryDataSource
),
createDateFormatter(),
@ -163,7 +160,6 @@ class RoomListPresenterTests {
val roomSummaryDataSource = FakeRoomSummaryDataSource()
val presenter = RoomListPresenter(
FakeMatrixClient(
sessionId = A_SESSION_ID,
roomSummaryDataSource = roomSummaryDataSource
),
createDateFormatter(),
@ -202,7 +198,6 @@ class RoomListPresenterTests {
val roomSummaryDataSource = FakeRoomSummaryDataSource()
val presenter = RoomListPresenter(
FakeMatrixClient(
sessionId = A_SESSION_ID,
roomSummaryDataSource = roomSummaryDataSource
),
createDateFormatter(),
@ -251,7 +246,6 @@ class RoomListPresenterTests {
val roomSummaryDataSource = FakeRoomSummaryDataSource()
val presenter = RoomListPresenter(
FakeMatrixClient(
sessionId = A_SESSION_ID,
roomSummaryDataSource = roomSummaryDataSource
),
createDateFormatter(),
@ -280,9 +274,7 @@ class RoomListPresenterTests {
fun `present - sets invite state`() = runTest {
val inviteStateFlow = MutableStateFlow(InvitesState.NoInvites)
val presenter = RoomListPresenter(
FakeMatrixClient(
sessionId = A_SESSION_ID,
),
FakeMatrixClient(),
createDateFormatter(),
FakeRoomLastMessageFormatter(),
FakeSessionVerificationService(),
@ -312,7 +304,7 @@ class RoomListPresenterTests {
@Test
fun `present - show context menu`() = runTest {
val presenter = RoomListPresenter(
FakeMatrixClient(A_SESSION_ID),
FakeMatrixClient(),
createDateFormatter(),
FakeRoomLastMessageFormatter(),
FakeSessionVerificationService(),
@ -339,7 +331,7 @@ class RoomListPresenterTests {
@Test
fun `present - hide context menu`() = runTest {
val presenter = RoomListPresenter(
FakeMatrixClient(A_SESSION_ID),
FakeMatrixClient(),
createDateFormatter(),
FakeRoomLastMessageFormatter(),
FakeSessionVerificationService(),
@ -371,7 +363,7 @@ class RoomListPresenterTests {
fun `present - leave room calls into leave room presenter`() = runTest {
val leaveRoomPresenter = LeaveRoomPresenterFake()
val presenter = RoomListPresenter(
FakeMatrixClient(A_SESSION_ID),
FakeMatrixClient(),
createDateFormatter(),
FakeRoomLastMessageFormatter(),
FakeSessionVerificationService(),