Files
LLeMbas-Android/app/src/test/java/eu/llembas/android/LiveReplyTest.kt
T
HomerandClaude Opus 5.5 4f09bc41bb
CI / check (push) Canceled after 0s
LLeMbas for Android 0.1.0 (alpha, unreleased): the first commit
A native client for a LLeMbas instance on the server's /api/v2, and the
phone's digital assistant.

- Sign in by device code; the token sealed in the Android Keystore; several
  instances.
- Chats and agent chats: the list, a chat with its reply streaming as JSON
  server-sent events (reconnecting, whole blocks), thinking, tool calls,
  steered messages, the plan, jobs, stop, edit, regenerate, continue, the
  model, effort and Plan mode, attachments and dictation.
- Cards in a sheet, answered as the page's form says it; first answer wins.
- Notifications through UnifiedPush, no Google services; an approval can be
  answered from its notification.
- The digital assistant: a VoiceInteractionService with its session (a sheet
  over the current app, "Include screen" off by default), a recognition
  service through the instance's speech-to-text, the lock-screen path that
  asks to unlock before sending, a Quick Settings tile and an Ask shortcut.
- Share to LLeMbas; Moria and Shire from the server's tokens; nine
  languages; a self-updater in the `full` flavour, none in `fdroid`.

Generated and pinned from the server, each checked in CI: the theme
(tokens.lock.json), the contract (contract/lock.json, server 2124ba9), the
strings and the icons. Built and tested only on GitHub Actions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 13:44:30 +00:00

49 lines
1.8 KiB
Kotlin

package eu.llembas.android
import eu.llembas.android.api.LiveReply
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
class LiveReplyTest {
@Test
fun aFrameReplacesItsBlockNeverAppends() {
val once = LiveReply("m").apply("tail", """{"thinking":"","text":"Lem","label":""}""")
val twice = once.apply("tail", """{"thinking":"","text":"Lembas","label":""}""")
assertEquals("Lembas", twice.tail.text)
assertEquals(listOf("text"), twice.shown.map { it.kind })
}
@Test
fun theOpenTailFollowsTheClosedSteps() {
val live = LiveReply("m")
.apply("steps", """{"steps":[{"index":0,"kind":"text","markdown":"One."}],"tail":{"thinking":"hm","text":"Two","label":"3s"}}""")
assertEquals(listOf("text", "thinking", "text"), live.shown.map { it.kind })
assertEquals(listOf(0, 1, 1), live.shown.map { it.index })
assertTrue(live.shown.drop(1).all { it.open })
}
@Test
fun anEmptyAskFrameClearsTheCard() {
val asked = LiveReply("m").apply("ask", """{"cards":[{"id":"c","kind":"question","items":[{"key":"q0","kind":"question"}]}]}""")
assertEquals(1, asked.cards.size)
assertTrue(asked.apply("ask", """{"cards":[]}""").cards.isEmpty())
}
@Test
fun anUnknownOrBrokenFrameChangesNothing() {
val live = LiveReply("m").apply("status", """{"text":"Working"}""")
assertEquals(live, live.apply("something-newer", "{}"))
assertEquals(live, live.apply("status", "not json"))
}
@Test
fun aDrainedQueueNamesTheNextReply() {
val done = LiveReply("m").apply(
"done",
"""{"message":{"id":"m","role":"assistant"},"chat":{"id":"c","title":"T"},"next":"m2"}""",
)
assertEquals("m2", done.next)
}
}