app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

GlobalTopBarTest.kt (1943B)


      1 package org.harvestcircle.ui.shell
      2 
      3 import androidx.compose.ui.test.ExperimentalTestApi
      4 import androidx.compose.ui.test.assertIsNotEnabled
      5 import androidx.compose.ui.test.onNodeWithTag
      6 import androidx.compose.ui.test.onNodeWithText
      7 import androidx.compose.ui.test.performClick
      8 import androidx.compose.ui.test.v2.runComposeUiTest
      9 import org.harvestcircle.application.SignerStatusLabel
     10 import org.harvestcircle.application.SyncStatusLabel
     11 import kotlin.test.Test
     12 import kotlin.test.assertEquals
     13 
     14 @OptIn(ExperimentalTestApi::class)
     15 class GlobalTopBarTest {
     16     @Test
     17     fun topBarUsesActualStatusAndTypedIntents() =
     18         runComposeUiTest {
     19             val intents = mutableListOf<GlobalTopBarIntent>()
     20             setHarvestCircleContent {
     21                 GlobalTopBar(
     22                     GlobalTopBarModel(
     23                         canGoBack = true,
     24                         canGoForward = false,
     25                         syncStatus = SyncStatusLabel.Degraded,
     26                         signerStatus = SignerStatusLabel.ReadOnly,
     27                     ),
     28                     intents::add,
     29                 )
     30             }
     31             onNodeWithText("Limited connection").performClick()
     32             onNodeWithText("Read-only").performClick()
     33             onNodeWithText("Open a Nostr reference").assertExists()
     34             onNodeWithTag("top-bar-open-reference").performClick()
     35             onNodeWithTag("top-bar-forward").assertIsNotEnabled()
     36             onNodeWithTag("top-bar-menu").performClick()
     37             onNodeWithText("About this build").performClick()
     38             assertEquals(
     39                 listOf(
     40                     GlobalTopBarIntent.ShowSyncStatus,
     41                     GlobalTopBarIntent.ShowSignerStatus,
     42                     GlobalTopBarIntent.OpenNostrReference,
     43                     GlobalTopBarIntent.SelectApplicationMenu(ApplicationMenuAction.AboutBuild),
     44                 ),
     45                 intents,
     46             )
     47         }
     48 }