54 lines
2.1 KiB
TypeScript
54 lines
2.1 KiB
TypeScript
import { type Locator, type Page } from '@playwright/test';
|
|
import { BasePage } from './BasePage';
|
|
import { VehicleLookupType } from 'safelite-playwright-core';
|
|
import { ProgressBarPercentages } from 'framework/localTypes/Enums';
|
|
import { IVehicleDetails } from 'safelite-playwright-core';
|
|
import { VinLookupPage } from './VinLookupPage';
|
|
import { VehicleLookupAddressPage } from './VehicleLookupAddressPage';
|
|
import { VehicleLookupLicensePage } from './VehicleLookupLicensePage';
|
|
import { step } from 'framework/localTypes/Step';
|
|
import { ITestData } from 'framework/TestData';
|
|
import { faker } from '@faker-js/faker';
|
|
|
|
export class MobileDetailsPage extends BasePage {
|
|
readonly page: Page;
|
|
readonly streetAddressInputBox: Locator;
|
|
readonly CityInputBox: Locator;
|
|
readonly YesButton: Locator;
|
|
readonly NoButton: Locator;
|
|
|
|
|
|
constructor(page: Page) {
|
|
super(page);
|
|
this.page = page;
|
|
this.streetAddressInputBox = page.locator('#streetAddress');
|
|
this.CityInputBox = page.locator('#city');
|
|
this.YesButton = page.locator('label[buttonlabel="Yes"]');
|
|
this.NoButton = page.locator('label[buttonlabel="No"]');
|
|
}
|
|
|
|
async enterMobileDetails(testData: Partial<ITestData>) {
|
|
const { appointmentDetails, customerDetails } = testData;
|
|
if (appointmentDetails?.serviceAddress) {
|
|
await this.streetAddressInputBox.fill(appointmentDetails.serviceAddress!.street);
|
|
await this.CityInputBox.fill(appointmentDetails.serviceAddress!.city);
|
|
}
|
|
else
|
|
{
|
|
console.error('ServiceLocationPage >> Please supply an address')
|
|
}
|
|
|
|
if (faker.datatype.boolean()) {
|
|
await this.YesButton.check();
|
|
} else {
|
|
await this.NoButton.check();
|
|
}
|
|
}
|
|
|
|
@step("MobileDetailsPage >> Enter service address: ")
|
|
async handleMobileDetailsPage(testData: Partial<ITestData>) {
|
|
await this.validateProgressBar(ProgressBarPercentages.MobileDetailsPage);
|
|
await this.enterMobileDetails(testData);
|
|
await this.nextPage();
|
|
}
|
|
}
|