diff --git a/playwright-tests/pages/OrderConfirmationPage.ts b/playwright-tests/pages/OrderConfirmationPage.ts index 9ac31826f..af05c132d 100644 --- a/playwright-tests/pages/OrderConfirmationPage.ts +++ b/playwright-tests/pages/OrderConfirmationPage.ts @@ -60,7 +60,8 @@ export class OrderConfirmationPage extends BasePage { // General Validations expect.soft(serviceTextValue).toContain(`${vehicleDetails!.year} ${vehicleDetails!.make} ${vehicleDetails!.model}`); - expect.soft(apptDateValue).toContain(customerDetails!.apptDate); + const formattedExpectedAppointmentDate = await this.getFormattedAppointmentDate(customerDetails!.apptDate!); + expect.soft(apptDateValue).toContain(formattedExpectedAppointmentDate); expect.soft(emailTextValue).toContain(customerDetails!.email); // Service package validations @@ -125,6 +126,16 @@ export class OrderConfirmationPage extends BasePage { } } + async getFormattedAppointmentDate(appointmentDate: string) { + + // Parse the original date + let parsedAppointmentDate = new Date(`${appointmentDate}` + 'T00:00:00'); + + // Format the new date as a string + let updatedAppointmentDate = parsedAppointmentDate.toLocaleDateString('en-US', { weekday: 'long', month: 'long', day: 'numeric' }); + return updatedAppointmentDate; + } + async logOrderNumber() { const sessionStorage = JSON.parse(await this.page.evaluate('sessionStorage.getItem(\'submittedState\')')); return sessionStorage.order.workOrderNumber; diff --git a/playwright-tests/pages/PaymentMethodPage.ts b/playwright-tests/pages/PaymentMethodPage.ts index 210e9291f..7971cef59 100644 --- a/playwright-tests/pages/PaymentMethodPage.ts +++ b/playwright-tests/pages/PaymentMethodPage.ts @@ -448,18 +448,9 @@ l } async getFormattedAppointmentDate(appointmentDate: string) { - const currentYear = new Date().getFullYear(); // Parse the original date - let parsedAppointmentDate = new Date(`${appointmentDate}, ${currentYear}`); - - let currentDate = new Date(); - currentDate.setDate(currentDate.getDate() - 2); - - // If the original date is not in the future, adjust the year - if (parsedAppointmentDate < currentDate) { - parsedAppointmentDate.setFullYear(parsedAppointmentDate.getFullYear() + 1); - } + let parsedAppointmentDate = new Date(`${appointmentDate}` + 'T00:00:00'); // Format the new date as a string let updatedAppointmentDate = parsedAppointmentDate.toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }); diff --git a/playwright-tests/pages/SchedulePage.ts b/playwright-tests/pages/SchedulePage.ts index 80ae29920..dd81a4f94 100644 --- a/playwright-tests/pages/SchedulePage.ts +++ b/playwright-tests/pages/SchedulePage.ts @@ -29,7 +29,7 @@ export class SchedulePage extends BasePage { this.dateText = this.page.locator('label.modal-title'); this.viewMoreDatesLink = this.page.getByText(/View more dates/).first(); this.appointmentDuration = this.page.locator('.duration-text-block'); - this.timeSlots = this.page.locator('fieldset:has(legend[id *= \'chooseTimeSlot\']) label'); + this.timeSlots = this.page.locator('fieldset[aria-labelledby=\'chooseTimeSlot\'] label'); } async scheduleAppointment(appointmentDetails: IAppointmentDetails) { @@ -52,6 +52,7 @@ export class SchedulePage extends BasePage { await this.viewMoreDatesLink.click(); } await this.firstAvailableDate.click(); + customerDetails.apptDate = `${await this.firstAvailableDate.getAttribute("id")}` // const timeSlots = this.timeSlots; const timeSlotCount = await this.timeSlots.count(); @@ -61,9 +62,8 @@ export class SchedulePage extends BasePage { customerDetails.apptTime = await this.getFormattedTimeSlot(timeSlot); }); // appointmentmentDetails.serviceLocation === AppointmentType.DropOff ? await this.dropOffButton.click() : await this.firstAvailableTime.click(); - customerDetails.apptDate = `${await this.dateText.allInnerTexts()}` customerDetails.apptDuration = (await this.appointmentDuration.innerText()).replace("Duration: ", ""); - await this.modalContinueButton.click(); + await this.nextPage(); } async getFormattedTimeSlot(timeSlot: Locator) {