Skip to content

Commit be6b153

Browse files
committed
Add more tests
1 parent 576b335 commit be6b153

File tree

11 files changed

+134
-9
lines changed

11 files changed

+134
-9
lines changed

stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/UserDtoTestData.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.getstream.chat.android.client.parser2.testdata
1818

19+
import io.getstream.chat.android.client.api2.model.dto.DeliveryReceiptsDto
1920
import io.getstream.chat.android.client.api2.model.dto.DeviceDto
2021
import io.getstream.chat.android.client.api2.model.dto.DownstreamMuteDto
2122
import io.getstream.chat.android.client.api2.model.dto.DownstreamPushPreferenceDto
@@ -146,6 +147,9 @@ internal object UserDtoTestData {
146147
},
147148
"read_receipts": {
148149
"enabled": false
150+
},
151+
"delivery_receipts": {
152+
"enabled": false
149153
}
150154
},
151155
"language": "language",
@@ -201,6 +205,9 @@ internal object UserDtoTestData {
201205
read_receipts = ReadReceiptsDto(
202206
enabled = false,
203207
),
208+
delivery_receipts = DeliveryReceiptsDto(
209+
enabled = false,
210+
),
204211
),
205212
language = "language",
206213
role = "owner",
@@ -282,6 +289,9 @@ internal object UserDtoTestData {
282289
},
283290
"read_receipts": {
284291
"enabled": false
292+
},
293+
"delivery_receipts": {
294+
"enabled": false
285295
}
286296
},
287297
"language": "language",
@@ -311,6 +321,9 @@ internal object UserDtoTestData {
311321
read_receipts = ReadReceiptsDto(
312322
enabled = false,
313323
),
324+
delivery_receipts = DeliveryReceiptsDto(
325+
enabled = false,
326+
),
314327
),
315328
banned = false,
316329
devices = listOf(DeviceDto(id = "deviceId", push_provider = "provider", push_provider_name = "provider_name")),
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2014-2025 Stream.io Inc. All rights reserved.
3+
*
4+
* Licensed under the Stream License;
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://github.com/GetStream/stream-chat-android/blob/main/LICENSE
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.getstream.chat.android.client.persistence.db.converter
18+
19+
import io.getstream.chat.android.randomLong
20+
import org.junit.Test
21+
import org.junit.jupiter.api.Assertions.assertEquals
22+
import org.junit.jupiter.api.Assertions.assertNull
23+
import java.util.Date
24+
25+
internal class DateConverterTest {
26+
27+
private val sut = DateConverter()
28+
29+
@Test
30+
fun `fromDb with a valid non null Long`() {
31+
val timestamp = randomLong()
32+
val date = Date(timestamp)
33+
34+
val actual = sut.fromDb(timestamp)
35+
36+
assertEquals(date, actual)
37+
}
38+
39+
@Test
40+
fun `toDb with a valid non null Date`() {
41+
val timestamp = randomLong()
42+
val date = Date(timestamp)
43+
44+
val actual = sut.toDb(date)
45+
46+
assertEquals(timestamp, actual)
47+
}
48+
49+
@Test
50+
fun `fromDb with a null Long`() {
51+
val actual = sut.fromDb(null)
52+
53+
assertNull(actual)
54+
}
55+
56+
@Test
57+
fun `toDb with a null Date`() {
58+
val actual = sut.toDb(null)
59+
60+
assertNull(actual)
61+
}
62+
}

stream-chat-android-compose/api/stream-chat-android-compose.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,13 +1262,15 @@ public final class io/getstream/chat/android/compose/ui/channels/list/Composable
12621262
public static field lambda-4 Lkotlin/jvm/functions/Function2;
12631263
public static field lambda-5 Lkotlin/jvm/functions/Function2;
12641264
public static field lambda-6 Lkotlin/jvm/functions/Function2;
1265+
public static field lambda-7 Lkotlin/jvm/functions/Function2;
12651266
public fun <init> ()V
12661267
public final fun getLambda-1$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
12671268
public final fun getLambda-2$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
12681269
public final fun getLambda-3$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
12691270
public final fun getLambda-4$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
12701271
public final fun getLambda-5$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
12711272
public final fun getLambda-6$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
1273+
public final fun getLambda-7$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function2;
12721274
}
12731275

12741276
public final class io/getstream/chat/android/compose/ui/channels/list/ComposableSingletons$ChannelListKt {

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channels/list/ChannelItem.kt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:Suppress("TooManyFunctions")
18+
1719
package io.getstream.chat.android.compose.ui.channels.list
1820

1921
import androidx.compose.foundation.ExperimentalFoundationApi
@@ -46,6 +48,7 @@ import androidx.compose.ui.tooling.preview.Preview
4648
import androidx.compose.ui.unit.dp
4749
import androidx.compose.ui.unit.sp
4850
import io.getstream.chat.android.client.extensions.currentUserUnreadCount
51+
import io.getstream.chat.android.client.extensions.internal.NEVER
4952
import io.getstream.chat.android.compose.R
5053
import io.getstream.chat.android.compose.state.channels.list.ItemState
5154
import io.getstream.chat.android.compose.ui.components.Timestamp
@@ -58,6 +61,7 @@ import io.getstream.chat.android.models.User
5861
import io.getstream.chat.android.previewdata.PreviewChannelData
5962
import io.getstream.chat.android.previewdata.PreviewChannelUserRead
6063
import io.getstream.chat.android.previewdata.PreviewUserData
64+
import java.util.Date
6165

6266
/**
6367
* The basic channel item, that shows the channel in a list and exposes single and long click actions.
@@ -396,6 +400,32 @@ internal fun ChannelItemLastMessageSentStatus() {
396400
)
397401
}
398402

403+
@Preview(showBackground = true)
404+
@Composable
405+
private fun ChannelItemLastMessageDeliveredStatusPreview() {
406+
ChatTheme {
407+
ChannelItemLastMessageDeliveredStatus()
408+
}
409+
}
410+
411+
@Composable
412+
internal fun ChannelItemLastMessageDeliveredStatus() {
413+
ChannelItem(
414+
currentUser = PreviewUserData.user1,
415+
channel = PreviewChannelData.channelWithMessages.copy(
416+
messages = PreviewChannelData.channelWithMessages.messages.map { message ->
417+
message.copy(user = PreviewUserData.user1)
418+
},
419+
read = listOf(
420+
PreviewChannelUserRead.channelUserRead2.copy(
421+
lastRead = NEVER,
422+
lastDeliveredAt = Date(),
423+
),
424+
),
425+
),
426+
)
427+
}
428+
399429
@Preview(showBackground = true)
400430
@Composable
401431
private fun ChannelItemLastMessageSeenStatusPreview() {

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/MessageReadStatusIcon.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private fun IsDeliveredIcon(modifier: Modifier) {
172172
contentDescription = stringResource(
173173
R.string.stream_ui_message_list_semantics_message_status_delivered,
174174
),
175-
tint = ChatTheme.colors.disabled,
175+
tint = ChatTheme.colors.textLowEmphasis,
176176
)
177177
}
178178

stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/ui/channels/ChannelItemTest.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import app.cash.paparazzi.DeviceConfig
2020
import app.cash.paparazzi.Paparazzi
2121
import io.getstream.chat.android.compose.ui.PaparazziComposeTest
2222
import io.getstream.chat.android.compose.ui.channels.list.ChannelItemDraftMessage
23+
import io.getstream.chat.android.compose.ui.channels.list.ChannelItemLastMessageDeliveredStatus
2324
import io.getstream.chat.android.compose.ui.channels.list.ChannelItemLastMessageSeenStatus
2425
import io.getstream.chat.android.compose.ui.channels.list.ChannelItemLastMessageSentStatus
2526
import io.getstream.chat.android.compose.ui.channels.list.ChannelItemMuted
@@ -61,6 +62,13 @@ internal class ChannelItemTest : PaparazziComposeTest {
6162
}
6263
}
6364

65+
@Test
66+
fun `last message delivered status`() {
67+
snapshotWithDarkMode {
68+
ChannelItemLastMessageDeliveredStatus()
69+
}
70+
}
71+
6472
@Test
6573
fun `last message seen status`() {
6674
snapshotWithDarkMode {
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)