fix for the schedule page changes
This commit is contained in:
parent
ac53601a34
commit
faf892b307
3 changed files with 16 additions and 14 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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' });
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue