Skip to content

Commit

Permalink
Switch to radio buttons and update wording
Browse files Browse the repository at this point in the history
  • Loading branch information
vrajmohan committed Feb 15, 2024
1 parent 2faba9f commit 716444e
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 54 deletions.
14 changes: 7 additions & 7 deletions src/main/java/org/mdbenefits/app/inputs/MdBenefitsFlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,13 @@ public class MdBenefitsFlow extends FlowInputs {
@DynamicField
private String docType;

private List<String> noOneHasDrugKingpinFelony;
private List<String> noOneHasVolumeDrugDealerFelony;
private List<String> noOneHasSexualOffenceConviction;
private List<String> noOneIsViolatingParole;
private List<String> noOneConvictedForLyingAboutBenefits;
private List<String> noOneConvictedForTradingBenefits;
private List<String> noOneIsReceivingBenefitsWithFakeID;
private String someoneHasDrugKingpinFelony;
private String someoneHasVolumeDrugDealerFelony;
private String someoneHasSexualOffenceConviction;
private String someoneIsViolatingParole;
private String someoneConvictedForLyingAboutBenefits;
private String someoneConvictedForTradingBenefits;
private String someoneIsReceivingBenefitsWithFakeID;

@NotEmpty(message = "{error.must-accept-terms}")
private List<String> tcaAcknowledgementAgree;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,11 @@ public Map<String, SubmissionField> prepareSubmissionFields(Submission submissio
new SingleField("applicantSSN", SubmissionUtilities.formatSSN((String) inputData.get("encryptedSSN")), null));
results.put("speaksEnglish", new SingleField("speaksEnglish", (String) "Yes", null));

prepareAnswersToSensitiveQuestions(inputData, results);
// TODO - this will get finished when design says it's ready
//prepareCitizenshipStatus(inputData, results);
return results;
}

private void prepareAnswersToSensitiveQuestions(Map<String, Object> inputData, Map<String, SubmissionField> results) {
for (String question : SubmissionUtilities.SENSITIVE_CONVICTION_QUESTIONS) {
String yesField = "noOne" + question;
String noField = "someone" + question;
List<String> response = (List<String>) inputData.get(yesField + "[]");
if (response != null && response.contains("true")) {
results.put(yesField, new SingleField(yesField, "Yes", null));
} else {
results.put(noField, new SingleField(noField, "Yes", null));
}
}
}

private void prepareCitizenshipStatus(Map<String, Object> inputData, Map<String, SubmissionField> results) {
boolean allAreCitizens = ((String) inputData.get("allAreCitizens")).equalsIgnoreCase("yes");
boolean applyingForSelf = ((String) inputData.get("isApplicantApplying")).equalsIgnoreCase("yes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public class SetDefaultSensitiveConvictionAnswers implements Action {

@Override
public void run(Submission submission) {
Arrays.stream(SubmissionUtilities.SENSITIVE_CONVICTION_QUESTIONS).forEach(s -> submission.getInputData().putIfAbsent("noOne" + s + "[]", "true"));
Arrays.stream(SubmissionUtilities.SENSITIVE_CONVICTION_QUESTIONS).forEach(s -> submission.getInputData().putIfAbsent("someone" + s, "false"));
}
}
27 changes: 17 additions & 10 deletions src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -917,16 +917,23 @@ legal-stuff.answer-legal-question=Answer legal questions
legal-stuff.review-legal-agreements=Review legal agreements
legal-stuff.sign-and-submit=Sign and submit
sensitive-conviction-questions.title=Sensitive Questions
sensitive-conviction-questions.header=Please check what is true for you and everyone in your household
sensitive-conviction-questions.subtext=If any statements are not true, you can talk to a case worker after submitting your application to see who is able to get benefits.
sensitive-conviction-question-HasDrugKingpinFelony=No one has been convicted of a felony that involved conspiring to supervise, organize, finance, or manage the making, transporting, or selling of controlled substances in the State on or after August 22, 1996.
sensitive-conviction-question-HasVolumeDrugDealerFelony=No one has been convicted of a felony that involved making, distributing, dispensing, or possessing controlled substances on or after August 22, 1996.
sensitive-conviction-question-HasSexualOffenceConviction=<p>No one has been convicted after February 7, 2014 of aggravated sexual abuse, murder, sexual exploitation and other abuse of children, sexual assault<sup>*</sup> and is also not in compliance with the terms of their sentence?</p><p><small><sup>*</sup>as defined in the Violence Against Women Act of 1994, or a similar state law.</small></p>
sensitive-conviction-question-IsViolatingParole=No one is violating parole, probation or fleeing from police or the courts.
sensitive-conviction-question-ConvictedForLyingAboutBenefits=Since August 22, 1996, no one has been convicted in courts of lying about where they lived or their identity in order to receive food benefits or cash assistance from multiple places in the same month.
sensitive-conviction-question-ConvictedForTradingBenefits=No one has been convicted in a court for trafficking $500 or more of food benefits.
sensitive-conviction-question-IsReceivingBenefitsWithFakeID=No one is getting food or cash benefits under a different identity or as a member of another household in another State.
sensitive-conviction-question-true=True
sensitive-conviction-questions.header=Please answer the following questions for you and everyone in your household
sensitive-conviction-questions.subtext=<p>If any of the following are "yes" for a member of your household, they may not be allowed to receive TCA or SNAP. <strong>However, they may still be eligible.</strong> After submitting your application, you can talk to a caseworker to see who can get benefits.</p>\
<p> It's essential to be honest so you and your household get the benefits you're entitled to. There are also penalties for providing false information.</p>

sensitive-conviction-question-HasDrugKingpinFelony=<p>Has anyone in your household been convicted of a drug kingpin felony on or after August 22, 1996?</p> \
<p class="text--small">A drug kingpin is an organizer, supervisor, financier, or manager who acts as a co-conspirator in a conspiracy to manufacture, distribute, dispense, transport in, or bring into the State a controlled dangerous substance.</p>
sensitive-conviction-question-HasVolumeDrugDealerFelony=<p>Has anyone in your household been convicted of a volume dealer drug felony on or after August 22, 1996?</p> \
<p class="text--small">A volume dealer is an individual, who manufactures, distributes, dispenses or possesses certain quantities of a controlled dangerous substance.</p>
sensitive-conviction-question-HasSexualOffenceConviction=<p>Has anyone in your household been convicted after February 7, 2014 of aggravated sexual abuse, murder, sexual exploitation and other abuse of children, sexual assault*, or a similar state law, and is also not in compliance with the terms of their sentence?</p>\
<p class="text--small"><sup>*</sup>as defined in the Violence Against Women Act of 1994, or a similar state law.</p>
sensitive-conviction-question-IsViolatingParole=Is anyone in your household currently violating parole or probation or fleeing from the police or the courts?
sensitive-conviction-question-ConvictedForLyingAboutBenefits=Has anyone in your household been convicted since August 22, 1996 in a federal or state court for not telling the truth about where they lived or their identity in order to receive food supplement benefits or cash assistance from more than one place in the same month?
sensitive-conviction-question-ConvictedForTradingBenefits=Has a court convicted any member of your household for trading or trafficking SNAP benefits of $500 or more?
sensitive-conviction-question-IsReceivingBenefitsWithFakeID=Is anyone in your household receiving benefits under another identity or as a member of another household or in another State?
sensitive-conviction-question-yes=Yes
sensitive-conviction-question-no=No

sensitive-conviction-questions-intro.title=Sensitive Questions Intro
sensitive-conviction-questions-intro.header=Sensitive questions
sensitive-conviction-questions-intro.subtext=We need to ask you questions that may be sensitive.
Expand Down
11 changes: 2 additions & 9 deletions src/main/resources/pdf-map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,17 @@ inputFields:
mailingAddress: mailingAddress
signature: signature
sex: applicantSex

isApplicantApplying: isApplicantApplying
citizenshipStatus: isApplicantCitizen

someoneInHHIsPregnant: someoneInHHIsPregnant

someoneHasDrugKingpinFelony: someoneHasDrugKingpinFelony
noOneHasDrugKingpinFelony: noOneHasDrugKingpinFelony
someoneHasVolumeDrugDealerFelony: someoneHasVolumeDrugDealerFelony
noOneHasVolumeDrugDealerFelony: noOneHasVolumeDrugDealerFelony
someoneHasSexualOffenceConviction: someoneHasSexualOffenceConviction
noOneHasSexualOffenceConviction: noOneHasSexualOffenceConviction
someoneIsViolatingParole: someoneIsViolatingParole
noOneIsViolatingParole: noOneIsViolatingParole
someoneConvictedForLyingAboutBenefits: someoneConvictedForLyingAboutBenefits
noOneConvictedForLyingAboutBenefits: noOneConvictedForLyingAboutBenefits
someoneConvictedForTradingBenefits: someoneConvictedForTradingBenefits
noOneConvictedForTradingBenefits: noOneConvictedForTradingBenefits
someoneIsReceivingBenefitsWithFakeID: someoneIsReceivingBenefitsWithFakeID
noOneIsReceivingBenefitsWithFakeID: noOneIsReceivingBenefitsWithFakeID

# Vraj - Usable to here

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<th:block
th:fragment="radioFieldsetUnescaped"
th:with="
hasHelpText=${!#strings.isEmpty(fieldsetHelpText)},
hasLabel=${!#strings.isEmpty(label)},
hasAriaLabel=${!#strings.isEmpty(ariaLabel)},
hasError=${
errorMessages != null &&
errorMessages.get(inputName) != null &&
(#arrays.length(errorMessages.get(inputName)) > 0) }"
th:assert="
${!#strings.isEmpty(inputName)},
${hasLabel || hasAriaLabel},
${content != null}">
<div th:class="'form-group' + ${(hasError ? ' form-group--error' : '')}">
<fieldset th:attr="
aria-describedby=${hasHelpText ? inputName + '-help-text' : ''},
aria-labelledby=${hasAriaLabel ? ariaLabel : ''}">
<legend class="form-question"
th:id="${inputName + '-legend'}"
th:inline="text">
[(${label})]
<p class="text--help spacing-below-0 text--normal"
th:if="${hasHelpText}"
th:id="${inputName + '-help-text'}"
th:text="${fieldsetHelpText}"></p>
</legend>
<input type="hidden" th:id="${inputName} + 'Hidden'" th:name="${inputName}" value="">
<th:block th:replace="${content}"/>
</fieldset>
<th:block
th:replace="~{fragments/inputError :: validationError(inputName=${inputName})}"></th:block>
</div>
</th:block>
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@
<th:block th:ref="sensitiveQuestionsContent">
<div class="form-card__content"
th:each="question : ${T(org.mdbenefits.app.utils.SubmissionUtilities).SENSITIVE_CONVICTION_QUESTIONS}">
<div th:with="inputName='noOne' + ${question}, label='sensitive-conviction-question-' + ${question}">
<th:block th:replace="~{fragments/inputs/checkboxFieldsetUnescaped ::
checkboxFieldsetUnescaped(inputName=${inputName},
label=#{${label}},
content=~{::checkboxInSetContent})}">
<th:block th:ref="checkboxInSetContent">
<div th:with="inputName='someone' + ${question}, label='sensitive-conviction-question-' + ${question}">
<th:block th:replace="~{fragments/inputs/radioFieldsetUnescaped ::
radioFieldsetUnescaped(inputName=${inputName},
label=#{${label}},
content=~{::trueFalseOptions})}">
<th:block th:ref="trueFalseOptions">
<th:block
th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName=${inputName}, value='true', label=#{sensitive-conviction-question-true})}"/>
th:replace="~{fragments/inputs/radio :: radio(inputName=${inputName},value='false', label=#{sensitive-conviction-question-no})}"/>
<th:block
th:replace="~{fragments/inputs/radio :: radio(inputName=${inputName},value='true', label=#{sensitive-conviction-question-yes})}"/>
</th:block>
</th:block>

</div>
</div>
<div class="form-card__footer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,17 @@ void docUploadSkipTest() {
@Test
void sensitiveConvictionQuestionsArePreCheckedTest() {
testPage.navigateToFlowScreen("mdBenefitsFlow/sensitiveConvictionQuestions");
List<WebElement> selectedElements = driver.findElements(By.cssSelector("input[type='checkbox']"));
selectedElements.forEach(element -> {
assertThat(element.getAttribute("checked")).isEqualTo("true");
});
List<WebElement> selectedElements = driver.findElements(By.cssSelector("input[type='radio']"));
selectedElements.stream()
.filter(element -> element.getAttribute("value").equals("false"))
.forEach(element -> {
assertThat(element.getAttribute("checked")).isEqualTo("true");
});
selectedElements.stream()
.filter(element -> element.getAttribute("value").equals("true"))
.forEach(element -> {
assertThat(element.getAttribute("checked")).isNull();
});
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/mdbenefits/app/pdf/PdfServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ void generate() throws IOException {
.with("homeAddressZipCode", "94103")
.with("phoneNumber", "(510) 555-1212")
.with("signature", "John Hancock")
.with("noOneIsReceivingBenefitsWithFakeID[]", List.of("true"))
.with("noOneHasDrugKingpinFelony[]", List.of())
.with("someoneInHHIsPregnant", "true")
.with("someoneHasDrugKingpinFelony", "false")
.build();
submission.setFlow("mdBenefitsFlow");

Expand Down

0 comments on commit 716444e

Please sign in to comment.