Skip to content

Commit

Permalink
Update ccap start date one page (#74)
Browse files Browse the repository at this point in the history
Added children-ccap-start-date screen and tests 

#187090179

Co-authored-by: Cypress Borg <[email protected]>
Co-authored-by: Sree Prasad <[email protected]>
  • Loading branch information
3 people authored Feb 26, 2024
1 parent a3928b2 commit 17c2bcf
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 32 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/ilgcc/app/inputs/Gcc.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ public class Gcc extends FlowInputs {
private List<String> childcareWeeklySchedule;

private String childAttendsOtherEd;

private String current_uuid;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package org.ilgcc.app.submission.actions;

import static java.util.Collections.emptyList;

import formflow.library.data.FormSubmission;
import formflow.library.data.Submission;
import java.time.DateTimeException;
import java.time.OffsetDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -34,23 +33,38 @@ public Map<String, List<String>> runValidation(FormSubmission formSubmission, Su
Map<String, List<String>> errorMessages = new HashMap<>();
Map<String, Object> inputData = formSubmission.getFormData();
String ccapStartingDate = String.format("%s/%s/%s",
(String) inputData.get("ccapStartMonth"),
(String) inputData.get("ccapStartDay"),
(String) inputData.get("ccapStartYear"));

(String) inputData.get("ccapStartMonth"),
(String) inputData.get("ccapStartDay"),
(String) inputData.get("ccapStartYear"));
String current_uuid = (String) inputData.get("current_uuid");
DateTime present = DateTime.now();
if (this.isDateInvalid(ccapStartingDate)) {
errorMessages.put(INPUT_NAME, List.of(messageSource.getMessage("errors.invalid-date-entered", null, locale)));
}else{
} else if (isChildInChildcare(submission, current_uuid)) {
DateTime dateCCAPStart = dtf.parseDateTime(ccapStartingDate);
DateTime present = DateTime.now();
DateTime earliest_supported_date = dtf.parseDateTime(EARLIEST_DATE_SUPPORTED);

if(this.isDateNotWithinSupportedRange(dateCCAPStart, earliest_supported_date, present)){
if (this.isDateNotWithinSupportedRange(dateCCAPStart, earliest_supported_date, present)) {
errorMessages.put(INPUT_NAME, List.of(
(messageSource.getMessage("errors.date-outside-of-supported-range", List.of(ccapStartingDate).toArray(), locale))));
}
}else{
DateTime dateCCAPStart = dtf.parseDateTime(ccapStartingDate);
if(this.isDateNotWithinSupportedRange(dateCCAPStart, present, null)){
errorMessages.put(INPUT_NAME, List.of((messageSource.getMessage("errors.date-outside-of-supported-range", List.of(ccapStartingDate).toArray(), locale))));
}
}


return errorMessages;
}

public Boolean isChildInChildcare(Submission submission, String uuid){
var children = (List<Map<String, Object>>) submission.getInputData().getOrDefault("children", emptyList());
for(var child : children) {
if(child.get("uuid").equals(uuid)) {
return child.getOrDefault("childInCare", "false").equals("true");
}
}
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ protected boolean isDateInvalid(String date) {
}

protected boolean isDateNotWithinSupportedRange (DateTime date, DateTime earliestSupportedDate, DateTime latestSupportedDate){
return (date.isBefore(earliestSupportedDate) || date.isAfter(latestSupportedDate));
if(latestSupportedDate == null){
return (date.withTimeAtStartOfDay().isBefore(earliestSupportedDate.withTimeAtStartOfDay()) );
}
return (date.withTimeAtStartOfDay().isBefore(earliestSupportedDate.withTimeAtStartOfDay()) || date.withTimeAtStartOfDay().isAfter(latestSupportedDate.withTimeAtStartOfDay()));
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/ilgcc/app/utils/SubmissionUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;

import static java.util.Collections.emptyList;


public class SubmissionUtilities {
public static final DateTimeFormatter MM_DD_YYYY = DateTimeFormatter.ofPattern("M/d/uuuu");
public static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MMMM dd, yyy");
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/flows-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ flow:
children-childcare-weekly-schedule:
subflow: children
nextScreens:
# - name: children-childcare-hourly-schedule
- name: children-ccap-child-other-ed # Skip WIP screens
condition: IsFiveOrOlder
- name: children-add
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ general.eligibility-table.row-4.family=5 people
general.eligibility-table.row-4.income=$6,008
general.eligibility-table.row-5.family=6 people
general.eligibility-table.row-5.income=$6,973
general.button.continue=Continue

general.week.monday=Monday
general.week.tuesday=Tuesday
Expand Down Expand Up @@ -183,8 +184,9 @@ children-ccap-info.race-ethnicity-help-text=Select all that apply. This is optio
children-ccap-in-care.title=CCAP in care
children-ccap-in-care.header=Is {0} already in child care with your chosen provider?
#children-ccap-start-date
children-ccap-start-date.title=CCAP Start Date
children-ccap-start-date.header=When did {0} start care at your chosen provider?
children-ccap-start-date.when-did-title=CCAP Start Date
children-ccap-start-date.when-did-header=When did {0} start care at your chosen provider?
children-ccap-start-date.when-will-header=When will {0} start care at your chosen provider?
#children-childcare-weekly-schedule
children-childcare-weekly-schedule.title=CCAP Childcare Weekly Schedule
children-childcare-weekly-schedule.header=What days is {0} in child care?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<th:block
th:fragment="yesOrNo(inputName, ariaDescribe)"
th:with="
hasHelpText=${!#strings.isEmpty(helpText)},
hasAriaDescribe=${!#strings.isEmpty(ariaDescribe)}"
th:assert="${!#strings.isEmpty(inputName)}, ${hasAriaDescribe}">
<div th:if="${hasHelpText}">
<p th:id="${inputName + '-help-text'}"
th:text="${helpText}"
class="text--help spacing-below-25"></p>
</div>
<button
th:name="${inputName}"
th:aria-describedby="${hasHelpText ? ariaDescribe + ' ' + inputName + '-help-text' : ariaDescribe}"
type="submit"
value="true"
class="button">
<span class="button__icon--left emoji emoji--inline emoji--checkmark"></span>
<span th:text="#{general.inputs.yes}"></span>
</button>
<button
th:name="${inputName}"
th:aria-describedby="${hasHelpText ? ariaDescribe + ' ' + inputName + '-help-text' : ariaDescribe}"
type="submit"
value="false"
class="button">
<span class="button__icon--left emoji emoji--inline emoji--crossmark"></span>
<span th:text="#{general.inputs.no}"></span>
</button>
</th:block>
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<th:block th:replace="${inputContent}"/>
</div>
<div class="form-card__footer">
<th:block th:replace="~{fragments/inputs/yesOrNo :: yesOrNo(
<th:block th:replace="~{fragments/inputs/overrides/yesOrNo :: yesOrNo(
inputName=${inputName},
ariaDescribe='header')}"/>
</div>
Expand Down
34 changes: 21 additions & 13 deletions src/main/resources/templates/gcc/children-ccap-start-date.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
<th:block
th:replace="~{fragments/screens/screenWithOneInput ::

<div th:with="childHasProvider=${fieldData.get('childInCare').equals('true')},
hasProviderHeader=#{children-ccap-start-date.when-did-header(${fieldData.get('childFirstName')})},
noCurrentProviderHeader=#{children-ccap-start-date.when-will-header(${fieldData.get('childFirstName')})}">
<th:block
th:replace="~{fragments/screens/screenWithOneInput ::
screenWithOneInput(
title=#{children-ccap-start-date.title},
header=#{children-ccap-start-date.header(${fieldData.get('childFirstName')})},
buttonLabel='Continue',
title=#{children-ccap-start-date.when-did-title},
header=${childHasProvider ? hasProviderHeader : noCurrentProviderHeader},
buttonLabel=#{general.button.continue},
formAction=${formAction},
iconFragment=~{fragments/gcc-icons :: baby},
inputContent=~{::inputContent})}">
<th:block th:ref="inputContent">
<!-- Be sure to have `ariaLabel='header'` to label the input with the header -->
<th:block th:replace="~{fragments/inputs/date ::
date(inputName='ccapStart',
label='',
ariaLabel='header',
groupName='ccapStartDate')}"/>
<th:block th:ref="inputContent">
<input type="hidden" th:name="current_uuid" th:value="${fieldData.get('uuid')}">
<th:block th:replace="~{fragments/inputs/date ::
date(inputName='ccapStart',
label='',
ariaLabel='header',
groupName='ccapStartDate')}"/>
</th:block>
</th:block>
</th:block>
</div>



29 changes: 28 additions & 1 deletion src/test/java/org/ilgcc/app/journeys/GccFlowJourneyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,36 @@ void fullGccFlow() {
testPage.clickContinue();
//children-ccap-in-care
assertThat(testPage.getTitle()).isEqualTo("CCAP in care");
testPage.clickButton("No");
//children-ccap-start-date (Test No logic)
assertThat(testPage.getTitle()).isEqualTo("CCAP Start Date");
assertThat((testPage.getHeader())).isEqualTo("When will child start care at your chosen provider?");
testPage.enter("ccapStartMonth", "*1");
testPage.enter("ccapStartDay", "1");
testPage.enter("ccapStartYear", "1889");
testPage.clickContinue();
assertThat(testPage.hasErrorText("Please check the date entered. It is not a valid date.")).isTrue();
testPage.enter("ccapStartMonth", "1");
testPage.enter("ccapStartDay", "1");
testPage.enter("ccapStartYear", "1989");
testPage.clickContinue();
assertThat(testPage.hasErrorText("Please check the date entered. " + "1/1/1989" + " is not a supported start date.")).isTrue();
testPage.enter("ccapStartMonth", "1");
testPage.enter("ccapStartDay", "1");
testPage.enter("ccapStartYear", "2089");
testPage.clickContinue();
assertThat(testPage.getTitle()).isEqualTo("CCAP Childcare Weekly Schedule");
testPage.goBack();
testPage.goBack();
testPage.goBack();
testPage.goBack();
//children-ccap-in-care
assertThat(testPage.getTitle()).isEqualTo("CCAP in care");
testPage.clickButton("Yes");
//children-ccap-start-date
//children-ccap-start-date (Test Yes Logic)
assertThat(testPage.getTitle()).isEqualTo("CCAP Start Date");
assertThat((testPage.getHeader())).isEqualTo("When did child start care at your chosen provider?");

testPage.enter("ccapStartMonth", "11");
testPage.enter("ccapStartDay", "1");
testPage.enter("ccapStartYear", "1889");
Expand Down

0 comments on commit 17c2bcf

Please sign in to comment.