Skip to content

Commit

Permalink
Increasing timeouts from 100 to 250ms and adding timeouts to all othe…
Browse files Browse the repository at this point in the history
…r tests in realtime store (#27)
  • Loading branch information
stigi authored Oct 9, 2024
1 parent a432c65 commit dd302cb
Showing 1 changed file with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.NewNotification("NewNotification"))

// THEN
delay(250)
coVerify(exactly = 2, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.size.shouldBeExactly(defaultEdgeArraySize)
storePage.notifications.mapIndexed { index, notif ->
Expand All @@ -160,6 +161,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadNotification(chosenIndex.toString()))

// THEN
delay(250)
coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.size.shouldBeExactly(defaultEdgeArraySize)
store.totalCount.shouldBeExactly(initialCounter.totalCount)
Expand All @@ -184,6 +186,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadNotification(chosenIndex.toString()))

// THEN
delay(250)
store[chosenIndex].readAt.shouldNotBeNull()
coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.size.shouldBeExactly(defaultEdgeArraySize)
Expand All @@ -209,6 +212,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadNotification(chosenIndex.toString()))

// THEN
delay(250)
store[chosenIndex].readAt.shouldNotBeNull()
store[chosenIndex].seenAt.shouldNotBeNull()
coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
Expand All @@ -235,6 +239,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadNotification("Not exists"))

// THEN
delay(250)
coVerify(exactly = 2, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.size.shouldBeExactly(defaultEdgeArraySize)
store.totalCount.shouldBeExactly(initialCounter.totalCount)
Expand All @@ -261,6 +266,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.UnreadNotification(chosenIndex.toString()))

// THEN
delay(250)
store[chosenIndex].readAt.shouldBeNull()
coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.size.shouldBeExactly(defaultEdgeArraySize)
Expand All @@ -287,6 +293,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.UnreadNotification(chosenIndex.toString()))

// THEN
delay(250)
store[chosenIndex].readAt.shouldBeNull()
coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.size.shouldBeExactly(defaultEdgeArraySize)
Expand All @@ -311,6 +318,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.UnreadNotification("Not exists"))

// THEN
delay(250)
coVerify(exactly = 2, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.size.shouldBeExactly(defaultEdgeArraySize)
Unit
Expand All @@ -334,6 +342,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.DeleteNotification(chosenIndex.toString()))

// THEN
delay(250)
coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.totalCount.shouldBeExactly(initialCounter.totalCount - 1)
store.unreadCount.shouldBeExactly(initialCounter.unreadCount - 1)
Expand All @@ -359,6 +368,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.DeleteNotification(chosenIndex.toString()))

// THEN
delay(250)
coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.unseenCount.shouldBeExactly(initialCounter.unseenCount - 1)
Unit
Expand All @@ -381,6 +391,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.DeleteNotification(chosenIndex.toString()))

// THEN
delay(250)
coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.unseenCount.shouldBeExactly(initialCounter.unseenCount)
Unit
Expand All @@ -402,6 +413,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.DeleteNotification("Not exists"))

// THEN
delay(250)
coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.totalCount.shouldBeExactly(initialCounter.totalCount)
store.unreadCount.shouldBeExactly(initialCounter.unreadCount)
Expand All @@ -424,6 +436,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadAllNotification)

// THEN
delay(250)
coVerify(exactly = 2, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.size.shouldBeExactly(defaultEdgeArraySize)
store.forEach { notification ->
Expand All @@ -446,6 +459,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.SeenAllNotification)

// THEN
delay(250)
coVerify(exactly = 2, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.size.shouldBeExactly(defaultEdgeArraySize)
store.forEach { notification ->
Expand All @@ -471,7 +485,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.NewNotification("NewNotification"))

// THEN
delay(100)
delay(250)
contentObserver.reloadStoreCounter.shouldBeExactly(1)
contentObserver.reloadStoreSpy.shouldNotBeEmpty()
Unit
Expand All @@ -495,6 +509,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadNotification(chosenIndex.toString()))

// THEN
delay(250)
contentObserver.reloadStoreCounter.shouldBeExactly(0)
contentObserver.didChangeCounter.shouldBeExactly(1)
contentObserver.didChangeSpy[0].indexes.shouldBe(listOf(chosenIndex))
Expand All @@ -517,7 +532,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadNotification("Not exists"))

// THEN
delay(100)
delay(250)
contentObserver.reloadStoreCounter.shouldBeExactly(1)
contentObserver.didChangeCounter.shouldBeExactly(0)
Unit
Expand All @@ -542,6 +557,7 @@ internal class NotificationStoreRealTimeTests {


// THEN
delay(250)
contentObserver.reloadStoreCounter.shouldBeExactly(0)
contentObserver.didChangeCounter.shouldBeExactly(0)
contentObserver.didDeleteCounter.shouldBeExactly(1)
Expand All @@ -566,6 +582,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.DeleteNotification(chosenIndex.toString()))

// THEN
delay(250)
contentObserver.reloadStoreCounter.shouldBeExactly(0)
contentObserver.didChangeCounter.shouldBeExactly(0)
contentObserver.didDeleteCounter.shouldBeExactly(1)
Expand All @@ -590,6 +607,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadAllNotification)

// THEN
delay(250)
contentObserver.reloadStoreCounter.shouldBeExactly(0)
contentObserver.didChangeCounter.shouldBeExactly(0)
contentObserver.didDeleteCounter.shouldBeExactly(1)
Expand Down Expand Up @@ -618,6 +636,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.SeenAllNotification)

// THEN
delay(250)
contentObserver.reloadStoreCounter.shouldBeExactly(0)
contentObserver.didChangeCounter.shouldBeExactly(0)
contentObserver.didDeleteCounter.shouldBeExactly(1)
Expand Down Expand Up @@ -645,7 +664,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.NewNotification("NewId"))

// THEN
delay(100)
delay(250)
countObserver.totalCountCounter.shouldBeExactly(2)
countObserver.unreadCountCounter.shouldBeExactly(2)
countObserver.unseenCountCounter.shouldBeExactly(2)
Expand All @@ -672,6 +691,7 @@ internal class NotificationStoreRealTimeTests {


// THEN
delay(250)
countObserver.totalCountCounter.shouldBeExactly(1)
countObserver.totalCountSpy[0].count.shouldBeExactly(store.totalCount)
countObserver.unreadCountCounter.shouldBeExactly(2)
Expand All @@ -698,7 +718,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadNotification(chosenIndex.toString()))

// THEN
delay(100)
delay(250)
countObserver.totalCountCounter.shouldBeExactly(1)
countObserver.totalCountSpy[0].count.shouldBeExactly(store.size)
countObserver.unreadCountCounter.shouldBeExactly(0)
Expand All @@ -724,6 +744,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadNotification(chosenIndex.toString()))

// THEN
delay(250)
countObserver.totalCountCounter.shouldBeExactly(1)
countObserver.totalCountSpy[0].count.shouldBeExactly(store.size)
countObserver.unseenCountCounter.shouldBeExactly(2)
Expand All @@ -750,6 +771,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadNotification(chosenIndex.toString()))

// THEN
delay(250)
countObserver.totalCountCounter.shouldBeExactly(1)
countObserver.totalCountSpy[0].count.shouldBeExactly(store.size)
countObserver.unseenCountCounter.shouldBeExactly(0)
Expand All @@ -775,7 +797,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadNotification(chosenIndex.toString()))

// THEN
delay(100)
delay(250)
countObserver.totalCountCounter.shouldBeExactly(2)
countObserver.unreadCountCounter.shouldBeExactly(2)
countObserver.unreadCountSpy[0].count.shouldBeExactly(initialCounts.unreadCount)
Expand All @@ -800,6 +822,8 @@ internal class NotificationStoreRealTimeTests {
val chosenIndex = anyIndexForDefaultEdgeArraySize
storeRealTime.processMessage(RealTimeEventMock.ReadNotification(chosenIndex.toString()))

// THEN
delay(250)
countObserver.totalCountCounter.shouldBeExactly(1)
countObserver.unreadCountCounter.shouldBeExactly(0)
Unit
Expand All @@ -824,6 +848,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadNotification(chosenIndex.toString()))

// THEN
delay(250)
countObserver.totalCountCounter.shouldBeExactly(2)
countObserver.totalCountSpy[0].count.shouldBeExactly(initialCounts.totalCount)
countObserver.totalCountSpy[1].count.shouldBeExactly(initialCounts.totalCount - 1)
Expand Down Expand Up @@ -852,6 +877,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadNotification(chosenIndex.toString()))

// THEN
delay(250)
countObserver.totalCountCounter.shouldBeExactly(2)
countObserver.totalCountSpy[0].count.shouldBeExactly(initialCounts.totalCount)
countObserver.totalCountSpy[1].count.shouldBeExactly(initialCounts.totalCount - 1)
Expand All @@ -878,7 +904,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.ReadAllNotification)

// THEN
delay(100)
delay(250)
countObserver.totalCountCounter.shouldBeExactly(2)
countObserver.unreadCountCounter.shouldBeExactly(1)
countObserver.unreadCountSpy[0].count.shouldBeExactly(initialCounts.unreadCount)
Expand All @@ -905,7 +931,7 @@ internal class NotificationStoreRealTimeTests {
storeRealTime.processMessage(RealTimeEventMock.SeenAllNotification)

// THEN
delay(100)
delay(250)
countObserver.totalCountCounter.shouldBeExactly(2)
countObserver.unreadCountCounter.shouldBeExactly(1)
countObserver.unreadCountSpy[0].count.shouldBeExactly(initialCounts.unreadCount)
Expand All @@ -932,6 +958,7 @@ internal class NotificationStoreRealTimeTests {
store.fetch().getOrThrow()

// THEN
delay(250)
countObserver.totalCountCounter.shouldBeExactly(0)
Unit
}
Expand All @@ -954,6 +981,7 @@ internal class NotificationStoreRealTimeTests {
store.fetch().getOrThrow()

// THEN
delay(250)
contentObserver.didInsertCounter.shouldBeExactly(0)
Unit
}
Expand All @@ -977,6 +1005,7 @@ internal class NotificationStoreRealTimeTests {
)

// THEN
delay(250)
coVerify(exactly = 1, timeout = 1000) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.size.shouldBeExactly(defaultEdgeArraySize - 1)
store.totalCount.shouldBeExactly(initialCounter.totalCount - 1)
Expand Down

0 comments on commit dd302cb

Please sign in to comment.