adding missing rich text test usages
This commit is contained in:
parent
e79c5c9a27
commit
eeb13b3f6c
|
@ -1,5 +1,7 @@
|
||||||
package app.dapk.st.notifications
|
package app.dapk.st.notifications
|
||||||
|
|
||||||
|
import app.dapk.st.matrix.common.RichText
|
||||||
|
import app.dapk.st.matrix.common.asString
|
||||||
import fixture.aRoomImageMessageEvent
|
import fixture.aRoomImageMessageEvent
|
||||||
import fixture.aRoomMessageEvent
|
import fixture.aRoomMessageEvent
|
||||||
import fixture.aRoomReplyMessageEvent
|
import fixture.aRoomReplyMessageEvent
|
||||||
|
@ -18,7 +20,7 @@ class RoomEventsToNotifiableMapperTest {
|
||||||
|
|
||||||
result shouldBeEqualTo listOf(
|
result shouldBeEqualTo listOf(
|
||||||
Notifiable(
|
Notifiable(
|
||||||
content = event.content,
|
content = event.content.asString(),
|
||||||
utcTimestamp = event.utcTimestamp,
|
utcTimestamp = event.utcTimestamp,
|
||||||
author = event.author
|
author = event.author
|
||||||
)
|
)
|
||||||
|
@ -42,14 +44,14 @@ class RoomEventsToNotifiableMapperTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given reply event with message, when mapping, then uses message for content`() {
|
fun `given reply event with message, when mapping, then uses message for content`() {
|
||||||
val reply = aRoomMessageEvent(utcTimestamp = -1, content = "hello")
|
val reply = aRoomMessageEvent(utcTimestamp = -1, content = RichText.of("hello"))
|
||||||
val event = aRoomReplyMessageEvent(reply, replyingTo = aRoomImageMessageEvent(utcTimestamp = -1))
|
val event = aRoomReplyMessageEvent(reply, replyingTo = aRoomImageMessageEvent(utcTimestamp = -1))
|
||||||
|
|
||||||
val result = mapper.map(listOf(event))
|
val result = mapper.map(listOf(event))
|
||||||
|
|
||||||
result shouldBeEqualTo listOf(
|
result shouldBeEqualTo listOf(
|
||||||
Notifiable(
|
Notifiable(
|
||||||
content = reply.content,
|
content = reply.content.asString(),
|
||||||
utcTimestamp = event.utcTimestamp,
|
utcTimestamp = event.utcTimestamp,
|
||||||
author = event.author
|
author = event.author
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package app.dapk.st.engine
|
package app.dapk.st.engine
|
||||||
|
|
||||||
import app.dapk.st.matrix.common.EventId
|
import app.dapk.st.matrix.common.EventId
|
||||||
|
import app.dapk.st.matrix.common.RichText
|
||||||
import app.dapk.st.matrix.message.MessageService
|
import app.dapk.st.matrix.message.MessageService
|
||||||
import fixture.*
|
import fixture.*
|
||||||
import org.amshove.kluent.shouldBeEqualTo
|
import org.amshove.kluent.shouldBeEqualTo
|
||||||
|
@ -54,7 +55,7 @@ class MergeWithLocalEchosUseCaseTest {
|
||||||
|
|
||||||
private fun createLocalEcho(eventId: EventId, body: String, state: MessageService.LocalEcho.State) = aLocalEcho(
|
private fun createLocalEcho(eventId: EventId, body: String, state: MessageService.LocalEcho.State) = aLocalEcho(
|
||||||
eventId,
|
eventId,
|
||||||
aTextMessage(aTextContent(body)),
|
aTextMessage(aTextContent(RichText.of(body))),
|
||||||
state,
|
state,
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package app.dapk.st.engine
|
package app.dapk.st.engine
|
||||||
|
|
||||||
|
import app.dapk.st.matrix.common.RichText
|
||||||
import fake.FakeRoomStore
|
import fake.FakeRoomStore
|
||||||
import fixture.NotificationDiffFixtures.aNotificationDiff
|
import fixture.NotificationDiffFixtures.aNotificationDiff
|
||||||
import fixture.aMatrixRoomMessageEvent
|
import fixture.aMatrixRoomMessageEvent
|
||||||
|
@ -15,8 +16,8 @@ import app.dapk.st.matrix.sync.RoomEvent as MatrixRoomEvent
|
||||||
import app.dapk.st.matrix.sync.RoomOverview as MatrixRoomOverview
|
import app.dapk.st.matrix.sync.RoomOverview as MatrixRoomOverview
|
||||||
|
|
||||||
private val NO_UNREADS = emptyMap<MatrixRoomOverview, List<MatrixRoomEvent>>()
|
private val NO_UNREADS = emptyMap<MatrixRoomOverview, List<MatrixRoomEvent>>()
|
||||||
private val A_MESSAGE = aMatrixRoomMessageEvent(eventId = anEventId("1"), content = "hello", utcTimestamp = 1000)
|
private val A_MESSAGE = aMatrixRoomMessageEvent(eventId = anEventId("1"), content = RichText.of("hello"), utcTimestamp = 1000)
|
||||||
private val A_MESSAGE_2 = aMatrixRoomMessageEvent(eventId = anEventId("2"), content = "world", utcTimestamp = 2000)
|
private val A_MESSAGE_2 = aMatrixRoomMessageEvent(eventId = anEventId("2"), content = RichText.of("world"), utcTimestamp = 2000)
|
||||||
private val A_ROOM_OVERVIEW = aMatrixRoomOverview(roomId = aRoomId("1"))
|
private val A_ROOM_OVERVIEW = aMatrixRoomOverview(roomId = aRoomId("1"))
|
||||||
private val A_ROOM_OVERVIEW_2 = aMatrixRoomOverview(roomId = aRoomId("2"))
|
private val A_ROOM_OVERVIEW_2 = aMatrixRoomOverview(roomId = aRoomId("2"))
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package app.dapk.st.engine
|
package app.dapk.st.engine
|
||||||
|
|
||||||
|
import app.dapk.st.matrix.common.RichText
|
||||||
import app.dapk.st.matrix.common.RoomId
|
import app.dapk.st.matrix.common.RoomId
|
||||||
import app.dapk.st.matrix.common.RoomMember
|
import app.dapk.st.matrix.common.RoomMember
|
||||||
import app.dapk.st.matrix.common.UserId
|
import app.dapk.st.matrix.common.UserId
|
||||||
|
@ -24,7 +25,7 @@ import test.delegateReturn
|
||||||
private val A_ROOM_ID = aRoomId()
|
private val A_ROOM_ID = aRoomId()
|
||||||
private val AN_USER_ID = aUserId()
|
private val AN_USER_ID = aUserId()
|
||||||
private val A_ROOM_STATE = aMatrixRoomState()
|
private val A_ROOM_STATE = aMatrixRoomState()
|
||||||
private val A_MERGED_ROOM_STATE = A_ROOM_STATE.copy(events = listOf(aMatrixRoomMessageEvent(content = "a merged event")))
|
private val A_MERGED_ROOM_STATE = A_ROOM_STATE.copy(events = listOf(aMatrixRoomMessageEvent(content = RichText.of("a merged event"))))
|
||||||
private val A_LOCAL_ECHOS_LIST = listOf(aLocalEcho())
|
private val A_LOCAL_ECHOS_LIST = listOf(aLocalEcho())
|
||||||
private val A_ROOM_MEMBER = aRoomMember()
|
private val A_ROOM_MEMBER = aRoomMember()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package fixture
|
package fixture
|
||||||
|
|
||||||
import app.dapk.st.matrix.common.MessageType
|
import app.dapk.st.matrix.common.MessageType
|
||||||
|
import app.dapk.st.matrix.common.RichText
|
||||||
import app.dapk.st.matrix.common.RoomId
|
import app.dapk.st.matrix.common.RoomId
|
||||||
import app.dapk.st.matrix.message.MessageService
|
import app.dapk.st.matrix.message.MessageService
|
||||||
|
|
||||||
|
@ -13,6 +14,6 @@ fun aTextMessage(
|
||||||
) = MessageService.Message.TextMessage(content, sendEncrypted, roomId, localId, timestampUtc)
|
) = MessageService.Message.TextMessage(content, sendEncrypted, roomId, localId, timestampUtc)
|
||||||
|
|
||||||
fun aTextContent(
|
fun aTextContent(
|
||||||
body: String = "text content body",
|
body: RichText = RichText.of("text content body"),
|
||||||
type: String = MessageType.TEXT.value,
|
type: String = MessageType.TEXT.value,
|
||||||
) = MessageService.Message.Content.TextContent(body, type)
|
) = MessageService.Message.Content.TextContent(body, type)
|
||||||
|
|
|
@ -5,8 +5,10 @@ package test
|
||||||
import TestMessage
|
import TestMessage
|
||||||
import TestUser
|
import TestUser
|
||||||
import app.dapk.st.core.extensions.ifNull
|
import app.dapk.st.core.extensions.ifNull
|
||||||
|
import app.dapk.st.matrix.common.RichText
|
||||||
import app.dapk.st.matrix.common.RoomId
|
import app.dapk.st.matrix.common.RoomId
|
||||||
import app.dapk.st.matrix.common.RoomMember
|
import app.dapk.st.matrix.common.RoomMember
|
||||||
|
import app.dapk.st.matrix.common.asString
|
||||||
import app.dapk.st.matrix.crypto.MatrixMediaDecrypter
|
import app.dapk.st.matrix.crypto.MatrixMediaDecrypter
|
||||||
import app.dapk.st.matrix.message.MessageService
|
import app.dapk.st.matrix.message.MessageService
|
||||||
import app.dapk.st.matrix.message.messageService
|
import app.dapk.st.matrix.message.messageService
|
||||||
|
@ -138,7 +140,7 @@ class MatrixTestScope(private val testScope: TestScope) {
|
||||||
suspend fun TestMatrix.expectTextMessage(roomId: RoomId, message: TestMessage) {
|
suspend fun TestMatrix.expectTextMessage(roomId: RoomId, message: TestMessage) {
|
||||||
println("expecting ${message.content}")
|
println("expecting ${message.content}")
|
||||||
this.client.syncService().room(roomId)
|
this.client.syncService().room(roomId)
|
||||||
.map { it.events.filterIsInstance<RoomEvent.Message>().map { TestMessage(it.content, it.author) }.firstOrNull() }
|
.map { it.events.filterIsInstance<RoomEvent.Message>().map { TestMessage(it.content.asString(), it.author) }.firstOrNull() }
|
||||||
.assert(message)
|
.assert(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +172,7 @@ class MatrixTestScope(private val testScope: TestScope) {
|
||||||
println("sending $content")
|
println("sending $content")
|
||||||
this.client.messageService().scheduleMessage(
|
this.client.messageService().scheduleMessage(
|
||||||
MessageService.Message.TextMessage(
|
MessageService.Message.TextMessage(
|
||||||
content = MessageService.Message.Content.TextContent(body = content),
|
content = MessageService.Message.Content.TextContent(body = RichText.of(content)),
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
sendEncrypted = isEncrypted,
|
sendEncrypted = isEncrypted,
|
||||||
localId = "local.${UUID.randomUUID()}",
|
localId = "local.${UUID.randomUUID()}",
|
||||||
|
|
Loading…
Reference in New Issue