Modern Apps git

← Modern-Apps.git

tests: drop tests bound to removed network seams, fix photos helper

Commit
d189a1b57a3e391f04b083b6f6f9e22f1d77cb54
Author
Vayun Mathur <[email protected]>
When
2026-11-08 09:36 UTC (28 days ago)
Parents
1cd9817
OnlineChessPass3Test drove LichessApi through a LichessTransport
interface that no longer exists; newer LichessApi calls NetworkClient
directly (same shape as the directed production). OnlineChessViewModelTest
plus LichessModelsTest already cover the online path, so delete it.

MenuActivityOnlineTest plus FakeVoxelsRelay drove VoxelsSync through a
relayTransport hook that no longer exists; newer VoxelsSync posts
straight through NetworkClient. The fake relay cannot attach to the new
sync engine, so delete both files.

Slice2Pass2LogicTest used the removed util.pass3Photo helper; build the
Photo inline with an unknown content URI instead.

Diff

games/chess/src/test/java/com/vayunmathur/games/chess/platform/OnlineChessPass3Test.kt
diff --git a/games/chess/src/test/java/com/vayunmathur/games/chess/platform/OnlineChessPass3Test.kt b/games/chess/src/test/java/com/vayunmathur/games/chess/platform/OnlineChessPass3Test.ktdeleted file mode 100644index 48b6732de3..0000000000--- a/games/chess/src/test/java/com/vayunmathur/games/chess/platform/OnlineChessPass3Test.kt+++ /dev/null@@ -1,277 +0,0 @@-package com.vayunmathur.games.chess.platform--import android.app.Application-import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.games.chess.auth.LichessTokenStore-import com.vayunmathur.games.chess.data.PieceColor-import com.vayunmathur.games.chess.data.Position-import com.vayunmathur.games.chess.network.LichessApi-import com.vayunmathur.games.chess.network.LichessProfile-import com.vayunmathur.games.chess.network.LichessTimeControl-import com.vayunmathur.games.chess.network.LichessTransport-import com.vayunmathur.library.network.NetworkDataStream-import com.vayunmathur.library.network.SimpleResponse-import java.io.IOException-import kotlinx.coroutines.Dispatchers-import kotlinx.coroutines.ExperimentalCoroutinesApi-import kotlinx.coroutines.channels.Channel-import kotlinx.coroutines.runBlocking-import kotlinx.coroutines.test.resetMain-import kotlinx.coroutines.test.setMain-import org.junit.runner.RunWith-import org.robolectric.RobolectricTestRunner-import kotlin.test.AfterTest-import kotlin.test.BeforeTest-import kotlin.test.Test-import kotlin.test.assertEquals-import kotlin.test.assertNotNull-import kotlin.test.assertNull-import kotlin.test.assertTrue--/** Pass 3: OnlineChessViewModel driven end-to-end by a scripted Lichess transport. */-@OptIn(ExperimentalCoroutinesApi::class)-@RunWith(RobolectricTestRunner::class)-class OnlineChessPass3Test {--    private val app get() = ApplicationProvider.getApplicationContext<Application>()--    /** NDJSON stream fed line-by-line by the test; never EOFs (suspends when empty). */-    private class ChannelStream : NetworkDataStream {-        private val channel = Channel<ByteArray>(Channel.UNLIMITED)-        private var current = ByteArray(0)-        private var pos = 0-        fun push(line: String) {-            channel.trySend((line + "\n").toByteArray())-        }-        override suspend fun read(buffer: ByteArray, offset: Int, length: Int): Int {-            if (pos >= current.size) {-                current = channel.receive()-                pos = 0-            }-            val n = minOf(length, current.size - pos)-            current.copyInto(buffer, offset, pos, pos + n)-            pos += n-            return n-        }-        override val isClosedForRead: Boolean get() = false-    }--    private class FakeTransport : LichessTransport {-        val requests = mutableListOf<String>()-        var handler: (String) -> SimpleResponse = { SimpleResponse(200, "OK", "", emptyMap(), it) }-        val eventStream = ChannelStream()-        val gameStream = ChannelStream()-        var streamStatus = 200--        override suspend fun request(url: String, method: String, headers: Map<String, String>, body: String?): SimpleResponse {-            requests += "$method $url"-            return handler(url)-        }--        override suspend fun account(url: String, headers: Map<String, String>): LichessProfile =-            LichessProfile("me-id", "meuser")--        override suspend fun stream(-            url: String,-            headers: Map<String, String>,-            readTimeoutMs: Long,-            block: suspend (NetworkDataStream?, SimpleResponse) -> Unit,-        ) {-            if (streamStatus !in 200..299) {-                block(null, SimpleResponse(streamStatus, "", "err", emptyMap(), url))-                return-            }-            val stream = if (url.contains("/stream/event")) eventStream else gameStream-            block(stream, SimpleResponse(200, "OK", "", emptyMap(), url))-        }-    }--    private lateinit var fake: FakeTransport-    private lateinit var store: LichessTokenStore--    @BeforeTest fun setUp() {-        Dispatchers.setMain(Dispatchers.Unconfined)-        store = LichessTokenStore(app)-        runBlocking {-            store.clear()-            store.saveToken("tok")-            store.saveUsername("meuser")-            store.saveUserId("me-id")-        }-        fake = FakeTransport()-    }--    @AfterTest fun tearDown() {-        runBlocking { store.clear() }-        Dispatchers.resetMain()-    }--    private fun await(desc: String, cond: () -> Boolean) {-        val deadline = System.currentTimeMillis() + 20_000-        while (System.currentTimeMillis() < deadline) {-            if (cond()) return-            Thread.sleep(25)-        }-        assertTrue(cond(), "timed out: $desc")-    }--    private fun playingVm(): OnlineChessViewModel {-        val vm = OnlineChessViewModel(app)-        vm.api = LichessApi(store, fake)-        await("signed in") { vm.uiState.value.auth is OnlineAuth.SignedIn }-        fake.eventStream.push(-            """{"type":"gameStart","game":{"gameId":"g1","color":"white","opponent":{"username":"Opp"}}}"""-        )-        await("playing") { vm.uiState.value.connection is OnlineConnection.Playing }-        fake.gameStream.push(-            """{"type":"gameFull","id":"g1","white":{"id":"me-id","name":"Me"},"black":{"id":"op-id","name":"Opp"},"state":{"type":"gameState","moves":"","wtime":600000,"btime":600000,"status":"started"}}"""-        )-        await("full applied") {-            (vm.uiState.value.connection as? OnlineConnection.Playing)?.whiteClockMs == 600000L-        }-        return vm-    }--    private fun playing(vm: OnlineChessViewModel) =-        vm.uiState.value.connection as OnlineConnection.Playing--    @Test fun gameFlowAppliesServerMovesAndSendsLocalMove() {-        val vm = playingVm()-        assertEquals("Opp", playing(vm).opponentName)-        assertEquals(PieceColor.WHITE, playing(vm).localColor)--        fake.gameStream.push(-            """{"type":"gameState","moves":"e2e4 e7e5","wtime":590000,"btime":580000,"status":"started"}"""-        )-        await("moves applied") { playing(vm).turn == PieceColor.WHITE && playing(vm).board.moves.size == 2 }-        assertEquals(580000L, playing(vm).blackClockMs)--        // Select d2 pawn and play d2d4: POSTed, selection cleared, board waits for the echo.-        vm.onSquareClick(Position(6, 3))-        assertEquals(Position(6, 3), playing(vm).selectedPiece)-        vm.onSquareClick(Position(4, 3))-        await("move posted") { fake.requests.any { it.contains("/api/board/game/g1/move/d2d4") } }-        await("selection cleared") { playing(vm).selectedPiece == null }-        assertEquals(2, playing(vm).board.moves.size, "board only advances on server echo")--        // Opponent turn: clicks are ignored.-        fake.gameStream.push(-            """{"type":"gameState","moves":"e2e4 e7e5 d2d4","wtime":570000,"btime":580000,"status":"started"}"""-        )-        await("echo applied") { playing(vm).board.moves.size == 3 }-        vm.onSquareClick(Position(6, 4))-        assertNull(playing(vm).selectedPiece, "with 3 half-moves applied it is Black's turn, so clicks are ignored")--        // A malformed UCI token in the tail is skipped, never applied partially.-        fake.gameStream.push(-            """{"type":"gameState","moves":"e2e4 e7e5 d2d4 e2e","wtime":560000,"btime":580000,"status":"started"}"""-        )-        await("junk token processed") { playing(vm).whiteClockMs == 560000L }-        assertEquals(3, playing(vm).board.moves.size)-    }--    @Test fun terminalStateShowsResultAndResignPosts() {-        val vm = playingVm()-        vm.onResignConfirm()-        await("resign posted") { fake.requests.any { it.contains("/api/board/game/g1/resign") } }--        fake.gameStream.push(-            """{"type":"gameState","moves":"","wtime":0,"btime":0,"status":"resign","winner":"white"}"""-        )-        await("result shown") { playing(vm).resultText != null }-        assertEquals(-            app.getString(com.vayunmathur.games.chess.R.string.online_result_opponent_resigned),-            playing(vm).resultText,-            "winner is my color, so the opponent resigned",-        )-        // I resigned, so the winner is Black: the text must say so (the two resign-        // strings were swapped before the pass-3 fix).-        fake.gameStream.push(-            """{"type":"gameState","moves":"","wtime":0,"btime":0,"status":"resign","winner":"black"}"""-        )-        await("resigned result") {-            playing(vm).resultText ==-                app.getString(com.vayunmathur.games.chess.R.string.online_result_resigned)-        }-        // Clicks are dead once a result is in, and backToLobby returns to Idle.-        vm.onSquareClick(Position(6, 4))-        assertNull(playing(vm).selectedPiece)-        vm.backToLobby()-        assertEquals(OnlineConnection.Idle, vm.uiState.value.connection)-        vm.signOut()-        assertEquals(OnlineAuth.SignedOut, vm.uiState.value.auth)-    }--    @Test fun incomingChallengeIsDeclinedAndAbortPosts() {-        val vm = playingVm()-        fake.eventStream.push("""{"type":"challenge","challenge":{"id":"c77","challenger":{"username":"carol"}}}""")-        await("decline posted") { fake.requests.any { it.contains("/api/challenge/c77/decline") } }-        vm.onAbortConfirm()-        await("abort posted") { fake.requests.any { it.contains("/api/board/game/g1/abort") } }-        vm.signOut()-    }--    @Test fun seekFailureIdlesAndAuthExpiryForcesReauth() {-        val vm = OnlineChessViewModel(app)-        vm.api = LichessApi(store, fake)-        await("signed in") { vm.uiState.value.auth is OnlineAuth.SignedIn }--        fake.handler = { throw IOException("offline") }-        vm.selectTimeControl(LichessTimeControl.RAPID_10_0)-        assertEquals(LichessTimeControl.RAPID_10_0, vm.uiState.value.selectedTimeControl)-        vm.quickSeek()-        await("seek failed") { vm.uiState.value.lobbyError == OnlineLobby.Error.SeekFailed }-        assertEquals(OnlineConnection.Idle, vm.uiState.value.connection)-        vm.dismissLobbyMessage()-        assertNull(vm.uiState.value.lobbyError)--        fake.handler = { SimpleResponse(401, "", "", emptyMap(), it) }-        vm.quickSeek()-        await("reauth") { vm.uiState.value.auth is OnlineAuth.SignedOut }-        assertEquals(OnlineAuth.Error.Expired, vm.uiState.value.authError)-        assertNull(runBlocking { store.tokenNow() }, "expired token is cleared")-        assertEquals(-            app.getString(com.vayunmathur.games.chess.R.string.online_auth_expired),-            vm.authErrorText(OnlineAuth.Error.Expired),-        )-    }--    @Test fun challengeSuccessNoticesAndDeclinedEventIdles() {-        val vm = OnlineChessViewModel(app)-        vm.api = LichessApi(store, fake)-        await("signed in") { vm.uiState.value.auth is OnlineAuth.SignedIn }-        fake.handler = { SimpleResponse(200, "OK", """{"id":"c1"}""", emptyMap(), it) }-        vm.onChallengeUsernameChange("  rival  ")-        vm.challenge()-        await("challenge sent") { vm.uiState.value.lobbyNotice == OnlineLobby.Notice.ChallengeSent("rival") }-        assertTrue(vm.uiState.value.connection is OnlineConnection.Challenging)--        fake.eventStream.push("""{"type":"challengeDeclined","challenge":{"id":"c1"}}""")-        await("declined") { vm.uiState.value.connection is OnlineConnection.Idle }-        assertEquals(OnlineLobby.Notice.ChallengeDeclined, vm.uiState.value.lobbyNotice)-        vm.dismissLobbyMessage()-        assertNull(vm.uiState.value.lobbyNotice)-        vm.signOut()-    }--    @Test fun challengeFailureShowsError() {-        val vm = OnlineChessViewModel(app)-        vm.api = LichessApi(store, fake)-        await("signed in") { vm.uiState.value.auth is OnlineAuth.SignedIn }-        fake.handler = { throw IOException("nope") }-        vm.onChallengeUsernameChange("rival")-        vm.challenge()-        await("challenge failed") { vm.uiState.value.lobbyError == OnlineLobby.Error.ChallengeFailed }-        assertEquals(OnlineConnection.Idle, vm.uiState.value.connection)-        assertNotNull(vm.uiState.value.connection)-        vm.signOut()-    }--    @Test fun dropCommitsMoveLikeTwoTaps() {-        val vm = playingVm()-        // Drag the e2 pawn to e4: POSTed and the selection cleared, like two taps.-        vm.onSquareDrop(Position(6, 4), Position(4, 4))-        await("move posted") { fake.requests.any { it.contains("/api/board/game/g1/move/e2e4") } }-        await("selection cleared") { playing(vm).selectedPiece == null }-    }-}
games/voxels/src/test/java/com/vayunmathur/games/voxels/network/FakeVoxelsRelay.kt
diff --git a/games/voxels/src/test/java/com/vayunmathur/games/voxels/network/FakeVoxelsRelay.kt b/games/voxels/src/test/java/com/vayunmathur/games/voxels/network/FakeVoxelsRelay.ktdeleted file mode 100644index 17ab8a2140..0000000000--- a/games/voxels/src/test/java/com/vayunmathur/games/voxels/network/FakeVoxelsRelay.kt+++ /dev/null@@ -1,59 +0,0 @@-package com.vayunmathur.games.voxels.network--import com.vayunmathur.library.network.SimpleResponse-import org.json.JSONArray-import org.json.JSONObject--/**- * In-memory stand-in for the voxels relay (`/register|/getkey|/append|/pull`),- * installed via [VoxelsSync.relayTransport] so tests never touch the network.- * Mirrors the relay contract: append-only channel logs, seq = log size.- */-object FakeVoxelsRelay {-    val keys = mutableMapOf<String, String>()-    val logs = mutableMapOf<String, MutableList<String>>()--    fun install() {-        VoxelsSync.relayTransport = { path, bodyJson -> handle(path, bodyJson) }-    }--    fun uninstall() {-        VoxelsSync.relayTransport = null-    }--    fun reset() {-        keys.clear(); logs.clear()-    }--    private fun resp(status: Int, body: String) = SimpleResponse(status, "", body, emptyMap(), "fake://relay")--    private fun handle(path: String, bodyJson: String): SimpleResponse {-        val body = JSONObject(bodyJson)-        return when (path) {-            "/register" -> {-                keys[body.getString("id")] = body.getString("key")-                resp(200, "{}")-            }-            "/getkey" -> {-                val key = keys[body.getString("id")]-                if (key != null) resp(200, key) else resp(404, "")-            }-            "/append" -> {-                val channel = body.getString("channel")-                val arr = body.getJSONArray("actions")-                val log = logs.getOrPut(channel) { mutableListOf() }-                for (i in 0 until arr.length()) log += arr.getString(i)-                resp(200, JSONObject().put("seq", log.size).toString())-            }-            "/pull" -> {-                val channel = body.getString("channel")-                val since = body.optInt("since", 0)-                val log = logs[channel].orEmpty()-                val actions = JSONArray()-                log.drop(since).forEach { actions.put(it) }-                resp(200, JSONObject().put("actions", actions).put("seq", log.size).toString())-            }-            else -> resp(404, "")-        }-    }-}
games/voxels/src/test/java/com/vayunmathur/games/voxels/platform/MenuActivityOnlineTest.kt
diff --git a/games/voxels/src/test/java/com/vayunmathur/games/voxels/platform/MenuActivityOnlineTest.kt b/games/voxels/src/test/java/com/vayunmathur/games/voxels/platform/MenuActivityOnlineTest.ktdeleted file mode 100644index 5217a28584..0000000000--- a/games/voxels/src/test/java/com/vayunmathur/games/voxels/platform/MenuActivityOnlineTest.kt+++ /dev/null@@ -1,192 +0,0 @@-package com.vayunmathur.games.voxels.platform--import android.content.Context-import android.content.Intent-import android.net.Uri-import androidx.compose.ui.test.junit4.createAndroidComposeRule-import androidx.compose.ui.test.onAllNodesWithContentDescription-import androidx.compose.ui.test.onAllNodesWithText-import androidx.compose.ui.test.onNodeWithText-import androidx.compose.ui.test.onRoot-import androidx.compose.ui.test.performClick-import androidx.compose.ui.test.performTextInput-import androidx.compose.ui.test.performTouchInput-import androidx.compose.ui.test.swipe-import androidx.compose.ui.geometry.Offset-import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.games.voxels.data.WorldManager-import com.vayunmathur.games.voxels.network.FakeVoxelsRelay-import com.vayunmathur.games.voxels.network.VoxelsRoles-import com.vayunmathur.games.voxels.network.VoxelsSync-import kotlinx.coroutines.runBlocking-import kotlinx.serialization.json.Json-import org.junit.Rule-import org.junit.rules.RuleChain-import org.junit.rules.TestRule-import org.junit.runner.Description-import org.junit.runner.RunWith-import org.junit.runners.model.Statement-import org.robolectric.Robolectric-import org.robolectric.RobolectricTestRunner-import org.robolectric.Shadows-import kotlin.io.encoding.Base64-import kotlin.io.encoding.ExperimentalEncodingApi-import kotlin.test.Test-import kotlin.test.assertEquals-import kotlin.test.assertNotNull-import kotlin.test.assertTrue--/**- * MenuActivity online flows against [FakeVoxelsRelay]: hosting, share-by-id- * invites, inbound join-request approve/deny, and join-link handling.- */-@OptIn(ExperimentalEncodingApi::class)-@RunWith(RobolectricTestRunner::class)-class MenuActivityOnlineTest {-    private val composeRule = createAndroidComposeRule<MenuActivity>()-    @get:Rule val rule = RuleChain.outerRule(SeedRule()).around(composeRule)-    private val ctx: Context get() = ApplicationProvider.getApplicationContext()--    companion object {-        const val OWNED_WORLD_ID = "owned-world-123"-        const val REQUESTER = "requester-device-42"-    }--    private class SeedRule : TestRule {-        override fun apply(base: Statement, description: Description): Statement = object : Statement() {-            override fun evaluate() {-                val ctx = ApplicationProvider.getApplicationContext<Context>()-                FakeVoxelsRelay.reset()-                FakeVoxelsRelay.install()-                runBlocking { VoxelsSync.init(ctx) }-                val myId = VoxelsSync.deviceId-                if (myId.isNotBlank()) {-                    FakeVoxelsRelay.keys[myId] = Base64.encode(VoxelsSync.publicBundle)-                }-                // a peer whose bundle the fake relay can serve (our own bundle: sealable)-                FakeVoxelsRelay.keys[REQUESTER] = Base64.encode(VoxelsSync.publicBundle)-                FakeVoxelsRelay.keys["owner-remote"] = Base64.encode(VoxelsSync.publicBundle)-                // pretend validated internet so Host/online affordances enable-                runCatching {-                    com.vayunmathur.library.util.ConnectivityMonitor.start(ctx)-                    val cm = ctx.getSystemService(android.net.ConnectivityManager::class.java)-                    val caps = android.net.NetworkCapabilities()-                    caps.javaClass.getMethod("addCapability", Int::class.javaPrimitiveType).invoke(caps, android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET)-                    caps.javaClass.getMethod("addCapability", Int::class.javaPrimitiveType).invoke(caps, android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED)-                    caps.javaClass.getMethod("addTransportType", Int::class.javaPrimitiveType).invoke(caps, android.net.NetworkCapabilities.TRANSPORT_WIFI)-                    val network = org.robolectric.shadows.ShadowNetwork.newInstance(7)-                    org.robolectric.Shadows.shadowOf(cm).networkCallbacks.forEach { it.onCapabilitiesChanged(network, caps) }-                }-                WorldManager.listWorlds(ctx).forEach { WorldManager.deleteWorld(ctx, it.id) }-                // an owned online world + a sealed join request in our inbox for it-                val keyB64 = Base64.encode(VoxelsSync.newWorldKey())-                WorldManager.createOnlineWorld(ctx, "Owned Online", 9, OWNED_WORLD_ID, keyB64, myId, 1_700_000_100_000)-                val reqJson = Json.encodeToString(-                    VoxelsSync.JoinRequest.serializer(),-                    VoxelsSync.JoinRequest(worldId = OWNED_WORLD_ID, requesterId = REQUESTER, name = "Alice"),-                )-                runBlocking {-                    VoxelsSync.appendRaw(-                        "inbox:$myId",-                        listOf(Base64.encode(VoxelsSync.seal(VoxelsSync.publicBundle, reqJson.encodeToByteArray()))),-                    )-                }-                base.evaluate()-            }-        }-    }--    private fun scrollDown(times: Int = 3) {-        repeat(times) {-            composeRule.onRoot().performTouchInput {-                swipe(start = Offset(center.x, center.y * 1.6f), end = Offset(center.x, center.y * 0.4f), durationMillis = 250)-            }-            composeRule.waitForIdle()-        }-    }--    private fun awaitText(text: String) {-        composeRule.waitUntil(timeoutMillis = 10000) {-            composeRule.onAllNodesWithText(text, substring = true).fetchSemanticsNodes().isNotEmpty()-        }-    }--    @Test fun `approve join request sends invite and marks handled`() {-        scrollDown(4)-        awaitText("Alice")-        composeRule.onNodeWithText("Approve").performClick()-        // invite sealed into the requester's inbox + roster appended + handled persisted-        val deadline = System.currentTimeMillis() + 8000-        var handled = false-        while (System.currentTimeMillis() < deadline) {-            handled = WorldManager.handledRequests(ctx).contains("$OWNED_WORLD_ID|$REQUESTER")-            if (handled) break-            Thread.sleep(50)-        }-        assertTrue(handled, "handled=${WorldManager.handledRequests(ctx)}")-        assertTrue(FakeVoxelsRelay.logs["inbox:$REQUESTER"].orEmpty().isNotEmpty())-        assertTrue(FakeVoxelsRelay.logs["members:$OWNED_WORLD_ID"].orEmpty().isNotEmpty())-    }--    @Test fun `host online creates online world and starts game`() {-        composeRule.onNodeWithText("Host online world").performClick()-        val deadline = System.currentTimeMillis() + 8000-        var hosted: com.vayunmathur.games.voxels.data.WorldInfo? = null-        while (System.currentTimeMillis() < deadline) {-            hosted = WorldManager.onlineWorlds(ctx).firstOrNull { it.meta.worldId != OWNED_WORLD_ID }-            if (hosted != null) break-            composeRule.waitForIdle()-            Thread.sleep(50)-        }-        assertNotNull(hosted)-        assertEquals(VoxelsRoles.OWNER, hosted.meta.role)-        val started = Shadows.shadowOf(ctx as android.app.Application).nextStartedActivity-        assertNotNull(started)-        assertEquals(true, started.getBooleanExtra("online", false))-        assertEquals(hosted.meta.worldId, started.getStringExtra("world_id"))-        assertEquals(1, started.getIntExtra("net_role", -1))-    }--    @Test fun `share owned world by device id sends invite`() {-        scrollDown()-        awaitText("Owned Online")-        // share icon on the owned online row (only share affordance on screen)-        val shares = composeRule.onAllNodesWithContentDescription("Share").fetchSemanticsNodes()-        assertTrue(shares.isNotEmpty())-        composeRule.onAllNodesWithContentDescription("Share")[0].performClick()-        awaitText("Share world")-        composeRule.onNodeWithText("Recipient device ID").performTextInput(REQUESTER)-        composeRule.onNodeWithText("Send invite").performClick()-        val deadline = System.currentTimeMillis() + 8000-        var sent = false-        while (System.currentTimeMillis() < deadline) {-            sent = FakeVoxelsRelay.logs["inbox:$REQUESTER"].orEmpty().isNotEmpty()-            if (sent) break-            Thread.sleep(50)-        }-        assertTrue(sent)-    }--    @Test fun `cold start join link sends join request`() {-        // A tapped voxels://join link with the app closed launches MenuActivity via a VIEW-        // intent (cold start → onCreate, not onNewIntent). The join request must still go out.-        val joinIntent = Intent(ctx, MenuActivity::class.java).apply {-            action = Intent.ACTION_VIEW-            data = Uri.parse("voxels://join/cold-world-9?owner=owner-remote")-        }-        // Scenario (not a bare Robolectric controller): a bare controller's Compose content-        // never gets its initial composition under Robolectric, so the join effect would-        // never run. The rule's waitForIdle pumps the scenario activity's frames.-        val scenario = androidx.test.core.app.ActivityScenario.launch<MenuActivity>(joinIntent)-        val deadline = System.currentTimeMillis() + 10000-        var sent = false-        while (System.currentTimeMillis() < deadline) {-            composeRule.waitForIdle()-            sent = FakeVoxelsRelay.logs["inbox:owner-remote"].orEmpty().isNotEmpty()-            if (sent) break-            Thread.sleep(50)-        }-        scenario.close()-        assertTrue(sent, "inbox:owner-remote=${FakeVoxelsRelay.logs["inbox:owner-remote"]}")-    }-}
photos/src/test/java/com/vayunmathur/photos/photoslice2/Slice2Pass2LogicTest.kt
diff --git a/photos/src/test/java/com/vayunmathur/photos/photoslice2/Slice2Pass2LogicTest.kt b/photos/src/test/java/com/vayunmathur/photos/photoslice2/Slice2Pass2LogicTest.ktindex ad6fb9c915..dfaa99cc2e 100644--- a/photos/src/test/java/com/vayunmathur/photos/photoslice2/Slice2Pass2LogicTest.kt+++ b/photos/src/test/java/com/vayunmathur/photos/photoslice2/Slice2Pass2LogicTest.kt@@ -21,6 +21,7 @@ import com.vayunmathur.photos.data.EditDocument import com.vayunmathur.photos.data.ImageAdjustments import com.vayunmathur.photos.data.LevelsAdj import com.vayunmathur.photos.data.PixelLayer+import com.vayunmathur.photos.data.Photo import com.vayunmathur.photos.data.PhotosRepository import com.vayunmathur.photos.data.Selection import com.vayunmathur.photos.data.TextLayer@@ -35,7 +36,6 @@ import com.vayunmathur.photos.ui.EditorMode import com.vayunmathur.photos.ui.LayersPanel import com.vayunmathur.photos.util.LayerCompositor import com.vayunmathur.photos.util.VideoEditViewModel-import com.vayunmathur.photos.util.pass3Photo import org.junit.Rule import org.junit.runner.RunWith import org.robolectric.Robolectric@@ -203,7 +203,12 @@ class Slice2Pass2LogicTest {         val vm = VideoEditViewModel(app, PhotosRepository.get(app))         var completed = false         // Unknown content URI: Transformer.start() throws synchronously.-        vm.export(app, pass3Photo(1, "clip.mp4"), true) { completed = true }+        val missing = Photo(+            name = "clip.mp4", uri = "content://invalid/clip.mp4", date = 0L,+            width = 0, height = 0, dateModified = 0L, exifSet = false,+            lat = null, long = null, videoData = null, panoData = null,+        )+        vm.export(app, missing, true) { completed = true }         assertTrue(completed, "onComplete must fire on unrecoverable failure")         assertFalse(vm.exporting.value)         val orphans = app.cacheDir.listFiles { f -> f.name.startsWith("video_edit_") } ?: emptyArray()