test: no content truncation test for compact screens (Closes #33)

Add NoContentTruncationTest that renders at 360dp compact width and
verifies: all 8 attribute cards assertExists/assertIsDisplayed, long
talent names ("Aeronautics Mechanic", "Electronic Warfare") are
displayed, and all card bounds have positive width/height. Requires
JVM Compose test runner.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shahondin1624
2026-03-13 13:14:15 +01:00
parent 72623ed0bc
commit 240f01e655

View File

@@ -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"
)
}
}
}