Skip to content

Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.

3.0 KB
Raw Blame
package com.gotcha.data

import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test

/** The counts and the empty check the Second Brain page opens on. */
class SecondBrainSummaryTest {

    private fun file(name: String) = MemoryStore.BrainFile(name = name, content = "", truncated = false)

    private fun snapshot(
        notes: Int = 0,
        people: Int = 0,
        areas: Int = 4,
        soul: String? = null,
        memoryIndex: String? = null
    ) = MemoryStore.SecondBrainSnapshot(
        available = true,
        soul = soul?.let { MemoryStore.BrainFile("SOUL.md", it, false) },
        memoryIndex = memoryIndex?.let { MemoryStore.BrainFile("MEMORY.md", it, false) },
        userCard = file("user.md"),
        areas = List(areas) { file("area$it.md") },
        people = List(people) { file("person$it.md") },
        notes = List(notes) { file("note$it.md") }
    )

    @Test
    fun `the seeded skeleton counts as empty`() {
        val summary = snapshot().summary()

        assertTrue(summary.empty)
        assertEquals(0, summary.notes)
        assertEquals(0, summary.people)
        assertEquals(4, summary.areas)
    }

    @Test
    fun `a note ends the empty state`() {
        assertFalse(snapshot(notes = 1).summary().empty)
    }

    @Test
    fun `a fifth area ends the empty state`() {
        assertFalse(snapshot(areas = 5).summary().empty)
    }

    @Test
    fun `a person ends the empty state too`() {
        assertFalse(snapshot(people = 1).summary().empty)
    }

    @Test
    fun `an edited identity is not empty even without notes`() {
        assertFalse(snapshot(soul = "# SOUL\n\n- Tone: dry").summary().empty)
    }

    @Test
    fun `an edited map is not empty even without notes`() {
        assertFalse(snapshot(memoryIndex = "# MEMORY\n\n- Gym: notes/gym.md").summary().empty)
    }

    @Test
    fun `an edited area hub is not empty even without notes`() {
        val withArea = MemoryStore.SecondBrainSnapshot(
            available = true,
            soul = null,
            memoryIndex = null,
            userCard = null,
            areas = listOf(
                MemoryStore.BrainFile(
                    "work.md",
                    "---\ntitle: Work\ntype: area\n---\n\n# Work\n\nProjects.\n\n- Alpha ships Friday",
                    false
                )
            ),
            people = emptyList(),
            notes = emptyList()
        )

        assertFalse(withArea.summary().empty)
    }

    @Test
    fun `the generated area hub is pristine`() {
        val generated = "---\ntitle: Work\ntype: area\n---\n\n# Work\n\nProjects and work threads."
        assertTrue(MemoryStore.isPristineArea(generated))
    }

    @Test
    fun `counts follow the snapshot`() {
        val summary = snapshot(notes = 3, people = 2, areas = 4).summary()

        assertEquals(3, summary.notes)
        assertEquals(2, summary.people)
        assertEquals(4, summary.areas)
        assertFalse(summary.empty)
    }
}