Skip to content

Commit

Permalink
replacing string id with constants
Browse files Browse the repository at this point in the history
  • Loading branch information
TKDickson committed Dec 10, 2024
1 parent 55ed60e commit d9cb0a7
Showing 1 changed file with 45 additions and 42 deletions.
87 changes: 45 additions & 42 deletions VAMobile/e2e/tests/AppointmentsExpanded.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { CommonE2eIdConstants, loginToDemoMode, openAppointments, openHealth, to

export const AppointmentsExpandede2eConstants = {
PATIENT_CANCELLATION: 'You canceled this appointment.',
VIDEO_VISIT_PREP_ID: 'prepareForVideoVisitTestID',
APPT_DIRECTIONS_ID: 'directionsTestID',
VA_APPT_CANCEL_ID: 'vaLinkApptsCancelTestID',
}

const checkMedicationWording = async ({
Expand Down Expand Up @@ -44,12 +47,12 @@ const checkMedicationWording = async ({

if (appointmentType === 'ATLAS' || appointmentType === 'Home' || appointmentType === 'GFE') {
await expect(element(by.text('Get your device ready to join.'))).toExist()
await expect(element(by.id('prepareForVideoVisitTestID'))).toExist()
await waitFor(element(by.id('prepareForVideoVisitTestID')))
await expect(element(by.id(AppointmentsExpandede2eConstants.VIDEO_VISIT_PREP_ID))).toExist()
await waitFor(element(by.id(AppointmentsExpandede2eConstants.VIDEO_VISIT_PREP_ID)))
.toBeVisible()
.whileElement(by.id(pastAppointment ? 'PastApptDetailsTestID' : 'UpcomingApptDetailsTestID'))
.scroll(300, 'down')
await element(by.id('prepareForVideoVisitTestID')).tap()
await element(by.id(AppointmentsExpandede2eConstants.VIDEO_VISIT_PREP_ID)).tap()
await expect(element(by.text('Appointments help'))).toExist()
await element(by.text('Close')).tap()
} else if (appointmentType === 'Claim') {
Expand All @@ -73,7 +76,7 @@ const checkMedicationWording = async ({
).not.toExist()
await expect(element(by.text('Learn more about claim exam appointments'))).not.toExist()
await expect(element(by.text('Get your device ready to join.'))).not.toExist()
await expect(element(by.id('prepareForVideoVisitTestID'))).not.toExist()
await expect(element(by.id(AppointmentsExpandede2eConstants.VIDEO_VISIT_PREP_ID))).not.toExist()
}
} else {
await expect(element(by.text('Prepare for your appointment'))).not.toExist()
Expand Down Expand Up @@ -191,7 +194,7 @@ const checkUpcomingApptDetails = async (
if (locationAddress != undefined) {
await expect(element(by.text(locationAddress))).toExist()
if (appointmentStatus !== 'Pending' && appointmentType !== 'CC') {
await expect(element(by.id('directionsTestID'))).toExist()
await expect(element(by.id(AppointmentsExpandede2eConstants.APPT_DIRECTIONS_ID))).toExist()
await expect(element(by.id(CommonE2eIdConstants.CALL_VA_PHONE_NUMBER_ID)).atIndex(0)).toExist()
await expect(element(by.id(CommonE2eIdConstants.CALL_VA_TTY_PHONE_NUMBER_ID)).atIndex(0)).toExist()
}
Expand Down Expand Up @@ -269,7 +272,7 @@ const checkUpcomingApptDetails = async (
}
await expect(element(by.id(CommonE2eIdConstants.CALL_VA_PHONE_NUMBER_ID)).atIndex(1)).toExist()
await expect(element(by.id(CommonE2eIdConstants.CALL_VA_TTY_PHONE_NUMBER_ID)).atIndex(1)).toExist()
await expect(element(by.id('vaLinkApptsCancelTestID'))).toExist()
await expect(element(by.id(AppointmentsExpandede2eConstants.VA_APPT_CANCEL_ID))).toExist()
}
} else if (appointmentStatus === 'Pending') {
if (appointmentType !== 'CC') {
Expand Down Expand Up @@ -346,36 +349,36 @@ const scrollToThenTap = async (text: string, pastAppointment: string) => {
text === 'At VA Palo Alto Health Care System' ||
text === 'At Hampton VA Medical Center'
) {
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
}
if (pastAppointment !== '') {
try {
await waitFor(element(by.text(text)))
.toBeVisible()
.whileElement(by.id('appointmentsTestID'))
.whileElement(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID))
.scroll(250, 'down')
} catch (ex) {
await waitFor(element(by.text(text)))
.toBeVisible()
.whileElement(by.id('appointmentsTestID'))
.whileElement(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID))
.scroll(250, 'up')
}
} else {
await waitFor(element(by.text(text)))
.toBeVisible()
.whileElement(by.id('appointmentsTestID'))
.whileElement(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID))
.scroll(300, 'down')

try {
await waitFor(element(by.text(text)))
.toBeVisible()
.whileElement(by.id('appointmentsTestID'))
.whileElement(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID))
.scroll(250, 'down')
} catch (ex) {
await waitFor(element(by.text(text)))
.toBeVisible()
.whileElement(by.id('appointmentsTestID'))
.whileElement(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID))
.scroll(250, 'up')
}
}
Expand All @@ -395,7 +398,7 @@ export async function apppointmentVerification(pastAppointment = false) {
await waitFor(element(by.text('Upcoming')))
.toExist()
.withTimeout(10000)
await element(by.id('appointmentsTestID')).scrollTo('top')
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('top')
await element(by.text('Past')).tap()
}
await scrollToThenTap('Vilanisi Reddy', pastAppointmentString)
Expand Down Expand Up @@ -711,12 +714,12 @@ export async function apppointmentVerification(pastAppointment = false) {
await waitFor(element(by.text('Upcoming')))
.toExist()
.withTimeout(10000)
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
} else {
await element(by.text('Past')).tap()
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
}
await scrollToThenTap('At Fort Collins VA Clinic - Claim - Canceled', pastAppointmentString)
await expect(element(by.text('Fort Collins VA Clinic - Claim - Canceled canceled this appointment.'))).toExist()
Expand Down Expand Up @@ -803,12 +806,12 @@ export async function apppointmentVerification(pastAppointment = false) {
await waitFor(element(by.text('Upcoming')))
.toExist()
.withTimeout(10000)
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
} else {
await element(by.text('Past')).tap()
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
}

await scrollToThenTap('At Central California VA Health Care System', pastAppointmentString)
Expand Down Expand Up @@ -901,16 +904,16 @@ export async function apppointmentVerification(pastAppointment = false) {
await waitFor(element(by.text('Upcoming')))
.toExist()
.withTimeout(10000)
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
} else {
await element(by.text('Past')).tap()
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
}

await scrollToThenTap('John Jones', pastAppointmentString)
Expand Down Expand Up @@ -1002,20 +1005,20 @@ export async function apppointmentVerification(pastAppointment = false) {
await waitFor(element(by.text('Upcoming')))
.toExist()
.withTimeout(10000)
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
} else {
await element(by.text('Past')).tap()
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id('appointmentsTestID')).scrollTo('bottom')
await element(by.id('next-page')).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
await element(by.id(CommonE2eIdConstants.APPOINTMENTS_SCROLL_ID)).scrollTo('bottom')
await element(by.id(CommonE2eIdConstants.NEXT_PAGE_ID)).tap()
}

await scrollToThenTap('Jane Jones', pastAppointmentString)
Expand Down

0 comments on commit d9cb0a7

Please sign in to comment.