Fixes service location selection

Corrects an issue where the service location wasn't being selected properly in certain scenarios.

Specifically, it ensures the 'Enter Service Address' button is clicked only when the address text box is not visible. It also removes the unnecessary 'saveAddressButton' click.
This commit is contained in:
maguire-arman 2025-05-15 10:47:17 -04:00
parent a3234c9213
commit b3c3411a37

View file

@ -36,7 +36,6 @@ export class ServiceLocationPage extends BasePage {
readonly zipCodeTextBox: Locator;
readonly vehicleProtectedYesButton: Locator;
readonly vehicleProtectedNoButton: Locator;
readonly saveAddressButton: Locator;
readonly repeatedClicksModalCloseButton: Locator;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=service-location';
@ -49,7 +48,7 @@ export class ServiceLocationPage extends BasePage {
// Initial selection
this.inShopButton = this.page.getByText(/In-shop/);
this.mobileButton = this.page.getByText(/Mobile/);
this.mobileButton = this.page.getByText(/Mobile/).nth(0);
this.dropOffButton = this.page.getByText(/Drop-off/);
this.RecalWarningMessage1 = this.page.getByText(/We're not able to provide mobile service/);
this.RecalWarningMessage2 = this.page.getByText(/advanced safety system recalibration needs to be done in our shop./);
@ -72,7 +71,6 @@ export class ServiceLocationPage extends BasePage {
this.zipCodeTextBox = this.page.getByRole('textbox', { name: 'Zip code' });
this.vehicleProtectedYesButton = this.page.locator('label').filter({ hasText: 'Yes' }).locator('div');
this.vehicleProtectedNoButton = this.page.locator('label').filter({ hasText: 'No' }).locator('div');
this.saveAddressButton = this.page.getByRole('button', { name: 'Continue' })
this.repeatedClicksModalCloseButton = this.page.locator('.QSISlider').locator('img[src*=\'close\']');
}
@ -120,7 +118,9 @@ export class ServiceLocationPage extends BasePage {
const { appointmentDetails, customerDetails } = testData;
if (appointmentDetails?.serviceAddress) {
await this.mobileButton.click();
await this.enterServiceAddressButton.click();
if (!(await this.serviceAddressTextBox.isVisible())) {
await this.enterServiceAddressButton.click();
}
await this.addressForm.populateAddress({ address: appointmentDetails.serviceAddress! });
if (await this.repeatedClicksModalCloseButton.isVisible()) {
await this.repeatedClicksModalCloseButton.click();
@ -134,7 +134,6 @@ export class ServiceLocationPage extends BasePage {
{
await this.mockScheduleResponseForEarlyBird(customerDetails!);
}
await this.saveAddressButton.click();
} else {
console.error('ServiceLocationPage >> Please supply an address')
}