Skip to content

Commit

Permalink
Fix Extended FAB NPE (#3119)
Browse files Browse the repository at this point in the history
* 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

* 🐛 Remove null assertion for the resourceData var

resourceData is null when loading the ExtendedFab in the register hence no need for null assertion

* ✅ Add test for Extended fab initialization

Test that Extended Fab can be initialized with null resourceData

* 🎨 Apply Spotless formatting

---------

Co-authored-by: Francis Odhiambo Otieno <[email protected]>
Co-authored-by: Peter Lubell-Doughtie <[email protected]>
Co-authored-by: Sebastian <[email protected]>
  • Loading branch information
4 people authored Mar 8, 2024
1 parent 6d586c6 commit 7205721
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 7205721

Please sign in to comment.