Skip to content

Commit

Permalink
Required fields changes (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
spokenbird authored Aug 20, 2024
1 parent e735891 commit d6d3793
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
th:with="
interiorElementHelp=${!#strings.isEmpty(interiorElementHelpText)},
exteriorElementHelp=${!#strings.isEmpty(exteriorElementHelpText)},
isRequiredInput=${requiredInputs.getOrDefault(inputName, false) || required != null && required},
hasIcon=${!#strings.isEmpty(checkboxIcon)},
name=${inputName} + '[]',
hasError=${
Expand Down Expand Up @@ -32,6 +33,7 @@
</div>
<div>
<span th:text="${label}"></span>
<span th:if="${isRequiredInput}" class="required-input" th:text="#{general.required-field}"></span>
<p th:if="${interiorElementHelp}"
th:id="${name} + '-' + ${value} + '-help-text'"
th:text="${interiorElementHelpText}"
Expand All @@ -42,7 +44,7 @@
<p th:if="${exteriorElementHelp}"
th:id="${name} + '-' + ${value} + '-help-text'"
th:text="${exteriorElementHelpText}"
class="text--help with-no-padding"></p>
class="text--help"></p>
<th:block
th:replace="~{fragments/inputError :: validationError(inputName=${inputName})}"></th:block>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/templates/ubi/economicHardship.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
header=#{economic-hardship.header},
subtext=#{economic-hardship.subheader},
formAction=${formAction},
inputName='economicHardshipTypes',
inputContent=~{::inputContent})}">
<th:block th:ref="inputContent">
<th:block th:replace="~{fragments/inputs/checkboxFieldset ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
screenWithOneInput(
title=#{household-member-income.title},
header=#{household-member-income.header},
inputName='householdMember',
formAction=${formAction},
inputContent=~{::inputContent})}">

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/templates/ubi/incomeTypes.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
title=#{income-types.title},
header=${selectedSelf ? #messages.msg('income-types.headerYou') : #messages.msg('income-types.headerPerson', houseHoldMemberName)},
subtext=#{income-types.sub-header},
inputName='incomeTypes',
formAction=${formAction},
inputName='incomeTypes',
inputContent=~{::inputContent})}">
<th:block th:ref="inputContent">
<th:block th:replace="~{fragments/inputs/checkboxFieldset ::
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/templates/ubi/legalStuff.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ <h4 th:text="#{legal-stuff.consent}"></h4>
<div class="align-with-boxed-content">
<th:block th:replace="~{fragments/inputs/checkboxMod ::
checkboxMod(inputName='agreesToLegalTerms',
required=true,
label=#{legal-stuff.i-agree},
exteriorElementHelpText=#{legal-stuff.copies-of-the-full-agreements-and-policies},
value='true')}">
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/templates/ubi/personalInfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<div class="question-with-follow-up__follow-up" id="moved-to-usa-follow-up">
<th:block th:replace="~{fragments/inputs/date ::
date(inputName='movedToUSA',
required=true,
label=#{personal-info.moved-when-label},
groupName='movedToUSADate')}"/>
<th:block th:replace="~{fragments/inputs/text ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
th:replace="~{fragments/screens/screenWithOneInput ::
screenWithOneInput(
title=#{household-reported-annual-pre-tax-income.title},
inputName='reportedTotalAnnualHouseholdIncome',
header=#{household-reported-annual-pre-tax-income.header},
formAction=${formAction},
inputName='reportedTotalAnnualHouseholdIncome',
buttonLabel=#{general.inputs.continue},
inputContent=~{::inputContent})}">
<th:block th:ref="inputContent">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
import org.formflowstartertemplate.app.submission.actions.SendEmailConfirmation;
import org.formflowstartertemplate.app.utils.AbstractBasePageTest;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.springframework.boot.test.mock.mockito.SpyBean;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Comparator;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -43,6 +41,9 @@ void fullUbiFlow() throws IOException, InterruptedException {
testPage.clickContinue();

// Personal info
assertThat(driver.findElement(By.cssSelector("label[for='firstName']")).getText()).contains("(required)");
assertThat(driver.findElement(By.cssSelector("label[for='lastName']")).getText()).contains("(required)");
assertThat(driver.findElement(By.cssSelector("legend[for='birth']")).getText()).contains("(required)");
testPage.enter("firstName", "Testy");
testPage.enter("lastName", "McTesterson");
// Test if follow up questions are disabled on page load
Expand Down Expand Up @@ -94,6 +95,7 @@ void fullUbiFlow() throws IOException, InterruptedException {
// movedToUSA - check invalid date when movedToUSA=Yes
assertThat(testPage.getTitle()).isEqualTo("Personal Info");
testPage.clickElementById("movedToUSA-Yes");
assertThat(driver.findElement(By.cssSelector("legend[for='movedToUSA']")).getText()).contains("(required)");
testPage.enter("movedToUSADay", "65");
testPage.enter("movedToUSAMonth", "3");
testPage.enter("movedToUSAYear", "1987");
Expand Down

0 comments on commit d6d3793

Please sign in to comment.