diff --git a/sharedUI/src/commonTest/kotlin/org/shahondin1624/NoContentTruncationTest.kt b/sharedUI/src/commonTest/kotlin/org/shahondin1624/NoContentTruncationTest.kt new file mode 100644 index 0000000..6c53cc4 --- /dev/null +++ b/sharedUI/src/commonTest/kotlin/org/shahondin1624/NoContentTruncationTest.kt @@ -0,0 +1,130 @@ +package org.shahondin1624 + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.width +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.ui.Modifier +import androidx.compose.ui.test.ExperimentalTestApi +import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.getBoundsInRoot +import androidx.compose.ui.test.onNodeWithTag +import androidx.compose.ui.test.runComposeUiTest +import androidx.compose.ui.unit.dp +import org.shahondin1624.lib.components.TestTags +import org.shahondin1624.lib.components.charactermodel.attributespage.AttributesPage +import org.shahondin1624.model.EXAMPLE_CHARACTER +import org.shahondin1624.model.attributes.AttributeType +import org.shahondin1624.theme.LocalWindowSizeClass +import org.shahondin1624.theme.WindowSizeClass +import kotlin.test.Test +import kotlin.test.assertTrue + +/** + * Verifies that attribute names and long talent names are not clipped + * on compact screens (360dp width). + */ +@OptIn(ExperimentalTestApi::class) +class NoContentTruncationTest { + + private val character = EXAMPLE_CHARACTER + + @Test + fun allAttributeNamesExistAndDisplayedAtCompact() = runComposeUiTest { + setContent { + CompositionLocalProvider(LocalWindowSizeClass provides WindowSizeClass.Compact) { + Column(modifier = Modifier.width(360.dp).fillMaxSize()) { + AttributesPage(character) + } + } + } + + waitForIdle() + + // Assert all 8 attribute cards exist and are displayed + for (attrType in AttributeType.entries) { + val tag = TestTags.attributeCard(attrType.name) + onNodeWithTag(tag) + .assertExists("Attribute card '${attrType.name}' should exist") + .assertIsDisplayed() + } + } + + @Test + fun longTalentNameAeronauticsMechanicDisplayed() = runComposeUiTest { + setContent { + CompositionLocalProvider(LocalWindowSizeClass provides WindowSizeClass.Compact) { + Column(modifier = Modifier.width(360.dp).fillMaxSize()) { + AttributesPage(character) + } + } + } + + waitForIdle() + + val tag = TestTags.talentCard("Aeronautics Mechanic") + onNodeWithTag(tag) + .assertExists("Talent card 'Aeronautics Mechanic' should exist") + .assertIsDisplayed() + } + + @Test + fun longTalentNameElectronicWarfareDisplayed() = runComposeUiTest { + setContent { + CompositionLocalProvider(LocalWindowSizeClass provides WindowSizeClass.Compact) { + Column(modifier = Modifier.width(360.dp).fillMaxSize()) { + AttributesPage(character) + } + } + } + + waitForIdle() + + val tag = TestTags.talentCard("Electronic Warfare") + onNodeWithTag(tag) + .assertExists("Talent card 'Electronic Warfare' should exist") + .assertIsDisplayed() + } + + @Test + fun textBoundsWithinCardBoundsAtCompact() = runComposeUiTest { + setContent { + CompositionLocalProvider(LocalWindowSizeClass provides WindowSizeClass.Compact) { + Column(modifier = Modifier.width(360.dp).fillMaxSize()) { + AttributesPage(character) + } + } + } + + waitForIdle() + + // Verify attribute cards have positive, non-zero bounds (not collapsed/clipped) + for (attrType in AttributeType.entries) { + val tag = TestTags.attributeCard(attrType.name) + val bounds = onNodeWithTag(tag).getBoundsInRoot() + assertTrue( + bounds.right > bounds.left, + "Card '${attrType.name}' should have positive width: $bounds" + ) + assertTrue( + bounds.bottom > bounds.top, + "Card '${attrType.name}' should have positive height: $bounds" + ) + } + + // Verify long talent cards have non-zero bounds + val longTalentNames = listOf("Aeronautics Mechanic", "Electronic Warfare") + for (talentName in longTalentNames) { + val tag = TestTags.talentCard(talentName) + val bounds = onNodeWithTag(tag).getBoundsInRoot() + assertTrue( + bounds.right > bounds.left, + "Talent card '$talentName' should have positive width: $bounds" + ) + assertTrue( + bounds.bottom > bounds.top, + "Talent card '$talentName' should have positive height: $bounds" + ) + } + } +}