From 67cce3e0b26efdc26164edbc5cf18ffd727f099d Mon Sep 17 00:00:00 2001 From: Sasikanth Miriyampalli Date: Thu, 2 Nov 2023 17:26:22 +0530 Subject: [PATCH] ANDROAPP-5684-mobile-ui-legend-component-info-icon-visibility (#131) * Hide legend info icon when there is no popup description data * Disable click when legend doesn't contain popup description data * Fix broken tests * Add test for legend click action --- .../hisp/dhis/common/screens/LegendScreen.kt | 21 ++++++++ .../ui/designsystem/component/Legend.kt | 28 ++++++++--- .../component/BasicInputImageTest.kt | 4 +- .../component/InputCheckBoxTest.kt | 4 +- .../component/InputCoordinateTest.kt | 4 +- .../component/InputDropDownTest.kt | 4 +- .../designsystem/component/InputEmailTest.kt | 4 +- .../component/InputIntegerTest.kt | 4 +- .../designsystem/component/InputLetterTest.kt | 4 +- .../designsystem/component/InputLinkTest.kt | 4 +- .../component/InputLongTextTest.kt | 4 +- .../component/InputNegativeIntegerTest.kt | 4 +- .../designsystem/component/InputNumberTest.kt | 4 +- .../component/InputOrgUnitTest.kt | 4 +- .../component/InputPercentageTest.kt | 4 +- .../component/InputPolygonTest.kt | 4 +- .../InputPositiveIntegerOrZeroTest.kt | 4 +- .../component/InputPositiveIntegerTest.kt | 4 +- .../component/InputRadioButtonTest.kt | 4 +- .../designsystem/component/InputTextTest.kt | 4 +- .../component/InputUnitIntervalTest.kt | 4 +- .../component/InputYesNoFieldTest.kt | 4 +- .../component/InputYesOnlyCheckBoxTest.kt | 4 +- .../component/InputYesOnlySwitchTest.kt | 4 +- .../ui/designsystem/component/LegendTest.kt | 49 +++++++++++++++++++ 25 files changed, 134 insertions(+), 52 deletions(-) create mode 100644 designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/LegendTest.kt diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/LegendScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/LegendScreen.kt index fa8344119..885088309 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/LegendScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/LegendScreen.kt @@ -7,6 +7,7 @@ import androidx.compose.ui.Modifier import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer import org.hisp.dhis.mobile.ui.designsystem.component.Legend import org.hisp.dhis.mobile.ui.designsystem.component.LegendData +import org.hisp.dhis.mobile.ui.designsystem.component.LegendDescriptionData import org.hisp.dhis.mobile.ui.designsystem.component.SubTitle import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor @@ -33,5 +34,25 @@ fun LegendScreen() { " consectetur adipiscing elit. Maecenas dolor lacus,", ), ) + + SubTitle("Legend with popup description") + Legend( + LegendData( + color = SurfaceColor.CustomGreen, + title = "Legend with popup", + popUpLegendDescriptionData = listOf( + LegendDescriptionData( + color = SurfaceColor.CustomGreen, + text = "Item 1", + range = 0..300, + ), + LegendDescriptionData( + color = SurfaceColor.CustomGreen, + text = "Item 2", + range = 301..600, + ), + ), + ), + ) } } diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Legend.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Legend.kt index dc3bd285c..303a30d9c 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Legend.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Legend.kt @@ -45,8 +45,9 @@ fun Legend( var showBottomSheetShell by rememberSaveable { mutableStateOf(false) } CompositionLocalProvider(LocalRippleTheme provides Ripple.CustomDHISRippleTheme) { - Column( - modifier = modifier + val hasPopupLegendDescriptionData = legendData.popUpLegendDescriptionData.orEmpty().isNotEmpty() + val clickableModifier = if (hasPopupLegendDescriptionData) { + Modifier .clickable( onClick = { legendData.popUpLegendDescriptionData?.let { @@ -54,7 +55,15 @@ fun Legend( } }, ) - .hoverPointerIcon(true), + .hoverPointerIcon(true) + } else { + Modifier + } + + Column( + modifier = modifier + .then(clickableModifier) + .testTag("LEGEND"), ) { Row( modifier = Modifier @@ -76,11 +85,14 @@ fun Legend( .weight(2f, true), style = MaterialTheme.typography.bodyMedium, ) - Icon( - imageVector = Icons.Outlined.HelpOutline, - contentDescription = "Legend Icon", - modifier = Modifier.size(InternalSizeValues.Size18), - ) + + if (hasPopupLegendDescriptionData) { + Icon( + imageVector = Icons.Outlined.HelpOutline, + contentDescription = "Legend Icon", + modifier = Modifier.size(InternalSizeValues.Size18), + ) + } } Divider( modifier = Modifier diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicInputImageTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicInputImageTest.kt index 1cd9e5087..fef512138 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicInputImageTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicInputImageTest.kt @@ -6,7 +6,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsEnabled import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.junit4.createComposeRule @@ -212,7 +212,7 @@ class BasicInputImageTest { } rule.onNodeWithTag("INPUT_IMAGE").assertExists() rule.onNodeWithTag("INPUT_IMAGE_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_IMAGE_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_IMAGE_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputCheckBoxTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputCheckBoxTest.kt index aa333c095..ed2c34aa5 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputCheckBoxTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputCheckBoxTest.kt @@ -5,7 +5,7 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.test.assert -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsFocused import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertIsNotFocused @@ -235,7 +235,7 @@ class InputCheckBoxTest { rule.onNodeWithTag("INPUT_CHECK_BOX").assertExists() rule.onNodeWithTag("INPUT_CHECK_BOX_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_CHECK_BOX_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_CHECK_BOX_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputCoordinateTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputCoordinateTest.kt index 51b8f80e5..863a2acec 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputCoordinateTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputCoordinateTest.kt @@ -4,7 +4,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsEnabled import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.junit4.createComposeRule @@ -143,7 +143,7 @@ class InputCoordinateTest { } rule.onNodeWithTag("INPUT_COORDINATE").assertExists() rule.onNodeWithTag("INPUT_COORDINATE_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_COORDINATE_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_COORDINATE_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDropDownTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDropDownTest.kt index 720f80021..99b10dd6c 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDropDownTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDropDownTest.kt @@ -4,7 +4,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsEnabled import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertTextEquals @@ -142,7 +142,7 @@ class InputDropDownTest { } rule.onNodeWithTag("INPUT_DROPDOWN").assertExists() rule.onNodeWithTag("INPUT_DROPDOWN_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_DROPDOWN_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_DROPDOWN_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputEmailTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputEmailTest.kt index 4d8ba0cf6..aa9feaa13 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputEmailTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputEmailTest.kt @@ -6,7 +6,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.test.assert -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsEnabled import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertTextEquals @@ -151,7 +151,7 @@ class InputEmailTest { } rule.onNodeWithTag("INPUT_EMAIL").assertExists() rule.onNodeWithTag("INPUT_EMAIL_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_EMAIL_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_EMAIL_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputIntegerTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputIntegerTest.kt index 09f922f53..20170bb7d 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputIntegerTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputIntegerTest.kt @@ -5,7 +5,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.test.assert -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertTextEquals import androidx.compose.ui.test.hasText @@ -123,7 +123,7 @@ class InputIntegerTest { } rule.onNodeWithTag("INPUT_INTEGER").assertExists() rule.onNodeWithTag("INPUT_INTEGER_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_INTEGER_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_INTEGER_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLetterTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLetterTest.kt index 0ee982ec8..0f611e9f3 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLetterTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLetterTest.kt @@ -7,7 +7,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.test.assert -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertTextEquals import androidx.compose.ui.test.hasText @@ -131,7 +131,7 @@ class InputLetterTest { } rule.onNodeWithTag("INPUT_LETTER").assertExists() rule.onNodeWithTag("INPUT_LETTER_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_LETTER_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_LETTER_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLinkTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLinkTest.kt index bdf4dcdc7..ab58154d9 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLinkTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLinkTest.kt @@ -6,7 +6,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.test.assert -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsEnabled import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertTextEquals @@ -152,7 +152,7 @@ class InputLinkTest { } rule.onNodeWithTag("INPUT_LINK").assertExists() rule.onNodeWithTag("INPUT_LINK_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_LINK_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_LINK_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLongTextTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLongTextTest.kt index c1e91f0ac..f7a6d4c79 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLongTextTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLongTextTest.kt @@ -7,7 +7,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.test.assert -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertTextEquals import androidx.compose.ui.test.hasText @@ -131,7 +131,7 @@ class InputLongTextTest { } rule.onNodeWithTag("INPUT_LONG_TEXT").assertExists() rule.onNodeWithTag("INPUT_LONG_TEXT_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_LONG_TEXT_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_LONG_TEXT_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNegativeIntegerTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNegativeIntegerTest.kt index d7ff0564c..2f2c4edfc 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNegativeIntegerTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNegativeIntegerTest.kt @@ -5,7 +5,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.test.assert -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.createComposeRule @@ -121,7 +121,7 @@ class InputNegativeIntegerTest { } rule.onNodeWithTag("INPUT_NEGATIVE_INTEGER").assertExists() rule.onNodeWithTag("INPUT_NEGATIVE_INTEGER_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_NEGATIVE_INTEGER_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_NEGATIVE_INTEGER_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNumberTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNumberTest.kt index a7645c247..338de2fcf 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNumberTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNumberTest.kt @@ -7,7 +7,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.test.assert -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertTextEquals import androidx.compose.ui.test.hasText @@ -131,7 +131,7 @@ class InputNumberTest { } rule.onNodeWithTag("INPUT_NUMBER").assertExists() rule.onNodeWithTag("INPUT_NUMBER_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_NUMBER_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_NUMBER_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputOrgUnitTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputOrgUnitTest.kt index 2d058015b..8cff0625d 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputOrgUnitTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputOrgUnitTest.kt @@ -5,7 +5,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsEnabled import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertTextEquals @@ -146,7 +146,7 @@ class InputOrgUnitTest { } rule.onNodeWithTag("INPUT_ORG_UNIT").assertExists() rule.onNodeWithTag("INPUT_ORG_UNIT_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_ORG_UNIT_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_ORG_UNIT_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPercentageTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPercentageTest.kt index 5d5ae0dd7..79795d8f4 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPercentageTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPercentageTest.kt @@ -5,7 +5,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.test.assert -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertTextEquals import androidx.compose.ui.test.hasText @@ -122,7 +122,7 @@ class InputPercentageTest { } rule.onNodeWithTag("INPUT_PERCENTAGE").assertExists() rule.onNodeWithTag("INPUT_PERCENTAGE_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_PERCENTAGE_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_PERCENTAGE_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPolygonTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPolygonTest.kt index 5ccf16371..c785cac61 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPolygonTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPolygonTest.kt @@ -4,7 +4,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsEnabled import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.junit4.createComposeRule @@ -141,7 +141,7 @@ class InputPolygonTest { } rule.onNodeWithTag("INPUT_POLYGON").assertExists() rule.onNodeWithTag("INPUT_POLYGON_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_POLYGON_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_POLYGON_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveIntegerOrZeroTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveIntegerOrZeroTest.kt index 35224b3ae..3e35b9518 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveIntegerOrZeroTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveIntegerOrZeroTest.kt @@ -5,7 +5,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.test.assert -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertTextEquals import androidx.compose.ui.test.hasText @@ -123,7 +123,7 @@ class InputPositiveIntegerOrZeroTest { } rule.onNodeWithTag("INPUT_POSITIVE_INTEGER_OR_ZERO").assertExists() rule.onNodeWithTag("INPUT_POSITIVE_INTEGER_OR_ZERO_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_POSITIVE_INTEGER_OR_ZERO_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_POSITIVE_INTEGER_OR_ZERO_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveIntegerTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveIntegerTest.kt index 1a2663dab..b964ffcd5 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveIntegerTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveIntegerTest.kt @@ -5,7 +5,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.test.assert -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertTextEquals import androidx.compose.ui.test.hasText @@ -123,7 +123,7 @@ class InputPositiveIntegerTest { } rule.onNodeWithTag("INPUT_POSITIVE_INTEGER").assertExists() rule.onNodeWithTag("INPUT_POSITIVE_INTEGER_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_POSITIVE_INTEGER_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_POSITIVE_INTEGER_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputRadioButtonTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputRadioButtonTest.kt index 095cabc62..81d69ebcd 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputRadioButtonTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputRadioButtonTest.kt @@ -6,7 +6,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsNotSelected import androidx.compose.ui.test.assertIsSelected import androidx.compose.ui.test.junit4.createComposeRule @@ -227,7 +227,7 @@ class InputRadioButtonTest { rule.onNodeWithTag("RADIO_BUTTON_INPUT").assertExists() rule.onNodeWithTag("RADIO_BUTTON_INPUT_LEGEND").assertExists() - rule.onNodeWithTag("RADIO_BUTTON_INPUT_LEGEND").assertHasClickAction() + rule.onNodeWithTag("RADIO_BUTTON_INPUT_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputTextTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputTextTest.kt index 96b70ae2f..00181993b 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputTextTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputTextTest.kt @@ -7,7 +7,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.test.assert -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertTextEquals import androidx.compose.ui.test.hasText @@ -131,7 +131,7 @@ class InputTextTest { } rule.onNodeWithTag("INPUT_TEXT").assertExists() rule.onNodeWithTag("INPUT_TEXT_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_TEXT_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_TEXT_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputUnitIntervalTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputUnitIntervalTest.kt index ea2b72711..5542e6e4b 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputUnitIntervalTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputUnitIntervalTest.kt @@ -5,7 +5,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.test.assert -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertTextEquals import androidx.compose.ui.test.hasText @@ -122,7 +122,7 @@ class InputUnitIntervalTest { } rule.onNodeWithTag("INPUT_UNIT_INTERVAL").assertExists() rule.onNodeWithTag("INPUT_UNIT_INTERVAL_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_UNIT_INTERVAL_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_UNIT_INTERVAL_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputYesNoFieldTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputYesNoFieldTest.kt index 365d99d72..924274dbb 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputYesNoFieldTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputYesNoFieldTest.kt @@ -6,7 +6,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsNotSelected import androidx.compose.ui.test.assertIsSelected import androidx.compose.ui.test.junit4.createComposeRule @@ -175,7 +175,7 @@ class InputYesNoFieldTest { rule.onNodeWithTag("INPUT_YES_NO_FIELD").assertExists() rule.onNodeWithTag("INPUT_YES_NO_FIELD_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_YES_NO_FIELD_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_YES_NO_FIELD_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputYesOnlyCheckBoxTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputYesOnlyCheckBoxTest.kt index 679d3dcf5..ee0c6a37c 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputYesOnlyCheckBoxTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputYesOnlyCheckBoxTest.kt @@ -7,7 +7,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.test.assert -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsEnabled import androidx.compose.ui.test.assertIsFocused import androidx.compose.ui.test.assertIsNotEnabled @@ -102,7 +102,7 @@ class InputYesOnlyCheckBoxTest { } rule.onNodeWithTag("INPUT_YES_ONLY_CHECKBOX").assertExists() rule.onNodeWithTag("INPUT_YES_ONLY_CHECKBOX_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_YES_ONLY_CHECKBOX_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_YES_ONLY_CHECKBOX_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputYesOnlySwitchTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputYesOnlySwitchTest.kt index a32d4a1f1..d04bb4363 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputYesOnlySwitchTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputYesOnlySwitchTest.kt @@ -6,7 +6,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag -import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction import androidx.compose.ui.test.assertIsFocused import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.junit4.createComposeRule @@ -102,7 +102,7 @@ class InputYesOnlySwitchTest { rule.onNodeWithTag("INPUT_YES_ONLY_SWITCH").assertExists() rule.onNodeWithTag("INPUT_YES_ONLY_SWITCH_LEGEND").assertExists() - rule.onNodeWithTag("INPUT_YES_ONLY_SWITCH_LEGEND").assertHasClickAction() + rule.onNodeWithTag("INPUT_YES_ONLY_SWITCH_LEGEND").assertHasNoClickAction() } @Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/LegendTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/LegendTest.kt new file mode 100644 index 000000000..af233495a --- /dev/null +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/LegendTest.kt @@ -0,0 +1,49 @@ +package org.hisp.dhis.mobile.ui.designsystem.component + +import androidx.compose.runtime.getValue +import androidx.compose.runtime.setValue +import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertHasNoClickAction +import androidx.compose.ui.test.junit4.createComposeRule +import androidx.compose.ui.test.onNodeWithTag +import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor +import org.junit.Rule +import org.junit.Test + +class LegendTest { + + @get:Rule + val rule = createComposeRule() + + @Test + fun legendShouldBeClickableIfItHasPopupDescription() { + rule.setContent { + Legend( + legendData = LegendData( + SurfaceColor.CustomGreen, + "Legend", + popUpLegendDescriptionData = listOf( + LegendDescriptionData( + color = SurfaceColor.CustomGreen, + text = "Item 1", + range = 0..300, + ), + ), + ), + ) + } + + rule.onNodeWithTag("LEGEND").assertHasClickAction() + } + + @Test + fun legendShouldNotBeClickableIfThereIsNoPopupDescription() { + rule.setContent { + Legend( + legendData = LegendData(SurfaceColor.CustomGreen, "Legend", popUpLegendDescriptionData = null), + ) + } + + rule.onNodeWithTag("LEGEND").assertHasNoClickAction() + } +}