Skip to content

Commit

Permalink
test: add autofill cypress test (#4607)
Browse files Browse the repository at this point in the history
* test: update cypress test steps to include conditional autofill logic

* test: run autofill test after regular test (broken)

* test: change second test to Elm Village for continuity

* test: remove zeros from mock bday months

* test: edit command conditionals based on actual autofill logic and add some cy.wait() to pass tests

* chore: move cy.wait into autofill only conditional and move step 12 to be after step 11

* test: create blue sky specific autofill application and run that after elm village

* chore: add BlueSkyProgramsAndPreferences to minimalDataApplication

* chore: remove only from test

* chore: pull nextStep logic out of function argument

* chore: wait 1 second on step 6 autofill

* chore: remove cy.log and put autofill logic back in arg

* test: add pathname checks before and after problematic line

* test: conditional isNextRouteValid call because using skip arg was inconsistent

* test: grab text to slow down step 6 during autofill

* test: run step6 only if not autofill

* test: select text instead of cy.wait() to slow app down

* test: rm minimalApplication, pass empty programs array, don't skip household step on autofill
  • Loading branch information
adriencyberspace authored Jan 31, 2025
1 parent fd0e526 commit cf128ee
Show file tree
Hide file tree
Showing 5 changed files with 361 additions and 528 deletions.
11 changes: 4 additions & 7 deletions sites/public/cypress/e2e/pages/submit-application.spec.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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)
})
})
237 changes: 5 additions & 232 deletions sites/public/cypress/mockData/applicationData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]",
Expand Down Expand Up @@ -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: {
Expand All @@ -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,
Expand Down Expand Up @@ -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 = [
Expand Down
Loading

0 comments on commit cf128ee

Please sign in to comment.