diff --git a/sites/public/cypress/e2e/pages/submit-application.spec.ts b/sites/public/cypress/e2e/pages/submit-application.spec.ts index 177b0696d8..b5ea92374c 100644 --- a/sites/public/cypress/e2e/pages/submit-application.spec.ts +++ b/sites/public/cypress/e2e/pages/submit-application.spec.ts @@ -1,7 +1,7 @@ -import { ElmVillageApplication, minimalDataApplication } from "../../mockData/applicationData" +import { ElmVillageApplication, autofillBlueSkyApplication } from "../../mockData/applicationData" describe("Submit", function () { - it("should submit an application for the Elm Village listing", function () { + it("should submit an application for the Elm Village listing, then autofill and submit an application for Blue Sky Apartments", function () { cy.intercept("GET", "/geocoding/v5/**", { fixture: "address" }) // Interceptor for the address in the preference cy.intercept( @@ -17,10 +17,7 @@ describe("Submit", function () { } ) - cy.submitApplication("Elm Village", ElmVillageApplication, false, true) - }) - it("should submit a minimal application for the Test: Default, No Preferences", function () { - cy.intercept("GET", "/geocoding/v5/**", { fixture: "address" }) - cy.submitApplication("Blue Sky Apartments", minimalDataApplication, false, false) + cy.submitApplication("Elm Village", ElmVillageApplication, false, true, false) + cy.submitApplication("Blue Sky Apartments", autofillBlueSkyApplication, true, true, true) }) }) diff --git a/sites/public/cypress/mockData/applicationData.ts b/sites/public/cypress/mockData/applicationData.ts index e9100f7ca9..c4fd2952e2 100644 --- a/sites/public/cypress/mockData/applicationData.ts +++ b/sites/public/cypress/mockData/applicationData.ts @@ -102,7 +102,7 @@ export const ElmVillageApplication: Application = { firstName: "First Name", middleName: "Middle Name", lastName: "Last Name", - birthMonth: "07", + birthMonth: "7", birthDay: "17", birthYear: "1996", emailAddress: "test@bloom.com", @@ -166,7 +166,7 @@ export const ElmVillageApplication: Application = { firstName: "Member Name", middleName: "Member Middle Name", lastName: "Member Last Name", - birthMonth: "07", + birthMonth: "7", birthDay: "17", birthYear: "1996", householdMemberAddress: { @@ -191,42 +191,12 @@ export const ElmVillageApplication: Application = { }, ], preferredUnitTypes: [ - { - ...idDefaults, - id: "dff3ff70-7085-4dab-afd9-de4b33e0ec1e", - name: "SRO" as UnitTypeEnum, - numBedrooms: 0, - }, - { - ...idDefaults, - id: "dff3ff70-7085-4dab-afd9-de4b33e0ec1e", - name: "Studio" as UnitTypeEnum, - numBedrooms: 0, - }, { ...idDefaults, id: "dff3ff70-7085-4dab-afd9-de4b33e0ec1e", name: "1 Bedroom" as UnitTypeEnum, numBedrooms: 1, }, - { - ...idDefaults, - id: "dff3ff70-7085-4dab-afd9-de4b33e0ec1e", - name: "2 Bedroom" as UnitTypeEnum, - numBedrooms: 2, - }, - { - ...idDefaults, - id: "dff3ff70-7085-4dab-afd9-de4b33e0ec1e", - name: "3 Bedroom" as UnitTypeEnum, - numBedrooms: 3, - }, - { - ...idDefaults, - id: "dff3ff70-7085-4dab-afd9-de4b33e0ec1e", - name: "4 Bedroom" as UnitTypeEnum, - numBedrooms: 3, - }, ], demographics: { ...idDefaults, @@ -307,207 +277,10 @@ export const ElmVillageApplication: Application = { language: LanguagesEnum.en, } -export const minimalDataApplication: Application = { - markedAsDuplicate: false, - ...idDefaults, - listings: { - id: "abcd1234", - }, - applicant: { - ...idDefaults, - phoneNumber: null, - noPhone: true, - phoneNumberType: null, - workInRegion: YesNoEnum.no, - applicantAddress: { - ...idDefaults, - street: "600 Montgomery St", - street2: "Unit", - city: "San Francisco", - state: "CA", - zipCode: "94111", - county: "", - }, - applicantWorkAddress: { - ...idDefaults, - street: "", - street2: "", - city: "", - state: "", - zipCode: "", - }, - firstName: "First Name", - middleName: null, - lastName: "Last Name", - birthMonth: "07", - birthDay: "17", - birthYear: "1996", - emailAddress: null, - noEmail: true, - }, - additionalPhone: false, - additionalPhoneNumber: "", - additionalPhoneNumberType: "", - contactPreferences: ["letter"], - householdSize: 1, - housingStatus: "", - sendMailToMailingAddress: false, - householdExpectingChanges: false, - householdStudent: false, - applicationsMailingAddress: { - ...idDefaults, - street: "", - street2: "", - city: "", - state: "", - zipCode: "", - }, - applicationsAlternateAddress: { - ...idDefaults, - street: "", - street2: "", - city: "", - state: "", - zipCode: "", - }, - alternateContact: { - ...idDefaults, - type: AlternateContactRelationship.noContact, - firstName: "", - lastName: "", - agency: "", - phoneNumber: "", - otherType: "", - emailAddress: "", - address: { - ...idDefaults, - street: "", - street2: "", - city: "", - state: "", - zipCode: "", - }, - }, - accessibility: { - ...idDefaults, - mobility: false, - vision: false, - hearing: false, - }, - incomeVouchers: false, - income: "50000", - incomePeriod: IncomePeriodEnum.perYear, - householdMember: [], - preferredUnitTypes: [ - { - ...idDefaults, - id: "dff3ff70-7085-4dab-afd9-de4b33e0ec1e", - name: "1 Bedroom" as UnitTypeEnum, - numBedrooms: 1, - }, - ], - demographics: { - ...idDefaults, - howDidYouHear: [], - race: [], - }, +export const autofillBlueSkyApplication: Application = { + ...ElmVillageApplication, preferences: [], - programs: [ - { - claimed: false, - key: "servedInMilitary", - options: [ - { - key: "servedInMilitary", - checked: false, - }, - { - key: "doNotConsider", - checked: false, - }, - { - key: "preferNotToSay", - checked: false, - }, - ], - }, - { - key: "tay", - claimed: false, - options: [ - { - key: "tay", - checked: false, - }, - { - key: "doNotConsider", - checked: false, - }, - { - key: "preferNotToSay", - checked: false, - }, - ], - }, - { - key: "disabilityOrMentalIllness", - claimed: false, - options: [ - { - key: "disabilityOrMentalIllness", - checked: false, - }, - { - key: "doNotConsider", - checked: false, - }, - { - key: "preferNotToSay", - checked: false, - }, - ], - }, - { - key: "housingSituation", - claimed: false, - options: [ - { - key: "notPermanent", - checked: false, - }, - { - key: "homeless", - checked: false, - }, - { - key: "doNotConsider", - checked: false, - }, - { - key: "preferNotToSay", - checked: false, - }, - ], - }, - { - key: "rentBasedOnIncome", - claimed: true, - options: [ - { - key: "flatRent", - checked: true, - }, - { - key: "30Percent", - checked: true, - }, - ], - }, - ] as ApplicationMultiselectQuestion[], - confirmationCode: "", - status: ApplicationStatusEnum.draft, - submissionType: ApplicationSubmissionTypeEnum.electronical, - language: LanguagesEnum.en, + programs: [] as ApplicationMultiselectQuestion[], } export const applicationStepOrder = [ diff --git a/sites/public/cypress/support/commands.js b/sites/public/cypress/support/commands.js index 4fe841acd9..68a720bd58 100644 --- a/sites/public/cypress/support/commands.js +++ b/sites/public/cypress/support/commands.js @@ -66,82 +66,93 @@ Cypress.Commands.add("beginApplicationRejectAutofill", (listingName) => { cy.getByID("app-next-step-button").click() }) -Cypress.Commands.add("beginApplicationSignedIn", (listingName) => { +Cypress.Commands.add("beginApplicationSignedIn", (listingName, autofill) => { cy.visit("/listings") cy.get(".is-card-link").contains(listingName).click() cy.getByID("listing-view-apply-button").eq(1).click() cy.getByID("app-choose-language-button").eq(0).click() cy.getByID("app-next-step-button").click() - cy.getByID("autofill-decline").click() + if (autofill) { + cy.getByID("autofill-accept").click() + } else { + cy.getByID("autofill-decline").click() + } }) -Cypress.Commands.add("step1PrimaryApplicantName", (application) => { - cy.getByTestId("app-primary-first-name").type(application.applicant.firstName) - if (application.applicant.middleName) { - cy.getByTestId("app-primary-middle-name").type(application.applicant.middleName) - } - cy.getByTestId("app-primary-last-name").type(application.applicant.lastName) - cy.getByTestId("dob-field-month").type(application.applicant.birthMonth) - cy.getByTestId("dob-field-day").type(application.applicant.birthDay) - cy.getByTestId("dob-field-year").type(application.applicant.birthYear) - if (application.applicant.noEmail) { - cy.getByTestId("app-primary-no-email").check() - } else { - cy.getByTestId("app-primary-email").type(application.applicant.emailAddress) +Cypress.Commands.add("step1PrimaryApplicantName", (application, autofill) => { + if (!autofill) { + cy.getByTestId("app-primary-first-name").type(application.applicant.firstName) + if (application.applicant.middleName) { + cy.getByTestId("app-primary-middle-name").type(application.applicant.middleName) + } + cy.getByTestId("app-primary-last-name").type(application.applicant.lastName) + cy.getByTestId("dob-field-month").type(application.applicant.birthMonth) + cy.getByTestId("dob-field-day").type(application.applicant.birthDay) + cy.getByTestId("dob-field-year").type(application.applicant.birthYear) + if (application.applicant.noEmail) { + cy.getByTestId("app-primary-no-email").check() + } else { + cy.getByTestId("app-primary-email").type(application.applicant.emailAddress) + } } + cy.goNext() cy.checkErrorAlert("not.exist") cy.checkErrorMessages("not.exist") cy.isNextRouteValid("primaryApplicantName") }) -Cypress.Commands.add("step2PrimaryApplicantAddresses", (application) => { - if (application.applicant.noPhone) { - cy.getByTestId("app-primary-no-phone").check() - } else { - cy.getPhoneFieldByTestId("app-primary-phone-number").type(application.applicant.phoneNumber) - cy.getByTestId("app-primary-phone-number-type").select(application.applicant.phoneNumberType) - } - - if (application.additionalPhoneNumber) { - cy.getByTestId("app-primary-additional-phone").check() - cy.getPhoneFieldByTestId("app-primary-additional-phone-number").type( - application.additionalPhoneNumber - ) - cy.getByTestId("app-primary-additional-phone-number-type").select( - application.additionalPhoneNumberType - ) - } +Cypress.Commands.add("step2PrimaryApplicantAddresses", (application, autofill) => { + if (!autofill) { + if (application.applicant.noPhone) { + cy.getByTestId("app-primary-no-phone").check() + } else { + cy.getPhoneFieldByTestId("app-primary-phone-number").type(application.applicant.phoneNumber) + cy.getByTestId("app-primary-phone-number-type").select(application.applicant.phoneNumberType) + } - cy.getByTestId("app-primary-address-street").type(application.applicant.applicantAddress.street) - cy.getByTestId("app-primary-address-street2").type(application.applicant.applicantAddress.street2) - cy.getByTestId("app-primary-address-city").type(application.applicant.applicantAddress.city) - cy.getByTestId("app-primary-address-state").select(application.applicant.applicantAddress.state) - cy.getByTestId("app-primary-address-zip").type(application.applicant.applicantAddress.zipCode) + if (application.additionalPhoneNumber) { + cy.getByTestId("app-primary-additional-phone").check() + cy.getPhoneFieldByTestId("app-primary-additional-phone-number").type( + application.additionalPhoneNumber + ) + cy.getByTestId("app-primary-additional-phone-number-type").select( + application.additionalPhoneNumberType + ) + } - if (application.sendMailToMailingAddress) { - cy.getByTestId("app-primary-send-to-mailing").check() - cy.getByTestId("app-primary-mailing-address-street").type( - application.applicationsMailingAddress.street - ) - cy.getByTestId("app-primary-mailing-address-street2").type( - application.applicationsMailingAddress.street2 - ) - cy.getByTestId("app-primary-mailing-address-city").type( - application.applicationsMailingAddress.city - ) - cy.getByTestId("app-primary-mailing-address-state").select( - application.applicationsMailingAddress.state + cy.getByTestId("app-primary-address-street").type(application.applicant.applicantAddress.street) + cy.getByTestId("app-primary-address-street2").type( + application.applicant.applicantAddress.street2 ) - cy.getByTestId("app-primary-mailing-address-zip").type( - application.applicationsMailingAddress.zipCode - ) - } + cy.getByTestId("app-primary-address-city").type(application.applicant.applicantAddress.city) + cy.getByTestId("app-primary-address-state").select(application.applicant.applicantAddress.state) + cy.getByTestId("app-primary-address-zip").type(application.applicant.applicantAddress.zipCode) + + if (application.sendMailToMailingAddress) { + cy.getByTestId("app-primary-send-to-mailing").check() + cy.getByTestId("app-primary-mailing-address-street").type( + application.applicationsMailingAddress.street + ) + cy.getByTestId("app-primary-mailing-address-street2").type( + application.applicationsMailingAddress.street2 + ) + cy.getByTestId("app-primary-mailing-address-city").type( + application.applicationsMailingAddress.city + ) + cy.getByTestId("app-primary-mailing-address-state").select( + application.applicationsMailingAddress.state + ) + cy.getByTestId("app-primary-mailing-address-zip").type( + application.applicationsMailingAddress.zipCode + ) + } - application.contactPreferences.forEach((contactPreference) => { - const contactPreferenceIndex = contactPreferencesCheckboxesOrder.indexOf(contactPreference) - cy.getByTestId("app-primary-contact-preference").eq(contactPreferenceIndex).check() - }) + application.contactPreferences.forEach((contactPreference) => { + const contactPreferenceIndex = contactPreferencesCheckboxesOrder.indexOf(contactPreference) + cy.getByTestId("app-primary-contact-preference").eq(contactPreferenceIndex).check() + }) + } if (application.applicant.workInRegion === "yes") { cy.getByTestId("app-primary-work-in-region-yes").check() @@ -173,14 +184,15 @@ Cypress.Commands.add("step2PrimaryApplicantAddresses", (application) => { cy.isNextRouteValid("primaryApplicantAddress") }) -Cypress.Commands.add("step3AlternateContactType", (application) => { - const alternateContactTypeIndex = alternateContactTypeRadioOrder.indexOf( - application.alternateContact.type - ) - cy.getByTestId("app-alternate-type").eq(alternateContactTypeIndex).check() - - if (application.alternateContact.type === "other") { - cy.get("[data-testid=app-alternate-other-type]").type(application.alternateContact.otherType) +Cypress.Commands.add("step3AlternateContactType", (application, autofill) => { + if (!autofill) { + const alternateContactTypeIndex = alternateContactTypeRadioOrder.indexOf( + application.alternateContact.type + ) + cy.getByTestId("app-alternate-type").eq(alternateContactTypeIndex).check() + if (application.alternateContact.type === "other") { + cy.get("[data-testid=app-alternate-other-type]").type(application.alternateContact.otherType) + } } cy.goNext() @@ -188,120 +200,143 @@ Cypress.Commands.add("step3AlternateContactType", (application) => { cy.checkErrorMessages("not.exist") }) -Cypress.Commands.add("step4AlternateContactName", (application) => { - cy.getByTestId("app-alternate-first-name").type(application.alternateContact.firstName) - cy.getByTestId("app-alternate-last-name").type(application.alternateContact.lastName) +Cypress.Commands.add("step4AlternateContactName", (application, autofill) => { + if (!autofill) { + cy.getByTestId("app-alternate-first-name").type(application.alternateContact.firstName) + cy.getByTestId("app-alternate-last-name").type(application.alternateContact.lastName) + } else { + cy.contains("Who is your alternate contact?") + } + cy.goNext() cy.checkErrorAlert("not.exist") cy.checkErrorMessages("not.exist") cy.isNextRouteValid("alternateContactName") }) -Cypress.Commands.add("step5AlternateContactInfo", (application) => { - cy.getPhoneFieldByTestId("app-alternate-phone-number").type( - application.alternateContact.phoneNumber - ) - cy.getByTestId("app-alternate-email").type(application.alternateContact.emailAddress) - cy.getByTestId("app-alternate-mailing-address-street").type( - application.alternateContact.address.street - ) - cy.getByTestId("app-alternate-mailing-address-street2").type( - application.alternateContact.address.street2 - ) - cy.getByTestId("app-alternate-mailing-address-city").type( - application.alternateContact.address.city - ) - cy.getByTestId("app-alternate-mailing-address-state").select( - application.alternateContact.address.state - ) - cy.getByTestId("app-alternate-mailing-address-zip").type( - application.alternateContact.address.zipCode - ) +Cypress.Commands.add("step5AlternateContactInfo", (application, autofill) => { + if (!autofill) { + cy.getPhoneFieldByTestId("app-alternate-phone-number").type( + application.alternateContact.phoneNumber + ) + cy.getByTestId("app-alternate-email").type(application.alternateContact.emailAddress) + cy.getByTestId("app-alternate-mailing-address-street").type( + application.alternateContact.address.street + ) + cy.getByTestId("app-alternate-mailing-address-street2").type( + application.alternateContact.address.street2 + ) + cy.getByTestId("app-alternate-mailing-address-city").type( + application.alternateContact.address.city + ) + cy.getByTestId("app-alternate-mailing-address-state").select( + application.alternateContact.address.state + ) + cy.getByTestId("app-alternate-mailing-address-zip").type( + application.alternateContact.address.zipCode + ) + } cy.goNext() cy.checkErrorAlert("not.exist") cy.checkErrorMessages("not.exist") - cy.isNextRouteValid("alternateContactInfo") -}) -Cypress.Commands.add("step6HouseholdSize", (application) => { - if (application.householdMember.length > 0) { - cy.getByID("householdSizeLiveWithOthers").click() - cy.goNext() - cy.checkErrorAlert("not.exist") - cy.checkErrorMessages("not.exist") - cy.location("pathname").should("include", "applications/household/members-info") + if (autofill & (application.householdMember.length > 0)) { + cy.isNextRouteValid("liveAlone") } else { - cy.getByID("householdSizeLiveAlone").click() - cy.goNext() - cy.checkErrorAlert("not.exist") - cy.checkErrorMessages("not.exist") - cy.location("pathname").should("include", "applications/household/preferred-units") + cy.isNextRouteValid("alternateContactInfo") + } +}) + +Cypress.Commands.add("step6HouseholdSize", (application, autofill) => { + if (!autofill) { + if (application.householdMember.length > 0) { + cy.getByID("householdSizeLiveWithOthers").click() + + cy.goNext() + cy.checkErrorAlert("not.exist") + cy.checkErrorMessages("not.exist") + + cy.location("pathname").should("include", "applications/household/members-info") + } else { + cy.getByID("householdSizeLiveAlone").click() + cy.goNext() + cy.checkErrorAlert("not.exist") + cy.checkErrorMessages("not.exist") + cy.location("pathname").should("include", "applications/household/preferred-units") + } } }) -Cypress.Commands.add("step7AddHouseholdMembers", (application) => { +Cypress.Commands.add("step7AddHouseholdMembers", (application, autofill) => { cy.goNext() cy.checkErrorAlert("not.exist") cy.checkErrorMessages("not.exist") + cy.location("pathname").should("include", "applications/household/add-members") application.householdMember.forEach((householdMember) => { - cy.getByID("app-add-household-member-button").click() + if (autofill) { + cy.getByID(`edit-member-${householdMember.firstName}-${householdMember.lastName}`).click() + } else { + cy.getByID("app-add-household-member-button").click() + } cy.checkErrorAlert("not.exist") cy.checkErrorMessages("not.exist") cy.location("pathname").should("include", "applications/household/member") - cy.getByTestId("app-household-member-first-name").type(householdMember.firstName) - cy.getByTestId("app-household-member-middle-name").type(householdMember.middleName) - cy.getByTestId("app-household-member-last-name").type(householdMember.lastName) - cy.getByTestId("dob-field-month").type(householdMember.birthMonth) - cy.getByTestId("dob-field-day").type(householdMember.birthDay) - cy.getByTestId("dob-field-year").type(householdMember.birthYear) - - if (householdMember.sameAddress === "no") { - cy.getByTestId("app-household-member-same-address").eq(1).check() - cy.getByTestId("app-household-member-address-street").type( - householdMember.householdMemberAddress.street - ) - cy.getByTestId("app-household-member-address-street2").type( - householdMember.householdMemberAddress.street2 - ) - cy.getByTestId("app-household-member-address-city").type( - householdMember.householdMemberAddress.city - ) - cy.getByTestId("app-household-member-address-state").select( - householdMember.householdMemberAddress.state - ) - cy.getByTestId("app-household-member-address-zip").type( - householdMember.householdMemberAddress.zipCode - ) - } else { - cy.getByTestId("app-household-member-same-address").eq(0).check() - } + if (!autofill) { + cy.getByTestId("app-household-member-first-name").type(householdMember.firstName) + cy.getByTestId("app-household-member-middle-name").type(householdMember.middleName) + cy.getByTestId("app-household-member-last-name").type(householdMember.lastName) + cy.getByTestId("dob-field-month").type(householdMember.birthMonth) + cy.getByTestId("dob-field-day").type(householdMember.birthDay) + cy.getByTestId("dob-field-year").type(householdMember.birthYear) + + if (householdMember.sameAddress === "no") { + cy.getByTestId("app-household-member-same-address").eq(1).check() + cy.getByTestId("app-household-member-address-street").type( + householdMember.householdMemberAddress.street + ) + cy.getByTestId("app-household-member-address-street2").type( + householdMember.householdMemberAddress.street2 + ) + cy.getByTestId("app-household-member-address-city").type( + householdMember.householdMemberAddress.city + ) + cy.getByTestId("app-household-member-address-state").select( + householdMember.householdMemberAddress.state + ) + cy.getByTestId("app-household-member-address-zip").type( + householdMember.householdMemberAddress.zipCode + ) + } else { + cy.getByTestId("app-household-member-same-address").eq(0).check() + } - if (householdMember.workInRegion === "yes") { - cy.getByTestId("app-household-member-work-in-region").eq(0).check() - cy.getByTestId("app-household-member-work-address-street").type( - householdMember.householdMemberWorkAddress.street - ) - cy.getByTestId("app-household-member-work-address-street2").type( - householdMember.householdMemberWorkAddress.street2 - ) - cy.getByTestId("app-household-member-work-address-city").type( - householdMember.householdMemberWorkAddress.city - ) - cy.getByTestId("app-household-member-work-address-state").select( - householdMember.householdMemberWorkAddress.state - ) - cy.getByTestId("app-household-member-work-address-zip").type( - householdMember.householdMemberWorkAddress.zipCode - ) - } else { - cy.getByTestId("app-household-member-work-in-region").eq(1).check() - } + if (householdMember.workInRegion === "yes") { + cy.getByTestId("app-household-member-work-in-region").eq(0).check() + cy.getByTestId("app-household-member-work-address-street").type( + householdMember.householdMemberWorkAddress.street + ) + cy.getByTestId("app-household-member-work-address-street2").type( + householdMember.householdMemberWorkAddress.street2 + ) + cy.getByTestId("app-household-member-work-address-city").type( + householdMember.householdMemberWorkAddress.city + ) + cy.getByTestId("app-household-member-work-address-state").select( + householdMember.householdMemberWorkAddress.state + ) + cy.getByTestId("app-household-member-work-address-zip").type( + householdMember.householdMemberWorkAddress.zipCode + ) + } else { + cy.getByTestId("app-household-member-work-in-region").eq(1).check() + } - cy.getByTestId("app-household-member-relationship").select(householdMember.relationship) + cy.getByTestId("app-household-member-relationship").select(householdMember.relationship) + } cy.getByID("app-household-member-save").click() cy.checkErrorAlert("not.exist") @@ -311,44 +346,84 @@ Cypress.Commands.add("step7AddHouseholdMembers", (application) => { cy.goNext() }) -Cypress.Commands.add("step8PreferredUnits", (application) => { - application.preferredUnitTypes.forEach((prefUnit) => { - cy.getByTestId(prefUnit.name).check() - }) +Cypress.Commands.add("step8PreferredUnits", (application, autofill) => { + if (!autofill) { + application.preferredUnitTypes.forEach((prefUnit) => { + cy.getByTestId(prefUnit.name).check() + }) + } else { + cy.contains("What unit sizes are you interested in?") + } + cy.goNext() cy.checkErrorAlert("not.exist") cy.checkErrorMessages("not.exist") cy.isNextRouteValid("preferredUnitSize") }) -Cypress.Commands.add("step9Accessibility", (application) => { - if (application.accessibility.mobility) { - cy.getByTestId("app-ada-mobility").check() - } - if (application.accessibility.vision) { - cy.getByTestId("app-ada-vision").check() - } - if (application.accessibility.hearing) { - cy.getByTestId("app-ada-hearing").check() - } - if ( - !application.accessibility.hearing && - !application.accessibility.hearing && - !application.accessibility.mobility - ) { - cy.getByTestId("app-ada-none").check() +Cypress.Commands.add("step9Accessibility", (application, autofill) => { + if (!autofill) { + if (application.accessibility.mobility) { + cy.getByTestId("app-ada-mobility").check() + } + if (application.accessibility.vision) { + cy.getByTestId("app-ada-vision").check() + } + if (application.accessibility.hearing) { + cy.getByTestId("app-ada-hearing").check() + } + if ( + !application.accessibility.hearing && + !application.accessibility.hearing && + !application.accessibility.mobility + ) { + cy.getByTestId("app-ada-none").check() + } } cy.goNext() cy.checkErrorAlert("not.exist") cy.checkErrorMessages("not.exist") - if (application.programs.length) { + + if (autofill || application.programs.length) { cy.isNextRouteValid("adaHouseholdMembers") } else { cy.isNextRouteValid("adaHouseholdMembers", 1) } }) +Cypress.Commands.add("step10Changes", (application, autofill) => { + if (!autofill) { + if (application.householdExpectingChanges) { + cy.getByTestId("app-expecting-changes").eq(0).check() + } else { + cy.getByTestId("app-expecting-changes").eq(1).check() + } + } + + cy.goNext() + + cy.checkErrorAlert("not.exist") + cy.checkErrorMessages("not.exist") + cy.isNextRouteValid("householdExpectingChanges") +}) + +Cypress.Commands.add("step11Student", (application, programsExist, autofill) => { + if (!autofill) { + if (application.householdStudent) { + cy.getByTestId("app-student").eq(0).check() + } else { + cy.getByTestId("app-student").eq(1).check() + } + } + + cy.goNext() + + cy.checkErrorAlert("not.exist") + cy.checkErrorMessages("not.exist") + cy.isNextRouteValid("householdStudent", !programsExist ? 1 : 0) +}) + Cypress.Commands.add("step12Programs", (application) => { application.programs.forEach((program) => { if (!program.claimed) { @@ -361,44 +436,22 @@ Cypress.Commands.add("step12Programs", (application) => { } }) } + cy.goNext() }) cy.isNextRouteValid("programs") }) -Cypress.Commands.add("step10Changes", (application) => { - if (application.householdExpectingChanges) { - cy.getByTestId("app-expecting-changes").eq(0).check() - } else { - cy.getByTestId("app-expecting-changes").eq(1).check() - } - cy.goNext() - - cy.checkErrorAlert("not.exist") - cy.checkErrorMessages("not.exist") - cy.isNextRouteValid("householdExpectingChanges") -}) - -Cypress.Commands.add("step11Student", (application, programsExist) => { - if (application.householdStudent) { - cy.getByTestId("app-student").eq(0).check() - } else { - cy.getByTestId("app-student").eq(1).check() +Cypress.Commands.add("step13IncomeVouchers", (application, autofill) => { + if (!autofill) { + if (application.incomeVouchers) { + cy.getByTestId("app-income-vouchers").eq(0).check() + } else { + cy.getByTestId("app-income-vouchers").eq(1).check() + } } - cy.goNext() - - cy.checkErrorAlert("not.exist") - cy.checkErrorMessages("not.exist") - cy.isNextRouteValid("householdStudent", !programsExist ? 1 : 0) -}) -Cypress.Commands.add("step13IncomeVouchers", (application) => { - if (application.incomeVouchers) { - cy.getByTestId("app-income-vouchers").eq(0).check() - } else { - cy.getByTestId("app-income-vouchers").eq(1).check() - } cy.goNext() cy.checkErrorAlert("not.exist") @@ -406,12 +459,14 @@ Cypress.Commands.add("step13IncomeVouchers", (application) => { cy.isNextRouteValid("vouchersSubsidies") }) -Cypress.Commands.add("step14Income", (application) => { - cy.getByTestId("app-income").type(application.income, { force: true }) - if (application.incomePeriod === "perMonth") { - cy.getByTestId("app-income-period").eq(0).check() - } else { - cy.getByTestId("app-income-period").eq(1).check() +Cypress.Commands.add("step14Income", (application, autofill) => { + if (!autofill) { + cy.getByTestId("app-income").type(application.income, { force: true }) + if (application.incomePeriod === "perMonth") { + cy.getByTestId("app-income-period").eq(0).check() + } else { + cy.getByTestId("app-income-period").eq(1).check() + } } cy.goNext() @@ -463,20 +518,24 @@ Cypress.Commands.add("step16GeneralPool", () => { cy.isNextRouteValid("generalPool") }) -Cypress.Commands.add("step17Demographics", (application) => { - cy.location("pathname").should("include", "applications/review/demographics") - application.demographics.race.forEach((race) => { - cy.getByTestId(race).check() - }) +Cypress.Commands.add("step17Demographics", (application, autofill) => { + if (!autofill) { + cy.location("pathname").should("include", "applications/review/demographics") + application.demographics.race.forEach((race) => { + cy.getByTestId(race).check() + }) - if (application.demographics.ethnicity) { - cy.getByTestId("app-demographics-ethnicity").select(application.demographics.ethnicity) - } + if (application.demographics.ethnicity) { + cy.getByTestId("app-demographics-ethnicity").select(application.demographics.ethnicity) + } - application.demographics.howDidYouHear.forEach((howDidYouHear) => { - const howDidYouHearIndex = howDidYouHearCheckboxesOrder.indexOf(howDidYouHear) - cy.getByTestId("app-demographics-how-did-you-hear").eq(howDidYouHearIndex).check() - }) + application.demographics.howDidYouHear.forEach((howDidYouHear) => { + const howDidYouHearIndex = howDidYouHearCheckboxesOrder.indexOf(howDidYouHear) + cy.getByTestId("app-demographics-how-did-you-hear").eq(howDidYouHearIndex).check() + }) + } else { + cy.contains("Which best describes your ethnicity?") + } cy.goNext() cy.checkErrorAlert("not.exist") @@ -671,60 +730,63 @@ Cypress.Commands.add("step19TermsAndSubmit", () => { cy.getByTestId("app-confirmation-id").should("be.visible").and("not.be.empty") }) -Cypress.Commands.add("submitApplication", (listingName, application, signedIn, verify) => { - if (signedIn) { - cy.beginApplicationSignedIn(listingName) - } else { - cy.beginApplicationRejectAutofill(listingName) - } - cy.step1PrimaryApplicantName(application) - cy.step2PrimaryApplicantAddresses(application) - cy.step3AlternateContactType(application) - if (application.alternateContact.type !== "noContact") { - cy.step4AlternateContactName(application) - cy.step5AlternateContactInfo(application) - } - cy.step6HouseholdSize(application) - if (application.householdMember.length > 0) { - cy.step7AddHouseholdMembers(application) - } - cy.step8PreferredUnits(application) - cy.step9Accessibility(application) - cy.step10Changes(application) - - cy.window().then((win) => { - const listing = JSON.parse(win.sessionStorage.getItem("bloom-app-listing")) - const listingQuestionSectionExists = (sectionTitle) => { - return ( - listing.listingMultiselectQuestions?.filter( - (question) => question.multiselectQuestions.applicationSection === sectionTitle - )?.length > 0 - ) +Cypress.Commands.add( + "submitApplication", + (listingName, application, signedIn, verify, autofill) => { + if (signedIn) { + cy.beginApplicationSignedIn(listingName, autofill) + } else { + cy.beginApplicationRejectAutofill(listingName) + } + cy.step1PrimaryApplicantName(application, autofill) + cy.step2PrimaryApplicantAddresses(application, autofill) + cy.step3AlternateContactType(application, autofill) + if (application.alternateContact.type !== "noContact") { + cy.step4AlternateContactName(application, autofill) + cy.step5AlternateContactInfo(application, autofill) + } + cy.step6HouseholdSize(application, autofill) + if (application.householdMember.length > 0) { + cy.step7AddHouseholdMembers(application, autofill) } - const programsExist = listingQuestionSectionExists("programs") - const preferencesExist = listingQuestionSectionExists("preferences") + cy.step8PreferredUnits(application, autofill) + cy.step9Accessibility(application, autofill) + cy.step10Changes(application, autofill) + + cy.window().then((win) => { + const listing = JSON.parse(win.sessionStorage.getItem("bloom-app-listing")) + const listingQuestionSectionExists = (sectionTitle) => { + return ( + listing.listingMultiselectQuestions?.filter( + (question) => question.multiselectQuestions.applicationSection === sectionTitle + )?.length > 0 + ) + } + const programsExist = listingQuestionSectionExists("programs") + const preferencesExist = listingQuestionSectionExists("preferences") - cy.step11Student(application, programsExist) + cy.step11Student(application, programsExist, autofill) - if (programsExist) { - cy.step12Programs(application) - } + if (programsExist) { + cy.step12Programs(application) + } - cy.step13IncomeVouchers(application) - cy.step14Income(application) - if (preferencesExist) { - if (application.preferences.length > 0) { - cy.step15SelectPreferences(application) - } else { - cy.step16GeneralPool() + cy.step13IncomeVouchers(application, autofill) + cy.step14Income(application, autofill) + if (preferencesExist) { + if (application.preferences.length > 0) { + cy.step15SelectPreferences(application) + } else { + cy.step16GeneralPool() + } } - } - cy.step17Demographics(application) - cy.step18Summary(application, verify) - cy.step19TermsAndSubmit(application) - }) -}) + cy.step17Demographics(application, autofill) + cy.step18Summary(application, verify) + cy.step19TermsAndSubmit(application) + }) + } +) Cypress.Commands.add("isNextRouteValid", (currentStep, skip = 0) => { const nextRouteIndex = diff --git a/sites/public/cypress/support/index.d.ts b/sites/public/cypress/support/index.d.ts index 0f188f656a..e500a388a0 100644 --- a/sites/public/cypress/support/index.d.ts +++ b/sites/public/cypress/support/index.d.ts @@ -3,7 +3,7 @@ declare namespace Cypress { interface Chainable { beginApplicationRejectAutofill(listingName: string): Chainable - beginApplicationSignedIn(listingName: string): Chainable + beginApplicationSignedIn(listingName: string, autofill?: boolean): Chainable checkErrorAlert(command: string): Chainable checkErrorMessages(command: string): Chainable getByTestId(testId: string): Chainable @@ -13,32 +13,33 @@ declare namespace Cypress { isNextRouteValid(currentStep: string, skip?: number): Chainable signIn(email?: string, password?: string): Chainable signOut(): Chainable - step1PrimaryApplicantName(application: Application): Chainable - step2PrimaryApplicantAddresses(application: Application): Chainable - step3AlternateContactType(application: Application): Chainable - step4AlternateContactName(application: Application): Chainable - step5AlternateContactInfo(application: Application): Chainable + step1PrimaryApplicantName(application: Application, autofill?: boolean): Chainable + step2PrimaryApplicantAddresses(application: Application, autofill?: boolean): Chainable + step3AlternateContactType(application: Application, autofill?: boolean): Chainable + step4AlternateContactName(application: Application, autofill?: boolean): Chainable + step5AlternateContactInfo(application: Application, autofill?: boolean): Chainable step6HouseholdSize(application: Application): Chainable - step7AddHouseholdMembers(application: Application): Chainable - step8PreferredUnits(application: Application): Chainable - step9Accessibility(application: Application): Chainable - step10Programs(application: Application): Chainable - step10Changes(application: Application): Chainable - step11Student(application: Application, programsExist: boolean): Chainable - step12Student(application: Application): Chainable + step7AddHouseholdMembers(application: Application, autofill?: boolean): Chainable + step8PreferredUnits(application: Application, autofill?: boolean): Chainable + step9Accessibility(application: Application, autofill?: boolean): Chainable + step10Programs(application: Application, autofill?: boolean): Chainable + step10Changes(application: Application, autofill?: boolean): Chainable + step11Student(application: Application, programsExist: boolean, autofill?: boolean): Chainable + step12Student(application: Application, autofill?: boolean): Chainable step12Programs(application: Application): Chainable - step13IncomeVouchers(application: Application): Chainable - step14Income(application: Application): Chainable + step13IncomeVouchers(application: Application, autofill?: boolean): Chainable + step14Income(application: Application, autofill?: boolean): Chainable step15SelectPreferences(application: Application): Chainable step16GeneralPool(): Chainable - step17Demographics(application: Application): Chainable - step18Summary(application: Application): Chainable + step17Demographics(application: Application, autofill?: boolean): Chainable + step18Summary(application: Application, verify?: boolean): Chainable step19TermsAndSubmit(application: Application): Chainable submitApplication( listingName: string, application: Application, signedIn: boolean, - verify?: boolean + verify?: boolean, + autofill?: boolean ) } } diff --git a/sites/public/src/pages/applications/start/autofill.tsx b/sites/public/src/pages/applications/start/autofill.tsx index 1eb44a3f42..c4c14f03d7 100644 --- a/sites/public/src/pages/applications/start/autofill.tsx +++ b/sites/public/src/pages/applications/start/autofill.tsx @@ -120,7 +120,7 @@ export default () => { onClick={() => { useDetails = true }} - data-testid={"autofill-accept"} + id={"autofill-accept"} type={"submit"} > {t("application.autofill.start")}