diff --git a/src/main/java/org/commcare/formplayer/services/MenuSessionFactory.java b/src/main/java/org/commcare/formplayer/services/MenuSessionFactory.java index 2e3799533..52b8b9025 100644 --- a/src/main/java/org/commcare/formplayer/services/MenuSessionFactory.java +++ b/src/main/java/org/commcare/formplayer/services/MenuSessionFactory.java @@ -142,10 +142,9 @@ public Screen rebuildSessionFromFrame(MenuSession menuSession, CaseSearchHelper } if (currentStep != null && currentStep != NEXT_SCREEN && entityScreen.shouldBeSkipped()) { - if (((EntityScreen)screen).autoSelectEntities(menuSession.getSessionWrapper())) { - screen = menuSession.getNextScreen(needsFullInit, entityScreenContext); - continue; - } + menuSession.handleInput(screen, currentStep, needsFullInit, true, false, entityScreenContext); + screen = menuSession.getNextScreen(needsFullInit, entityScreenContext); + continue; } if (currentStep == null && processedStepsCount != steps.size()) { checkAndLogCaseIDMatchError(steps, processedSteps, neededDatum.getDataId()); diff --git a/src/test/java/org/commcare/formplayer/tests/CaseListAutoSelectTests.kt b/src/test/java/org/commcare/formplayer/tests/CaseListAutoSelectTests.kt index 41a1a0b3e..9bc5c43f3 100644 --- a/src/test/java/org/commcare/formplayer/tests/CaseListAutoSelectTests.kt +++ b/src/test/java/org/commcare/formplayer/tests/CaseListAutoSelectTests.kt @@ -2,12 +2,10 @@ package org.commcare.formplayer.tests import org.commcare.formplayer.beans.NewFormResponse import org.commcare.formplayer.beans.menus.EntityListResponse -import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest - @WebMvcTest class CaseListAutoSelectTests : BaseTestClass() { @@ -30,24 +28,7 @@ class CaseListAutoSelectTests : BaseTestClass() { fun testAutoSelection() { // We directly go to the form without selecting the case val selections = arrayOf("0", "2") - var response = sessionNavigate(selections, APP, NewFormResponse::class.java) - - // test breadcrumb - assertEquals( 3, response.breadcrumbs.size) - assertEquals( "Untitled Application", response.breadcrumbs[0]) - assertEquals( "Case List", response.breadcrumbs[1]) - assertEquals( "Followup Form 1", response.breadcrumbs[2]) - - // test persistent menu - val persistentMenu = response.persistentMenu - assertEquals(2, persistentMenu.size) - assertEquals("Case List", persistentMenu[0].displayText) - assertEquals("Case List 1", persistentMenu[1].displayText) - val zeroSelectionMenu = persistentMenu[0].commands - assertEquals(3, zeroSelectionMenu.size) - assertEquals("Registration Form", zeroSelectionMenu[0].displayText) - assertEquals("Followup Form", zeroSelectionMenu[1].displayText) - assertEquals("Followup Form 1", zeroSelectionMenu[2].displayText) + sessionNavigate(selections, APP, NewFormResponse::class.java) } @Test diff --git a/src/test/java/org/commcare/formplayer/tests/MultiSelectCaseClaimTest.java b/src/test/java/org/commcare/formplayer/tests/MultiSelectCaseClaimTest.java index 4fcdc4d7a..088d36570 100644 --- a/src/test/java/org/commcare/formplayer/tests/MultiSelectCaseClaimTest.java +++ b/src/test/java/org/commcare/formplayer/tests/MultiSelectCaseClaimTest.java @@ -17,7 +17,6 @@ import org.commcare.formplayer.beans.NewFormResponse; import org.commcare.formplayer.beans.menus.CommandListResponseBean; import org.commcare.formplayer.beans.menus.EntityListResponse; -import org.commcare.formplayer.beans.menus.PersistentCommand; import org.commcare.formplayer.mocks.FormPlayerPropertyManagerMock; import org.commcare.formplayer.utils.MockRequestUtils; import org.commcare.formplayer.utils.WithHqUser; @@ -203,13 +202,6 @@ public void testAutoSelection() throws Exception { assertEquals(reponse.getSelections().length, 1); assertEquals(reponse.getSelections()[0], "2"); assertEquals("Close", reponse.getCommands()[0].getDisplayText()); - - // Persistent Menu And Breadcrumbs should not contain the auto-selected entities - ArrayList subMenu = reponse.getPersistentMenu().get(2).getCommands(); - assertEquals(1, subMenu.size()); - assertEquals("Close", subMenu.get(0).getDisplayText()); // directly contains the form instead of entity selection - assertEquals(ImmutableList.of("Case Claim", "Follow Up"), - Arrays.stream(reponse.getBreadcrumbs()).toList()); } ArrayList updatedSelections = new ArrayList<>(Arrays.asList(reponse.getSelections())); @@ -219,11 +211,6 @@ public void testAutoSelection() throws Exception { APP_NAME, null, NewFormResponse.class); - ArrayList subMenu = formResponse.getPersistentMenu().get(2).getCommands(); - assertEquals(1, subMenu.size()); - assertEquals("Close", subMenu.get(0).getDisplayText()); - assertEquals(ImmutableList.of("Case Claim", "Follow Up", "Close"), - Arrays.stream(formResponse.getBreadcrumbs()).toList()); } @Test diff --git a/src/test/java/org/commcare/formplayer/tests/MultiSelectCaseListTest.java b/src/test/java/org/commcare/formplayer/tests/MultiSelectCaseListTest.java index 985a434fe..5e364eb23 100644 --- a/src/test/java/org/commcare/formplayer/tests/MultiSelectCaseListTest.java +++ b/src/test/java/org/commcare/formplayer/tests/MultiSelectCaseListTest.java @@ -241,7 +241,6 @@ public void testPersistentMenu() throws Exception { expectedMenu.add(new PersistentCommand("0", "Case List", "jr://file/commcare/image/m0customicon_en.png", NavIconState.NEXT)); expectedMenu.add(new PersistentCommand("1", "Case List", null, NavIconState.NEXT)); expectedMenu.add(new PersistentCommand("2", "Menu with Auto Submit Form", null, NavIconState.NEXT)); - expectedMenu.add(new PersistentCommand("3", "Single Form Auto Select", null, NavIconState.NEXT)); assertEquals(expectedMenu, menuResponse.getPersistentMenu()); selections = new String[]{"0"}; @@ -267,42 +266,4 @@ public void testPersistentMenu() throws Exception { firstSecondMenu.addCommand(new PersistentCommand(guid, "(2) 123, ...", null, NavIconState.ENTITY_SELECT)); assertEquals(expectedMenu, formResponse.getPersistentMenu()); } - - @Test - public void testPersistentMenuWithAutoSelect() throws Exception { - ArrayList expectedMenu = new ArrayList<>(); - expectedMenu.add(new PersistentCommand("0", "Case List", "jr://file/commcare/image/m0customicon_en.png", NavIconState.NEXT)); - expectedMenu.add(new PersistentCommand("1", "Case List", null, NavIconState.NEXT)); - expectedMenu.add(new PersistentCommand("2", "Menu with Auto Submit Form", null, NavIconState.NEXT)); - expectedMenu.add(new PersistentCommand("3", "Single Form Auto Select", null, NavIconState.NEXT)); - PersistentCommand firstMenu = expectedMenu.get(0); - firstMenu.addCommand(new PersistentCommand("0","Registration Form", null, NavIconState.JUMP)); - firstMenu.addCommand(new PersistentCommand("1","Followup Form", null, NavIconState.JUMP)); - firstMenu.addCommand(new PersistentCommand("2","Followup Form with AutoSelect Datum", "jr://file/commcare/image/m0f2customicon_en.png", NavIconState.NEXT)); - firstMenu.addCommand(new PersistentCommand("3","Followup Form with AutoSelect Datum", null, NavIconState.NEXT)); - String[] selections = new String[]{"0", "2"}; - NewFormResponse formResponse = sessionNavigate(selections, APP, NewFormResponse.class); - assertEquals(expectedMenu, formResponse.getPersistentMenu()); - } - - @Test - public void testPersistentMenuWithAutoAdvance() throws Exception { - ArrayList expectedMenu = new ArrayList<>(); - expectedMenu.add(new PersistentCommand("0", "Case List", "jr://file/commcare/image/m0customicon_en.png", NavIconState.NEXT)); - expectedMenu.add(new PersistentCommand("1", "Case List", null, NavIconState.NEXT)); - expectedMenu.add(new PersistentCommand("2", "Menu with Auto Submit Form", null, NavIconState.NEXT)); - expectedMenu.add(new PersistentCommand("3", "Single Form Auto Select", null, NavIconState.NEXT)); - - // Auto-Advance in a Auto Select Case List - String[] selections = new String[]{"3"}; - NewFormResponse formResponse = sessionNavigate(selections, APP, NewFormResponse.class); - assertEquals(expectedMenu, formResponse.getPersistentMenu()); - - FormPlayerPropertyManagerMock.mockAutoAdvanceMenu(storageFactoryMock, false); - selections = new String[]{"3", "0"}; - formResponse = sessionNavigate(selections, APP, NewFormResponse.class); - expectedMenu.get(3).addCommand(new PersistentCommand("0", "Followup Form with AutoSelect Datum", - "jr://file/commcare/image/m0f2customicon_en.png", NavIconState.JUMP)); - assertEquals(expectedMenu, formResponse.getPersistentMenu()); - } } diff --git a/src/test/resources/archives/case_claim_with_multi_select/profile.ccpr b/src/test/resources/archives/case_claim_with_multi_select/profile.ccpr index 5b0088ab3..0c5a5041b 100644 --- a/src/test/resources/archives/case_claim_with_multi_select/profile.ccpr +++ b/src/test/resources/archives/case_claim_with_multi_select/profile.ccpr @@ -72,7 +72,7 @@ - + diff --git a/src/test/resources/archives/case_list_auto_select/profile.ccpr b/src/test/resources/archives/case_list_auto_select/profile.ccpr index c81000147..abe123043 100644 --- a/src/test/resources/archives/case_list_auto_select/profile.ccpr +++ b/src/test/resources/archives/case_list_auto_select/profile.ccpr @@ -21,10 +21,6 @@ - - - - diff --git a/src/test/resources/archives/case_list_auto_select/suite.xml b/src/test/resources/archives/case_list_auto_select/suite.xml index 44f93cf7d..33d96ea66 100644 --- a/src/test/resources/archives/case_list_auto_select/suite.xml +++ b/src/test/resources/archives/case_list_auto_select/suite.xml @@ -118,7 +118,9 @@
http://openrosa.org/formdesigner/99F89DA7-E568-4952-9BAF-717263F2C5DD
- Followup Form 1 + + + @@ -146,7 +148,9 @@ - Case List 1 + + + diff --git a/src/test/resources/archives/multi_select_case_list/suite.xml b/src/test/resources/archives/multi_select_case_list/suite.xml index 4444b731f..f1971da46 100644 --- a/src/test/resources/archives/multi_select_case_list/suite.xml +++ b/src/test/resources/archives/multi_select_case_list/suite.xml @@ -199,11 +199,6 @@ Menu with Auto Submit Form - - Single Form Auto Select - - -