diff --git a/src/test/java/org/commcare/formplayer/tests/MultiSelectCaseClaimTest.java b/src/test/java/org/commcare/formplayer/tests/MultiSelectCaseClaimTest.java index 500d94ee4d..459fb279e3 100644 --- a/src/test/java/org/commcare/formplayer/tests/MultiSelectCaseClaimTest.java +++ b/src/test/java/org/commcare/formplayer/tests/MultiSelectCaseClaimTest.java @@ -3,6 +3,7 @@ import static org.commcare.formplayer.util.Constants.TOGGLE_SESSION_ENDPOINTS; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; @@ -332,4 +333,56 @@ public void testMultiSelectEndpointWithClaim_ValidSelection() throws Exception { checkForSelectedEntitiesInstance(formResponse.getSessionId(), selectedValues); } } + + @Test + @WithHqUser(enabledToggles = {TOGGLE_SESSION_ENDPOINTS}) + public void testCaseListEndpointWithInlineCaseSearch() throws Exception { + try (MockRequestUtils.VerifiedMock ignore = mockRequest.mockQuery( + "query_responses/case_search_multi_select_response.xml")) { + EntityListResponse response = sessionNavigateWithEndpoint(APP_NAME, + "inline_case_search_list_without_selection", + null, + EntityListResponse.class); + assertNotNull(response.getEntities()); + } + } + + + @Test + @WithHqUser(enabledToggles = {TOGGLE_SESSION_ENDPOINTS}) + public void testCaseListSelectionEndpointWithInlineCaseSearch() throws Exception { + String[] selectedValues = new String[]{"94f8d030-c6f9-49e0-bc3f-5e0cdbf10c18", + "0156fa3e-093e-4136-b95c-01b13dae66c7", + "0156fa3e-093e-4136-b95c-01b13dae66c8"}; + String selectedValuesArg = String.join(",", selectedValues); + HashMap endpointArgs = new HashMap<>(); + endpointArgs.put("selected_cases", selectedValuesArg); + try (MockRequestUtils.VerifiedMock ignore = mockRequest.mockQuery( + "query_responses/case_search_multi_select_response.xml")) { + CommandListResponseBean response = sessionNavigateWithEndpoint(APP_NAME, + "inline_case_search_list", + endpointArgs, + CommandListResponseBean.class); + assertEquals(response.getCommands().length, 1); + } + } + + @Test + @WithHqUser(enabledToggles = {TOGGLE_SESSION_ENDPOINTS}) + public void testFormEndpointWithInlineCaseSearch() throws Exception { + String[] selectedValues = new String[]{"94f8d030-c6f9-49e0-bc3f-5e0cdbf10c18", + "0156fa3e-093e-4136-b95c-01b13dae66c7", + "0156fa3e-093e-4136-b95c-01b13dae66c8"}; + String selectedValuesArg = String.join(",", selectedValues); + HashMap endpointArgs = new HashMap<>(); + endpointArgs.put("selected_cases", selectedValuesArg); + try (MockRequestUtils.VerifiedMock ignore = mockRequest.mockQuery( + "query_responses/case_search_multi_select_response.xml")) { + NewFormResponse formResponse = sessionNavigateWithEndpoint(APP_NAME, + "inline_case_search_form", + endpointArgs, + NewFormResponse.class); + checkForSelectedEntitiesInstance(formResponse.getSessionId(), selectedValues); + } + } } diff --git a/src/test/resources/archives/case_claim_with_multi_select/suite.xml b/src/test/resources/archives/case_claim_with_multi_select/suite.xml index 14cb56e55d..04fb0ae572 100644 --- a/src/test/resources/archives/case_claim_with_multi_select/suite.xml +++ b/src/test/resources/archives/case_claim_with_multi_select/suite.xml @@ -259,6 +259,33 @@ + +
http://openrosa.org/formdesigner/5CCB1614-68B3-44C0-A166-D63AA7C1D4FB
+ + + + + + + + + + + + + + + + + + + + + + + + +
@@ -283,6 +310,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +