Fix logic for scheduling appointments
This commit is contained in:
parent
02e0afe4f6
commit
303fc24735
1 changed files with 15 additions and 6 deletions
|
|
@ -56,13 +56,20 @@ export class SchedulePage extends BasePage {
|
|||
// Select in shop and schedule
|
||||
async scheduleInShop(appointmentDetails?: IAppointmentDetails){
|
||||
|
||||
if (await this.inShopButton.isVisible() && appointmentDetails?.serviceLocation !== ServiceLocation.DropOff) {
|
||||
if (await this.inShopButton.isVisible()) {
|
||||
await this.inShopButton.waitFor({ state: 'visible', timeout: 5000 });
|
||||
await this.inShopButton.click();
|
||||
await (await this.getTimeSlot(1)).click();
|
||||
await (await this.getFirstNonDropOffTimeSlot()).click();
|
||||
} else if (await this.inShopButton.isHidden() && appointmentDetails?.serviceLocation === ServiceLocation.InShop) {
|
||||
await (await this.getFirstNonDropOffTimeSlot()).click();
|
||||
} else if (appointmentDetails?.serviceLocation === ServiceLocation.DropOff) {
|
||||
await this.inShopButton.isVisible();
|
||||
if (await this.inShopButton.isVisible()){
|
||||
await this.inShopButton.waitFor({ state: 'visible', timeout: 5000 });
|
||||
await this.inShopButton.click();
|
||||
await this.dropOffButton.isVisible() ? await this.dropOffButton.click() : null;
|
||||
} else {
|
||||
await this.dropOffButton.waitFor({ state: 'visible', timeout: 5000 });
|
||||
await this.dropOffButton.isVisible() ? await this.dropOffButton.click() : await (await this.getFirstNonDropOffTimeSlot()).click(); // drop off is available in the morning for same day so this is here to avoid flaky tests
|
||||
}
|
||||
} else {
|
||||
await this.selectFirstAvailableTime();
|
||||
}
|
||||
|
|
@ -89,7 +96,9 @@ export class SchedulePage extends BasePage {
|
|||
}
|
||||
}
|
||||
|
||||
async getTimeSlot(index: number): Promise<Locator> {
|
||||
return this.page.locator('.time-slot-button').nth(index);
|
||||
async getFirstNonDropOffTimeSlot(): Promise<Locator> {
|
||||
const timeSlots = this.page.locator('.time-slot-button');
|
||||
const nonDropOff = timeSlots.filter({ hasNotText: /Drop & Go/i });
|
||||
return nonDropOff.first();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue