Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

action tests #441

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,189 +56,6 @@ void personalInformationFlow() {

}

@Test
void birthDateFlow() {
testPage.navigateToFlowScreen("laDigitalAssister/personalInfo");
testPage.enter("firstName", "test");
testPage.enter("lastName", "test2");
testPage.selectRadio("sex", "F");
testPage.clickContinue();

assert(testPage.hasErrorText(message("error.format-dob")));

testPage.enter("birthMonth", "12");
testPage.enter("birthDay", "09");
testPage.enter("birthYear", "85");
testPage.clickContinue();

assert(testPage.hasErrorText(message("error.format-dob")));

testPage.enter("birthMonth", "12");
testPage.enter("birthDay", "25");
testPage.enter("birthYear", "1885");
testPage.clickContinue();

assert(testPage.hasErrorText(message("error.invalid-dob")));

testPage.enter("birthMonth", "12");
testPage.enter("birthDay", "25");
testPage.enter("birthYear", "2025");

testPage.clickContinue();
assert(testPage.hasErrorText(message("error.invalid-dob")));

testPage.enter("birthMonth", "2");
testPage.enter("birthDay", "9");
testPage.enter("birthYear", "1985");

testPage.clickContinue();
assertThat(testPage.getTitle()).isEqualTo(message("home-address.title"));
}

@Test
void noHomeAddressFlow(){
testPage.navigateToFlowScreen("laDigitalAssister/homeAddress");
testPage.clickContinue();

assert(testPage.hasErrorText(message("error.missing-address")));

testPage.clickElementById("noHomeAddress-true");
testPage.clickContinue();

assertThat(testPage.getTitle()).isEqualTo(message("where-to-send-mail.title"));

testPage.clickButton("Add a mailing address");

testPage.clickContinue();

assert(testPage.hasErrorText(message("error.missing-general")));
assert(testPage.hasErrorText(message("error.format-zip")));

testPage.enter("mailingAddressStreetAddress1", "test");
testPage.enter("mailingAddressCity", "test2");
testPage.enter("mailingAddressZipCode", "12");
testPage.selectFromDropdown("mailingAddressState", "CO - Colorado");

testPage.clickContinue();

assert(testPage.hasErrorText(message("error.format-zip")));

testPage.enter("mailingAddressZipCode", "12526");
testPage.clickContinue();

assertThat(testPage.getTitle()).isEqualTo(message("contact-info.title"));
}

@Test
void homeAddressFlow(){
testPage.navigateToFlowScreen("laDigitalAssister/homeAddress");
testPage.clickContinue();

assert(testPage.hasErrorText(message("error.missing-address")));

testPage.enter("homeAddressStreetAddress1", "123 Main St");
testPage.clickContinue();

assert(testPage.hasErrorText(message("error.missing-general")));
assert(testPage.hasErrorText(message("error.format-zip")));

testPage.enter("homeAddressCity", "test2");
testPage.selectFromDropdown("homeAddressState", "CO - Colorado");
testPage.enter("homeAddressZipCode", "12526");

testPage.clickContinue();

assertThat(testPage.getTitle()).isEqualTo(message("mailing-address.title"));

testPage.clickElementById("sameAsHomeAddress-true");
testPage.clickContinue();

assertThat(testPage.getTitle()).isEqualTo(message("contact-info.title"));
testPage.goBack();

assertThat(testPage.getTitle()).isEqualTo(message("mailing-address.title"));
testPage.clickElementById("sameAsHomeAddress-true");

testPage.enter("mailingAddressStreetAddress1", "test");
testPage.selectFromDropdown("mailingAddressState", "CO - Colorado");
testPage.enter("mailingAddressCity", "");
testPage.enter("mailingAddressZipCode", "1245");

testPage.clickContinue();

assert(testPage.hasErrorText(message("error.missing-general")));
assert(testPage.hasErrorText(message("error.format-zip")));

testPage.enter("mailingAddressCity", "Test 5");
testPage.enter("mailingAddressZipCode", "12526");
testPage.clickContinue();

assertThat(testPage.getTitle()).isEqualTo(message("contact-info.title"));
}

@Test
void contactInformationFlow(){
testPage.navigateToFlowScreen("laDigitalAssister/contactInfo");
testPage.clickContinue();

assertThat(testPage.getTitle()).isEqualTo(message("phone-number-nudge.title"));
testPage.goBack();

testPage.enter("emailAddress", "test");
testPage.enter("phoneNumber", "123-456-789");

testPage.clickContinue();

assert(testPage.hasErrorText(message("error.invalid-email")));
assert(testPage.hasErrorText(message("error.invalid-phone")));

testPage.enter("emailAddress", "");
testPage.enter("phoneNumber", "");

testPage.clickElementById("remindersMethod-By Text-label");

testPage.clickContinue();
assert(testPage.hasErrorText(message("error.invalid-phone")));

testPage.enter("phoneNumber", "123-456-7891");
testPage.clickContinue();

assertThat(testPage.getTitle()).isEqualTo(message("review-contact-info.title"));
testPage.goBack();

testPage.enter("phoneNumber", "123-456-789");
testPage.clickContinue();

assert(testPage.hasErrorText(message("error.invalid-phone")));
testPage.clickElementById("remindersMethod-By Text-label");
testPage.clickElementById("remindersMethod-By Email-label");
testPage.enter("emailAddress", "test@mail.com");
testPage.enter("phoneNumber", "");


testPage.clickContinue();

assertThat(testPage.getTitle()).isEqualTo(message("phone-number-nudge.title"));
testPage.goBack();

testPage.enter("phoneNumber", "123-456-7891");
testPage.clickContinue();

assertThat(testPage.getTitle()).isEqualTo(message("review-contact-info.title"));

testPage.goBack();

testPage.enter("emailAddress", "test");
testPage.clickContinue();

assert(testPage.hasErrorText(message("error.invalid-email")));

testPage.enter("emailAddress", "test@mail.com");
testPage.clickContinue();

assertThat(testPage.getTitle()).isEqualTo(message("review-contact-info.title"));
}

@Test
void hourlyIncomeFlow(){
loadUserPersonalData();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package org.ladocuploader.app.submission.actions;

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

import formflow.library.data.FormSubmission;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

@SpringBootTest()
@ActiveProfiles("test")
class ValidateBirthdateTest {
private final String BLANK_VALUE="";
private final String BIRTHDATE_INPUT_NAME = "birthDay";

@Autowired
private ValidateBirthdate validator;

@Test
public void testBirthDateBlankRaisesAnError() {
FormSubmission form = new FormSubmission(Map.of(
"birthMonth", BLANK_VALUE,
"birthDay", BLANK_VALUE,
"birthYear",BLANK_VALUE
));

Map<String, List<String>> result = validator.runValidation(form, null);
assertThat(result.get(BIRTHDATE_INPUT_NAME)).containsAll(List.of("Make sure to provide a date in MM/DD/YYYY OR M/D/YYYY."));
}

@Test
public void testBirthDayWrongFormatDoesNotRaiseAnError() {
FormSubmission form = new FormSubmission(Map.of(
"birthMonth", "01",
"birthDay", "1",
"birthYear","1991"
));

Map<String, List<String>> result = validator.runValidation(form, null);
assertThat(result.get(BIRTHDATE_INPUT_NAME)).isNullOrEmpty();
}

@Test
public void testBirthMonthWrongFormatDoesNotRaiseAnError() {
FormSubmission form = new FormSubmission(Map.of(
"birthMonth", "1",
"birthDay", "01",
"birthYear","1991"
));

Map<String, List<String>> result = validator.runValidation(form, null);
assertThat(result.get(BIRTHDATE_INPUT_NAME)).isNullOrEmpty();
}


@Test
public void testBirthYearWrongFormatDoesRaiseAnError() {
FormSubmission form = new FormSubmission(Map.of(
"birthMonth", "01",
"birthDay", "01",
"birthYear","91"
));

Map<String, List<String>> result = validator.runValidation(form, null);
assertThat(result.get(BIRTHDATE_INPUT_NAME)).containsAll(List.of("Make sure to provide a date in MM/DD/YYYY OR M/D/YYYY."));
}

@Test
public void testBirthYearBefore1900sDoesRaiseAnError() {
FormSubmission form = new FormSubmission(Map.of(
"birthMonth", "01",
"birthDay", "01",
"birthYear","1885"
));

Map<String, List<String>> result = validator.runValidation(form, null);
assertThat(result.get(BIRTHDATE_INPUT_NAME)).containsAll(List.of("Make sure to provide a valid date."));
}

@Test
public void testBirthDateInFutureDoesRaiseAnError() {
FormSubmission form = new FormSubmission(Map.of(
"birthMonth", "01",
"birthDay", "01",
"birthYear","2027"
));

Map<String, List<String>> result = validator.runValidation(form, null);
assertThat(result.get(BIRTHDATE_INPUT_NAME)).containsAll(List.of("Make sure to provide a valid date."));
}

@Test
public void testBirthdayHappyPath() {
FormSubmission form = new FormSubmission(Map.of(
"birthMonth", "1",
"birthDay", "1",
"birthYear","1991"
));

Map<String, List<String>> result = validator.runValidation(form, null);
assertThat(result.get(BIRTHDATE_INPUT_NAME)).isNullOrEmpty();
}

}
Loading