Skip to content

Commit

Permalink
Update personInfo page and update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
bseeger committed Mar 7, 2024
1 parent f4bfeeb commit ef57b9f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/mdbenefits/app/inputs/MdBenefitsFlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ public class MdBenefitsFlow extends FlowInputs {
@NotBlank(message = "{error.missing-firstname}")
private String firstName;

private String middleName;

@NotBlank(message = "{error.missing-lastname}")
private String lastName;

private String otherNames;

private String birthDay;
private String birthMonth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
import org.mdbenefits.app.data.enums.CitizenshipStatus;
Expand All @@ -28,6 +27,10 @@ public Map<String, SubmissionField> prepareSubmissionFields(Submission submissio
Map<String, Object> inputData = submission.getInputData();

String fullName = String.format("%s, %s", inputData.get("lastName"), inputData.get("firstName"));
if (inputData.get("middleName") != null) {
fullName += ", " + inputData.get("middleName");
}

results.put("applicantFullName", new SingleField("applicantFullName", (String) fullName, null));

var dob = Stream.of("birthMonth", "birthDay", "birthYear")
Expand All @@ -48,7 +51,7 @@ public Map<String, SubmissionField> prepareSubmissionFields(Submission submissio
results.put("applicantSex", new SingleField("applicantSex", "", null));
}

if (inputData.getOrDefault("isApplicantPregnant","No").toString().equalsIgnoreCase("Yes")) {
if (inputData.getOrDefault("isApplicantPregnant", "No").toString().equalsIgnoreCase("Yes")) {
results.put("applicantIsPregnantName", new SingleField("applicantIsPregnantName", (String) fullName, null));
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,13 @@ signpost.contact-info=Contact info

# Personal info
personal-info.title=Personal info
personal-info.header=Tell us about yourself
personal-info.header=Let's get to know you
personal-info.firstname=What's your first name?
personal-info.firstname-help=Legally as it appears on your ID
personal-info.middlename=What's your middle name?
personal-info.middlename-help=Legally as it appears on your ID
personal-info.lastname=What's your last name?
personal-info.lastname-help=Legally as it appears on your ID. If you have 2 last names, type it exactly as it is written on your ID (ex: with hyphens, or 2 words).
personal-info.othernames=Other names you use now or have used in the past
personal-info.othernames-help=List maiden names, legal name changes, and gender preferred names.
personal-info.lastname-help=Legally as it appears on your ID.
personal-info.birthdate=When were you born?

personal-info.sex.title=Applicant Sex
Expand Down
9 changes: 5 additions & 4 deletions src/main/resources/templates/mdBenefitsFlow/personalInfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
label=#{personal-info.firstname},
helpText=#{personal-info.firstname-help})}"/>

<th:block th:replace="~{fragments/inputs/text ::
text(inputName='middleName',
label=#{personal-info.middlename},
helpText=#{personal-info.middlename-help})}"/>

<th:block th:replace="~{fragments/inputs/text ::
text(inputName='lastName',
label=#{personal-info.lastname},
helpText=#{personal-info.lastname-help})}"/>

<th:block th:replace="~{fragments/inputs/text ::
text(inputName='otherNames',
label=#{personal-info.othernames},
helpText=#{personal-info.othernames-help})}"/>

<th:block th:replace="~{fragments/inputs/date ::
date(inputName='birth',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,12 +621,12 @@ void completeFlowWithHousehold() {
testPage.selectRadio("householdMemberEnrolledInSchool", "Yes");
testPage.selectRadio("householdMemberHasDisability", "Yes");
testPage.clickContinue();

assertThat(testPage.getTitle()).isEqualTo(message("household-race-and-ethnicity.title"));
testPage.clickElementById("householdMemberRace-WHITE");
testPage.selectRadio("householdMemberEthnicity", EthnicityType.HISPANIC_OR_LATINO.name());
testPage.clickContinue();

assertThat(testPage.getTitle()).isEqualTo(message("household-list.title"));
testPage.clickButton("I'm done");

Expand Down Expand Up @@ -716,6 +716,7 @@ void loadUserPersonalData() {
testPage.navigateToFlowScreen("mdBenefitsFlow/personalInfo");

testPage.enter("firstName", "test");
testPage.enter("middleName", "MiddleName");
testPage.enter("lastName", "test2");
testPage.enter("birthMonth", "12");
testPage.enter("birthDay", "25");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void whenMailingAddressStreetAddress2PresentThenIncludesIt() {
"mailingAddressCity", "Baltimore",
"mailingAddressState", "MD",
"mailingAddressZipCode", "21201"
);
);
assertThat(preparer.formatMailingAddress(inputData)).isEqualTo("10 Main St, Unit #A, Baltimore, MD 21201");
}

Expand All @@ -74,4 +74,10 @@ public void whenMailingAddressStreetAddress2AbsentThenOmitsIt() {
assertThat(preparer.formatMailingAddress(inputData)).isEqualTo("10 Main St, Baltimore, MD 21201");
}

public void testWithMiddleName() {
submission.getInputData().put("middleName", "MiddleName");
Map<String, SubmissionField> result = preparer.prepareSubmissionFields(submission, null);
assertThat(result.get("applicantFullName"))
.isEqualTo(new SingleField("applicantFullName", "Doe, John, MiddleName", null));
}
}

0 comments on commit ef57b9f

Please sign in to comment.