adding missing rich text test usages

This commit is contained in:
Adam Brown 2022-10-24 22:56:17 +01:00
parent e79c5c9a27
commit eeb13b3f6c
6 changed files with 18 additions and 10 deletions

View File

@ -1,5 +1,7 @@
package app.dapk.st.notifications
import app.dapk.st.matrix.common.RichText
import app.dapk.st.matrix.common.asString
import fixture.aRoomImageMessageEvent
import fixture.aRoomMessageEvent
import fixture.aRoomReplyMessageEvent
@ -18,7 +20,7 @@ class RoomEventsToNotifiableMapperTest {
result shouldBeEqualTo listOf(
Notifiable(
content = event.content,
content = event.content.asString(),
utcTimestamp = event.utcTimestamp,
author = event.author
)
@ -42,14 +44,14 @@ class RoomEventsToNotifiableMapperTest {
@Test
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 result = mapper.map(listOf(event))
result shouldBeEqualTo listOf(
Notifiable(
content = reply.content,
content = reply.content.asString(),
utcTimestamp = event.utcTimestamp,
author = event.author
)

View File

@ -1,6 +1,7 @@
package app.dapk.st.engine
import app.dapk.st.matrix.common.EventId
import app.dapk.st.matrix.common.RichText
import app.dapk.st.matrix.message.MessageService
import fixture.*
import org.amshove.kluent.shouldBeEqualTo
@ -54,7 +55,7 @@ class MergeWithLocalEchosUseCaseTest {
private fun createLocalEcho(eventId: EventId, body: String, state: MessageService.LocalEcho.State) = aLocalEcho(
eventId,
aTextMessage(aTextContent(body)),
aTextMessage(aTextContent(RichText.of(body))),
state,
)
}

View File

@ -1,5 +1,6 @@
package app.dapk.st.engine
import app.dapk.st.matrix.common.RichText
import fake.FakeRoomStore
import fixture.NotificationDiffFixtures.aNotificationDiff
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
private val NO_UNREADS = emptyMap<MatrixRoomOverview, List<MatrixRoomEvent>>()
private val A_MESSAGE = aMatrixRoomMessageEvent(eventId = anEventId("1"), content = "hello", utcTimestamp = 1000)
private val A_MESSAGE_2 = aMatrixRoomMessageEvent(eventId = anEventId("2"), content = "world", utcTimestamp = 2000)
private val A_MESSAGE = aMatrixRoomMessageEvent(eventId = anEventId("1"), content = RichText.of("hello"), utcTimestamp = 1000)
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_2 = aMatrixRoomOverview(roomId = aRoomId("2"))

View File

@ -1,5 +1,6 @@
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.RoomMember
import app.dapk.st.matrix.common.UserId
@ -24,7 +25,7 @@ import test.delegateReturn
private val A_ROOM_ID = aRoomId()
private val AN_USER_ID = aUserId()
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_ROOM_MEMBER = aRoomMember()

View File

@ -1,6 +1,7 @@
package fixture
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.message.MessageService
@ -13,6 +14,6 @@ fun aTextMessage(
) = MessageService.Message.TextMessage(content, sendEncrypted, roomId, localId, timestampUtc)
fun aTextContent(
body: String = "text content body",
body: RichText = RichText.of("text content body"),
type: String = MessageType.TEXT.value,
) = MessageService.Message.Content.TextContent(body, type)

View File

@ -5,8 +5,10 @@ package test
import TestMessage
import TestUser
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.RoomMember
import app.dapk.st.matrix.common.asString
import app.dapk.st.matrix.crypto.MatrixMediaDecrypter
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) {
println("expecting ${message.content}")
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)
}
@ -170,7 +172,7 @@ class MatrixTestScope(private val testScope: TestScope) {
println("sending $content")
this.client.messageService().scheduleMessage(
MessageService.Message.TextMessage(
content = MessageService.Message.Content.TextContent(body = content),
content = MessageService.Message.Content.TextContent(body = RichText.of(content)),
roomId = roomId,
sendEncrypted = isEncrypted,
localId = "local.${UUID.randomUUID()}",