From 72057211ecfc6bbab73e16066fa5a789674fefb7 Mon Sep 17 00:00:00 2001 From: Allan Onchuru <16164649+allan-on@users.noreply.github.com> Date: Fri, 8 Mar 2024 11:52:15 +0300 Subject: [PATCH] Fix Extended FAB NPE (#3119) * Hotfix to allow launching of overflow menu items (Questionnaire/Profile) * Hotfix to allow launching of overflow menu items (Questionnaire/Profile) * Hotfix to allow launching of overflow menu items (Questionnaire/Profile) * Overflow menu items plus new profiles * Overflow menu items plus new profiles * :bug: Remove null assertion for the resourceData var resourceData is null when loading the ExtendedFab in the register hence no need for null assertion * :white_check_mark: Add test for Extended fab initialization Test that Extended Fab can be initialized with null resourceData * :art: Apply Spotless formatting --------- Co-authored-by: Francis Odhiambo Otieno <4540684+f-odhiambo@users.noreply.github.com> Co-authored-by: Peter Lubell-Doughtie Co-authored-by: Sebastian <36365043+SebaMutuku@users.noreply.github.com> --- .../ui/shared/components/ExtendedFabTest.kt | 31 +++++++++++++++++++ .../quest/ui/shared/components/ExtendedFab.kt | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/shared/components/ExtendedFabTest.kt b/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/shared/components/ExtendedFabTest.kt index f64b1db060..d850e2e8c7 100644 --- a/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/shared/components/ExtendedFabTest.kt +++ b/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/shared/components/ExtendedFabTest.kt @@ -67,6 +67,37 @@ class ExtendedFabTest { } } + @Test + fun can_initializing_extended_fab_with_null_resource_data() { + composeRule.setContent { + ExtendedFab( + fabActions = + listOf( + NavigationMenuConfig( + id = "test", + display = "Fab Button", + menuIconConfig = ImageConfig(type = ICON_TYPE_LOCAL, reference = "ic_user"), + actions = + listOf( + ActionConfig( + trigger = ActionTrigger.ON_CLICK, + workflow = ApplicationWorkflow.LAUNCH_QUESTIONNAIRE.name, + questionnaire = QuestionnaireConfig(id = "23", title = "Add Family"), + ), + ), + ), + ), + resourceData = null, + navController = TestNavHostController(LocalContext.current), + lazyListState = null, + ) + } + composeRule + .onNodeWithTag(FAB_BUTTON_TEST_TAG, useUnmergedTree = true) + .assertExists() + .assertIsDisplayed() + } + @Test fun testFloatingButtonIsDisplayed() { init() diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/shared/components/ExtendedFab.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/shared/components/ExtendedFab.kt index ffccca67fd..baff4a9a17 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/shared/components/ExtendedFab.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/shared/components/ExtendedFab.kt @@ -89,7 +89,7 @@ fun ExtendedFab( imageProperties = ImageProperties(imageConfig = firstMenuIconConfig), tint = if (firstFabEnabled) Color.White else DefaultColor, navController = navController, - resourceData = resourceData!!, + resourceData = resourceData, ) } if (text.isNotEmpty()) {