diff --git a/app/src/main/java/com/example/ui/components/InterpretationCard.kt b/app/src/main/java/com/example/ui/components/InterpretationCard.kt index 9d08787..b215c96 100644 --- a/app/src/main/java/com/example/ui/components/InterpretationCard.kt +++ b/app/src/main/java/com/example/ui/components/InterpretationCard.kt @@ -29,6 +29,10 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.semantics.role +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.semantics.stateDescription import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.example.engine.StaveInterpretationData @@ -104,6 +108,10 @@ fun InterpretationCard( Row( modifier = Modifier .fillMaxWidth() + .semantics { + role = Role.Button + stateDescription = if (expandedRitual) "Развёрнуто" else "Свёрнуто" + } .clickable { expandedRitual = !expandedRitual } .padding(vertical = 8.dp), horizontalArrangement = Arrangement.SpaceBetween, diff --git a/app/src/test/java/com/example/ui/components/InterpretationCardTest.kt b/app/src/test/java/com/example/ui/components/InterpretationCardTest.kt new file mode 100644 index 0000000..0ffec4e --- /dev/null +++ b/app/src/test/java/com/example/ui/components/InterpretationCardTest.kt @@ -0,0 +1,57 @@ +package com.example.ui.components + +import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.junit4.createComposeRule +import androidx.compose.ui.test.onNodeWithText +import androidx.compose.ui.test.performClick +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.example.engine.RuneRole +import com.example.engine.StaveInterpretationData +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.annotation.Config + +@RunWith(AndroidJUnit4::class) +@Config(sdk = [33]) +class InterpretationCardTest { + + @get:Rule + val composeTestRule = createComposeRule() + + @Test + fun interpretationCard_rendersAndTogglesAccordion() { + val sampleData = StaveInterpretationData( + title = "Тестовый Став Защиты", + summary = "Общее толкование тестового става для проверки интерфейса.", + runeRoles = listOf( + RuneRole("Fehu", "Исток", "Привлечение энергии и ресурсов."), + RuneRole("Uruz", "Врата", "Наделение физической силой.") + ), + strokeOrderAdvice = "Наносите сначала центральные оси, затем боковые ветви.", + activationSteps = listOf("Оговорите намерение.", "Активируйте дыханием."), + carryingAdvice = "Носить при себе как амулет.", + deactivationAdvice = "С благодарностью сжечь.", + disclaimer = "Символический арт-инструмент." + ) + + composeTestRule.setContent { + InterpretationCard(data = sampleData) + } + + // Verify summary and title rendered + composeTestRule.onNodeWithText("Тестовый Став Защиты").assertIsDisplayed() + composeTestRule.onNodeWithText("Общее толкование тестового става для проверки интерфейса.").assertIsDisplayed() + + // Accordion initially collapsed + composeTestRule.onNodeWithText("Инструкция: нанесение и активация").assertIsDisplayed() + + // Click accordion header + composeTestRule.onNodeWithText("Инструкция: нанесение и активация").performClick() + composeTestRule.waitForIdle() + + // Verify expanded content exists in hierarchy + composeTestRule.onNodeWithText("Наносите сначала центральные оси, затем боковые ветви.").assertExists() + composeTestRule.onNodeWithText("1. Оговорите намерение.").assertExists() + } +}