diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputIconCardTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputMatrixTest.kt similarity index 60% rename from designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputIconCardTest.kt rename to designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputMatrixTest.kt index fc0378483..df0fa9fb4 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputIconCardTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputMatrixTest.kt @@ -7,11 +7,12 @@ import androidx.compose.ui.test.isNotEnabled import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onAllNodesWithTag import androidx.compose.ui.test.onNodeWithTag +import org.hisp.dhis.mobile.ui.designsystem.component.internal.IconCardData import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor import org.junit.Rule import org.junit.Test -class InputIconCardTest { +class InputMatrixTest { @get:Rule val rule = createComposeRule() @@ -75,42 +76,6 @@ class InputIconCardTest { rule.onAllNodesWithTag("MATRIX_ICON_CARD_TEST").assertAll(isEnabled()) } - @Test - fun shouldNotAllowSequentialUserInputWhenDisabled() { - rule.setContent { - InputSequential( - title = "Label", - testTag = "TEST", - data = data, - selectedData = null, - state = InputShellState.DISABLED, - onSelectionChanged = { - // no-op - }, - ) - } - rule.onNodeWithTag("ICON_CARD_INPUT_SEQUENTIAL_TEST").assertExists() - rule.onAllNodesWithTag("SEQUENTIAL_ICON_CARD_TEST").assertAll(isNotEnabled()) - } - - @Test - fun shouldAllowSequentialUserInputWhenEnabled() { - rule.setContent { - InputSequential( - title = "Label", - testTag = "TEST", - data = data, - selectedData = null, - state = InputShellState.UNFOCUSED, - onSelectionChanged = { - // no-op - }, - ) - } - rule.onNodeWithTag("ICON_CARD_INPUT_SEQUENTIAL_TEST").assertExists() - rule.onAllNodesWithTag("SEQUENTIAL_ICON_CARD_TEST").assertAll(isEnabled()) - } - @Test fun shouldShowMatrixLegendCorrectly() { rule.setContent { @@ -149,43 +114,4 @@ class InputIconCardTest { rule.onNodeWithTag("ICON_CARDS_INPUT_TEST_SUPPORTING_TEXT").assertExists() } - - @Test - fun shouldShowSequentialLegendCorrectly() { - rule.setContent { - InputMatrix( - title = "Label", - testTag = "TEST", - data = data, - selectedData = null, - itemCount = 2, - state = InputShellState.UNFOCUSED, - legendData = LegendData(SurfaceColor.CustomGreen, "Legend"), - onSelectionChanged = { - // no-op - }, - ) - } - - rule.onNodeWithTag("ICON_CARDS_INPUT_TEST_LEGEND").assertExists() - } - - @Test - fun shouldShowSequentialSupportingTextCorrectly() { - rule.setContent { - InputSequential( - title = "Label", - testTag = "TEST", - data = data, - selectedData = null, - state = InputShellState.UNFOCUSED, - supportingText = listOf(SupportingTextData("Supporting text", SupportingTextState.DEFAULT)), - onSelectionChanged = { - // no-op - }, - ) - } - - rule.onNodeWithTag("ICON_CARDS_INPUT_TEST_SUPPORTING_TEXT").assertExists() - } } diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputSequentialTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputSequentialTest.kt new file mode 100644 index 000000000..fdf06fe65 --- /dev/null +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputSequentialTest.kt @@ -0,0 +1,115 @@ +package org.hisp.dhis.mobile.ui.designsystem.component + +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.test.assertAll +import androidx.compose.ui.test.isEnabled +import androidx.compose.ui.test.isNotEnabled +import androidx.compose.ui.test.junit4.createComposeRule +import androidx.compose.ui.test.onAllNodesWithTag +import androidx.compose.ui.test.onNodeWithTag +import org.hisp.dhis.mobile.ui.designsystem.component.internal.IconCardData +import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor +import org.junit.Rule +import org.junit.Test + +class InputSequentialTest { + + @get:Rule + val rule = createComposeRule() + + private val data = listOf( + IconCardData( + uid = "7e0cb105-c276-4f12-9f56-a26af8314121", + label = "Stethoscope", + iconRes = "dhis2_stethoscope_positive", + iconTint = Color(0xFFFF8400), + ), + IconCardData( + uid = "72269f6b-6b99-4d2e-a667-09f20c2097e0", + label = "Medicines", + iconRes = "dhis2_medicines_positive", + iconTint = Color(0xFFEB0085), + ), + IconCardData( + uid = "37b81748-e9b4-4f74-a50a-59b945e54aa4", + label = "Sayana press", + iconRes = "dhis2_sayana_press_positive", + iconTint = Color(0xFF1FDB00), + ), + ) + + @Test + fun shouldNotAllowSequentialUserInputWhenDisabled() { + rule.setContent { + InputSequential( + title = "Label", + testTag = "TEST", + data = data, + selectedData = null, + state = InputShellState.DISABLED, + onSelectionChanged = { + // no-op + }, + ) + } + rule.onNodeWithTag("ICON_CARD_INPUT_SEQUENTIAL_TEST").assertExists() + rule.onAllNodesWithTag("SEQUENTIAL_ICON_CARD_TEST").assertAll(isNotEnabled()) + } + + @Test + fun shouldAllowSequentialUserInputWhenEnabled() { + rule.setContent { + InputSequential( + title = "Label", + testTag = "TEST", + data = data, + selectedData = null, + state = InputShellState.UNFOCUSED, + onSelectionChanged = { + // no-op + }, + ) + } + rule.onNodeWithTag("ICON_CARD_INPUT_SEQUENTIAL_TEST").assertExists() + rule.onAllNodesWithTag("SEQUENTIAL_ICON_CARD_TEST").assertAll(isEnabled()) + } + + @Test + fun shouldShowSequentialLegendCorrectly() { + rule.setContent { + InputMatrix( + title = "Label", + testTag = "TEST", + data = data, + selectedData = null, + itemCount = 2, + state = InputShellState.UNFOCUSED, + legendData = LegendData(SurfaceColor.CustomGreen, "Legend"), + onSelectionChanged = { + // no-op + }, + ) + } + + rule.onNodeWithTag("ICON_CARDS_INPUT_TEST_LEGEND").assertExists() + } + + @Test + fun shouldShowSequentialSupportingTextCorrectly() { + rule.setContent { + InputSequential( + title = "Label", + testTag = "TEST", + data = data, + selectedData = null, + state = InputShellState.UNFOCUSED, + supportingText = listOf(SupportingTextData("Supporting text", SupportingTextState.DEFAULT)), + onSelectionChanged = { + // no-op + }, + ) + } + + rule.onNodeWithTag("ICON_CARDS_INPUT_TEST_SUPPORTING_TEXT").assertExists() + } +}