Cotton code
37 lines · 1.9 KB · KotlinRaw
package com.cottondb.messages.warmimport android.app.Applicationimport androidx.compose.ui.test.junit4.createComposeRuleimport androidx.compose.ui.test.onNodeWithTagimport androidx.compose.ui.test.performClickimport androidx.compose.ui.test.performScrollToimport com.cottondb.shell.core.CottonCoreimport kotlinx.serialization.json.jsonObjectimport org.junit.Assert.assertEqualsimport org.junit.Ruleimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport org.robolectric.annotation.Config/** * Comms' Help and feedback ends with the privacy policy and the way to reach us, as every app's does (chat/CONTRACT * "Help's two links"; store pass, 24 Nov 2026: Comms drew Share a report alone). Invented answer. */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], qualifiers = "w360dp-h800dp-mdpi", application = Application::class)class YouHelpLinksTest {    @get:Rule val compose = createComposeRule()    @Test fun help_opens_the_privacy_policy_and_the_help_page() {        val help = CottonCore.json.parseToJsonElement(            """{"title":"Help and feedback","share":{"label":"Share a report","line":"A small text file."},            "links":[{"id":"privacy","label":"Privacy policy","url":"https://cottondb.com/privacy"},{"id":"support","label":"Help and contact","url":"https://cottondb.com/support"}]}""",        ).jsonObject        val opened = mutableListOf<String>()        compose.setContent { WarmTheme(night = false) { HelpPage(help, "Something's wrong", "Back", onShare = {}, onBack = {}, onOpen = { opened += it }) } }        compose.onNodeWithTag("settings-link-privacy").performScrollTo().performClick()        compose.onNodeWithTag("settings-link-support").performScrollTo().performClick()        assertEquals(listOf("https://cottondb.com/privacy", "https://cottondb.com/support"), opened)    }}