Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package com.flipcash.app.messenger.internal
import androidx.compose.foundation.text.input.TextFieldState
import com.flipcash.services.models.chat.MessageContent
import com.flipcash.shared.chat.MessageCapability
import com.flipcash.shared.chat.MessagePolicy
import com.flipcash.shared.chat.models.ChatListItem
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Instant

/**
Expand Down Expand Up @@ -58,6 +60,36 @@ class ChatMessageActionReducerTest {
assertEquals(target.capabilities, state.selectionCapabilities)
}

@Test
fun `selecting a bubble past its edit window drops Edit`() {
// The transcript resolved this bubble when it was mapped, which may have been well inside a
// window that has since closed. Offering Edit anyway costs a round-trip the server answers
// CANNOT_EDIT. sentAt is decades old, so any finite window here has closed.
val state = reduce(
ChatViewModel.State(messagePolicy = MessagePolicy(editWindow = 5.minutes)),
ChatViewModel.Event.ToggleMessageSelection(bubble(1)),
)

assertEquals(
setOf(MessageCapability.Copy, MessageCapability.Delete),
state.selectionCapabilities,
)
}

@Test
fun `selecting a bubble past its delete window drops Delete`() {
// Separate from the case above so a window wired to the wrong capability cannot pass both.
val state = reduce(
ChatViewModel.State(messagePolicy = MessagePolicy(deleteWindow = 5.minutes)),
ChatViewModel.Event.ToggleMessageSelection(bubble(1)),
)

assertEquals(
setOf(MessageCapability.Copy, MessageCapability.Edit),
state.selectionCapabilities,
)
}

@Test
fun `long-pressing the selected bubble again clears the bar`() {
val target = bubble(1)
Expand Down
Loading