package com.cottondb.android.ui.legalimport androidx.compose.ui.graphics.asAndroidBitmapimport androidx.compose.ui.test.junit4.createComposeRuleimport androidx.compose.ui.test.onNodeWithContentDescriptionimport androidx.compose.ui.test.onNodeWithTextimport androidx.compose.ui.test.onRootimport androidx.compose.ui.test.performScrollToimport androidx.compose.ui.test.assertIsDisplayedimport androidx.compose.ui.test.performClickimport androidx.compose.ui.test.captureToImageimport androidx.test.ext.junit.runners.AndroidJUnit4import com.cottondb.android.ScreenEvidenceimport com.cottondb.android.legal.LegalDocumentsimport com.cottondb.android.design.CottonThemeimport org.junit.Assert.assertEqualsimport org.junit.Ruleimport org.junit.Testimport org.junit.runner.RunWith@RunWith(AndroidJUnit4::class)classLegalScreenTest { @get:Ruleval compose = createComposeRule() @Testfun privacyPresentsTheStaticSheetAndDelegatesBack() {var backs = 0 compose.setContent {CottonTheme {LegalScreen(LegalDocuments.privacy, onBack = { backs += 1 }) } }ScreenEvidence.capture("legal-privacy") { compose.onRoot().captureToImage().asAndroidBitmap() } compose.onNodeWithText("Privacy").assertExists() compose.onNodeWithText("Last updated 11 August 2026").assertExists() compose.onNodeWithText("Deleting your data").performScrollTo().assertIsDisplayed() compose.onNodeWithText("You can delete any record from inside the app. To delete your account and everything in it, use the \"Report a problem\" option in Settings and ask — it is removed, not archived.", ).assertExists() compose.onNodeWithContentDescription("Back").performClick() assertEquals(1, backs) } @Testfun termsPreservesSectionOrderAndLastParagraph() { compose.setContent {CottonTheme {LegalScreen(LegalDocuments.terms, onBack = {}) } }ScreenEvidence.capture("legal-terms") { compose.onRoot().captureToImage().asAndroidBitmap() } compose.onNodeWithText("Terms").assertExists() compose.onNodeWithText("Your account").assertExists() compose.onNodeWithText("Changes").assertExists() compose.onNodeWithText("These terms can change as the app does. The date at the top says when they last did.", ).assertExists() }}