Skip to content

Commit

Permalink
CCAP-28-bug-fix (#243)
Browse files Browse the repository at this point in the history
Co-authored-by: Cypress Borg <cborg@codeforamerica.org>
  • Loading branch information
enyia21 and coltborg committed May 9, 2024
1 parent fd644e3 commit b82bc5d
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 9 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Expand Up @@ -56,7 +56,7 @@ dependencies {
implementation 'ch.qos.logback.contrib:logback-json-classic:0.1.5'
implementation 'ch.qos.logback.contrib:logback-jackson:0.1.5'

if (profile == 'dev' || useLocalLibrary == 'true') {
if (useLocalLibrary == 'true') {
implementation fileTree(dir: "$rootDir/../form-flow/build/libs", include: '*.jar')
println "📦 Using local library"
} else {
Expand Down Expand Up @@ -228,10 +228,10 @@ enum DesignSystem {
static DesignSystem fromString(String value) {
for (DesignSystem designSystem : values()) {
if (designSystem.name().replaceAll('_', '-').equalsIgnoreCase(value)) {
return designSystem;
return designSystem
}
}
throw new IllegalArgumentException("Unknown design system: " + value);
throw new IllegalArgumentException("Unknown design system: " + value)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/messages.properties
Expand Up @@ -220,7 +220,7 @@ parent-no-permanent-address.subtext=This could be a friend or family member's ad
parent-no-permanent-address.has-place-to-get-mail=I have a place to get mail
parent-no-permanent-address.contact-by-email=Contact me by email instead.
#parent-confirm-address
parent-confirm-address.title=Parent
parent-confirm-address.title=Parent Confirm Address
parent-confirm-address.header=Confirm your address
parent-confirm-address.note-addr-not-found=We couldn't find your address. To make sure you get mail from us, you may edit your address or keep going.
parent-confirm-address.note-suggested-addr=We updated the address you entered. If correct, please use the suggested address.
Expand Down
16 changes: 15 additions & 1 deletion src/main/resources/templates/gcc/parent-comm-preference.html
Expand Up @@ -23,4 +23,18 @@
</th:block>
</th:block>
</th:block>
</th:block>
</th:block>
<script defer>
let url = new URL(document.URL)
let contactByEmail = url.searchParams.get("unhousedPrefersEmail")

let mailIsNotPreferredCommunicationMethod = document.getElementById("parentContactPreferredCommunicationMethod-mail").checked===false;
//checks that unhousedPrefersEmail is in the query params and is set to true, also checks that mail is not a field that is passed by submission

if((contactByEmail!==null) && mailIsNotPreferredCommunicationMethod){
let email = document.getElementById('parentContactPreferredCommunicationMethod-email');
if(contactByEmail){
email.checked=true;
}
}
</script>
Expand Up @@ -17,7 +17,7 @@
class="button button--primary spacing-below-35" id="place-to-get-mail-link"></a>
</div>
<div>
<a th:href="'/flow/' + ${flow} + '/parent-contact'"
<a th:href="'/flow/' + ${flow} + '/parent-comm-preference?unhousedPrefersEmail=true'"
th:text="#{parent-no-permanent-address.contact-by-email}"
id="contact-by-email"></a>
</div>
Expand Down
91 changes: 91 additions & 0 deletions src/test/java/org/ilgcc/app/journeys/OptInJourneyTest.java
@@ -0,0 +1,91 @@
package org.ilgcc.app.journeys;

import static org.assertj.core.api.Assertions.assertThat;

import org.ilgcc.app.utils.AbstractBasePageTest;
import org.junit.jupiter.api.Test;

public class OptInJourneyTest extends AbstractBasePageTest {

@Test
void shouldPreselectEmailWhenParentExperiencingHomelessnessClicksContactByEmailWithoutExistingSelectedPreference() {
// Activities Screen
testPage.navigateToFlowScreen("gcc/parent-home-address");
saveSubmission(getSessionSubmissionTestBuilder().withDayCareProvider()
.withHomelessDetails()
.build());

//parent-home-address
assertThat(testPage.getTitle()).isEqualTo("What is your home address?");
testPage.clickElementById("parentHomeExperiencingHomelessness-yes");
testPage.clickContinue();
//parent-no-permanent-address
assertThat(testPage.getTitle()).isEqualTo("Parent");
testPage.clickLink("Contact me by email instead.");
//parent-comm-preference
assertThat(testPage.getTitle()).isEqualTo("Parent Communications Preference");
assertThat(testPage.findElementById("parentContactPreferredCommunicationMethod-email").getAttribute("checked")).isEqualTo("true");
testPage.selectRadio("parentContactPreferredCommunicationMethod", "mail");
}
@Test
void shouldSetPreferredCommunicationToUserInputAfterUserSelectsAPreferredCommunicationMethod(){
testPage.navigateToFlowScreen("gcc/parent-home-address");
saveSubmission(getSessionSubmissionTestBuilder().withDayCareProvider()
.withHomelessDetails()
.build());

//parent-home-address
assertThat(testPage.getTitle()).isEqualTo("What is your home address?");
testPage.clickElementById("parentHomeExperiencingHomelessness-yes");
testPage.clickContinue();
//parent-no-permanent-address
assertThat(testPage.getTitle()).isEqualTo("Parent");
testPage.clickLink("Contact me by email instead.");
//parent-comm-preference
assertThat(testPage.getTitle()).isEqualTo("Parent Communications Preference");
assertThat(testPage.findElementById("parentContactPreferredCommunicationMethod-email").getAttribute("checked")).isEqualTo("true");
testPage.clickElementById("parentContactPreferredCommunicationMethod-mail");
testPage.clickContinue();
//parent-contact-info
assertThat(testPage.getTitle()).isEqualTo("Parent Contact Info");
testPage.goBack();
assertThat(testPage.getTitle()).isEqualTo("Parent Communications Preference");
assertThat(testPage.findElementById("parentContactPreferredCommunicationMethod-mail").getAttribute("checked")).isEqualTo("true");
testPage.goBack();
//parent-no-permanent-address
assertThat(testPage.getTitle()).isEqualTo("Parent");
testPage.clickLink("Contact me by email instead.");
assertThat(testPage.findElementById("parentContactPreferredCommunicationMethod-mail").getAttribute("checked")).isEqualTo("true");



}
@Test
void shouldSelectNothingIfAParentExperiencingHomelessnessDoesNotSelectContactByEmail(){
testPage.navigateToFlowScreen("gcc/parent-home-address");
saveSubmission(getSessionSubmissionTestBuilder().withDayCareProvider()
.withHomelessDetails()
.build());
//parent-home-address
assertThat(testPage.getTitle()).isEqualTo("What is your home address?");
testPage.clickElementById("parentHomeExperiencingHomelessness-yes");
testPage.clickContinue();
//parent-no-permanent-address
assertThat(testPage.getTitle()).isEqualTo("Parent");
testPage.clickLink("I have a place to get mail");
//parent-mailing-address
assertThat(testPage.getTitle()).isEqualTo("Parent Mailing Address");
testPage.enter("parentMailingStreetAddress1", "972 Mission St");
testPage.enter("parentMailingStreetAddress2", "5th floor");
testPage.enter("parentMailingCity", "San Francisco");
testPage.selectFromDropdown("parentMailingState", "CA - California");
testPage.enter("parentMailingZipCode", "94103");
testPage.clickContinue();
//parent-confirm-address
assertThat(testPage.getTitle()).isEqualTo("Parent Confirm Address");
testPage.clickButton("Use this address");
//parent-comm-preference
assertThat(testPage.getTitle()).isEqualTo("Parent Communications Preference");
assertThat(testPage.findElementById("parentContactPreferredCommunicationMethod-mail").getAttribute("checked")).isEqualTo(null);
}
}
11 changes: 8 additions & 3 deletions src/test/java/org/ilgcc/app/utils/SubmissionTestBuilder.java
@@ -1,8 +1,6 @@
package org.ilgcc.app.utils;

import formflow.library.data.Submission;
import jakarta.validation.constraints.NotBlank;
import jakarta.websocket.OnClose;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -49,7 +47,14 @@ public SubmissionTestBuilder withParentDetails() {
submission.getInputData().put("parentHasPartner", "false");
return this;
}

public SubmissionTestBuilder withHomelessDetails(){
submission.getInputData().put("parentFirstName", "HP_first");
submission.getInputData().put("parentLastName", "HP_last");
submission.getInputData().put("parentBirthMonth", "10");
submission.getInputData().put("parentBirthDay", "20");
submission.getInputData().put("parentBirthYear", "1922");
return this;
}
public SubmissionTestBuilder withParentPartnerDetails() {
submission.getInputData().put("parentSpouseIsStepParent", "Yes");
submission.getInputData().put("parentSpouseShareChildren", "Yes");
Expand Down

0 comments on commit b82bc5d

Please sign in to comment.