fix for the afterpay tests related to progress bar validations and updated mobile service location selection

This commit is contained in:
kpatel8hs4io 2025-05-21 19:17:37 -04:00
parent 24615cb76d
commit 2f297d2c10
10 changed files with 62 additions and 26 deletions

View file

@ -56,8 +56,11 @@ export class BasePage {
async fillAndValidate(element: Locator, value: string){
await expect(async () => {
await element.clear();
await element.fill(value);
var text = await element.textContent();
if(text !== value) {
await element.clear();
await element.fill(value);
}
await expect(element).toHaveValue(value);
}).toPass();
}
@ -129,8 +132,8 @@ export class BasePage {
}
}
async validateProgressBar(progressPercentage: string) {
await this.page.locator('button .loader').waitFor({ state: 'hidden', timeout: 60000 });
async validateProgressBar(progressPercentage: string, timeout: number = 60000) {
await this.page.locator('button .loader, .buy-loader, timeout, .modal-loader').waitFor({ state: 'hidden', timeout: timeout });
const actualProgressPercentage = await this.progressBar.getAttribute("value") || "Not Found";
Soft.expect(actualProgressPercentage).toBe(progressPercentage);
console.log(`Progress Bar Percentage: Actual - ${actualProgressPercentage} vs Expected - ${progressPercentage}`);

View file

@ -178,12 +178,12 @@ export class OrderConfirmationPage extends BasePage {
@step("OrderConfirmationPage >> Validate order")
async verifyOrderConfirmationPage(testData: Partial<ITestData>) {
await this.page.waitForURL(new RegExp('(.+)confirmation'), {timeout: 60000});
await this.validateProgressBar("100");
await this.validateOrderConfirmationPage(testData);
const workOrderNumber = await this.logOrderNumber();
await test.step(`Session Storage Work Order Number: ${workOrderNumber}`, async () => {
console.log(`Session Storage Work Order Number: ${workOrderNumber}`);
});
}
}
}

View file

@ -159,7 +159,7 @@ export class PaymentMethodPage extends BasePage {
// Early Bird line item validation
if (appointmentDetails?.appointmentTimeSlot == AppointmentTimeslot.EarlyBird) {
expect.soft(servicePackageValue).toContain('Early Bird');
expect.soft(servicePackageValue).toContain('Early bird');
}
}
}

View file

@ -48,7 +48,7 @@ export class ServiceLocationPage extends BasePage {
// Initial selection
this.inShopButton = this.page.getByText(/In-shop/);
this.mobileButton = this.page.getByText(/Mobile/).nth(0);
this.mobileButton = this.page.locator('label[buttonlabel="Mobile"]');
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./);
@ -63,7 +63,7 @@ export class ServiceLocationPage extends BasePage {
// For mobile
this.enterServiceAddressButton = this.page.getByRole('link', { name: 'Enter your service address' });
this.enterServiceAddressButton = this.page.getByRole('link', { name: 'Enter your service address ' });
this.serviceAddressTextBox = this.page.getByRole('textbox', { name: 'Street Address' });
this.aptNumberTextBox = this.page.getByRole('textbox', { name: 'Apt. number'});
this.cityTextBox = this.page.getByRole('textbox', { name: 'City' });
@ -118,9 +118,7 @@ export class ServiceLocationPage extends BasePage {
const { appointmentDetails, customerDetails } = testData;
if (appointmentDetails?.serviceAddress) {
await this.mobileButton.click();
if (!(await this.serviceAddressTextBox.isVisible())) {
await this.enterServiceAddressButton.click();
}
// await this.enterServiceAddressButton.click();
await this.addressForm.populateAddress({ address: appointmentDetails.serviceAddress! });
if (await this.repeatedClicksModalCloseButton.isVisible()) {
await this.repeatedClicksModalCloseButton.click();

View file

@ -1,7 +1,7 @@
import { expect, type Locator, type Page } from '@playwright/test';
import { BasePage } from '../BasePage';
import { ICustomerDetails } from '@business-logic/types/CustomerDetails';
import { faker } from '@faker-js/faker/locale/en';
import { waitUntil } from '@impl/utils/TimingUtils';
export class AddressForm extends BasePage {
readonly page: Page;
@ -12,6 +12,7 @@ export class AddressForm extends BasePage {
readonly firstNameTextBox: Locator;
readonly lastNameTextBox: Locator;
readonly addressNotFoundMsg: Locator;
readonly addressSuggestionList: Locator;
constructor(page: Page) {
super(page);
@ -23,6 +24,7 @@ export class AddressForm extends BasePage {
this.firstNameTextBox = page.getByRole('textbox', { name: 'First name' });
this.lastNameTextBox = page.getByRole('textbox', { name: 'Last name' });
this.addressNotFoundMsg = page.getByText('Address not found.');
this.addressSuggestionList = page.locator('.pac-container .pac-item').first();
}
async forceAddressFormToAppear() {
@ -38,13 +40,29 @@ export class AddressForm extends BasePage {
if (customerDetails.address) {
// Force address form to appear
await this.forceAddressFormToAppear();
// await this.forceAddressFormToAppear();
await this.streetAddressTextBox.click();
await this.streetAddressTextBox.pressSequentially(`${customerDetails.address.street}, ${customerDetails.address.city}, ${customerDetails.address.state} ${customerDetails.address.postalCode}`).then( async() => {
await this.streetAddressTextBox.dispatchEvent('keydown', { key: 'ArrowDown' });
await this.streetAddressTextBox.dispatchEvent('keyup', { key: 'ArrowDown' });
});
await waitUntil(async () => {
await this.addressSuggestionList.waitFor({ state: 'visible', timeout: 5000 });
let text = await this.addressSuggestionList.textContent() || '';
return (
text.includes(customerDetails.address!.street) &&
text.includes(customerDetails.address!.city) &&
text.includes(customerDetails.address!.state)
);
});
await this.addressSuggestionList.dispatchEvent('mouseover');
await this.addressSuggestionList.click();
// Fill address
await this.fillAndValidate(this.streetAddressTextBox, customerDetails.address.street);
await this.fillAndValidate(this.zipCodeTextBox, customerDetails.address.postalCode)
await this.fillAndValidate(this.cityTextBox, customerDetails.address.city);
await this.stateDrpDwn.selectOption(customerDetails.address.state);
}
if (customerDetails.firstName) {

View file

@ -12,9 +12,18 @@ setFakerSeedFromTestName("CashRepairMobileCreditCard");
const cashRepairMobileCCData : Partial<ITestData> = {
...getDefaultTestData(), // Get default data with current seed
//Override default vehicle damage (Windshield Crack)
// Override default vehicle damage (Windshield Crack)
vehicleDamage: [VehicleDamage.WindshieldOneChip],
// Override customer postal code
customerDetails: {
...getDefaultTestData().customerDetails!,
address: {
...getDefaultTestData().customerDetails!.address,
postalCode: '91710'
}
},
// Override specific fields with test-specific data
vehicleDetails: {
...getDefaultTestData().vehicleDetails!,

View file

@ -17,6 +17,14 @@ const cashReplaceDynamicRecalMobileData: Partial<ITestData> = {
// Flag for dynamic Recalibration vehicle
dynamicRecal: true,
customerDetails: {
...getDefaultTestData().customerDetails!,
address: {
...getDefaultTestData().customerDetails!.address,
postalCode: '21237'
}
},
// Override vehicle details
vehicleDetails: {
@ -37,7 +45,7 @@ const cashReplaceDynamicRecalMobileData: Partial<ITestData> = {
appointmentDate: getDefaultTestData().appointmentDetails?.appointmentDate,
serviceAddress: {
// Use street address from current faker seed
street: getDefaultTestData().customerDetails!.address.street,
street: "5050 Silver Oak Dr",
city: 'Rosedale',
state: 'MD',
postalCode: '21237',

View file

@ -12,13 +12,13 @@ setFakerSeedFromTestName("CashReplaceMultiGlassMobile");
const cashReplaceMultiGlassMobileData: Partial<ITestData> = {
...getDefaultTestData(), // Get default data with current seed
// Override customer postal code
customerDetails: {
...getDefaultTestData().customerDetails!,
address: {
...getDefaultTestData().customerDetails!.address,
postalCode: '43085'
}
postalCode: '21237'
}// Override customer postal code
},
// Flag for recalibration vehicle
@ -33,7 +33,7 @@ const cashReplaceMultiGlassMobileData: Partial<ITestData> = {
appointmentDate: getDefaultTestData().appointmentDetails?.appointmentDate,
serviceAddress: {
// Use street address from current faker seed
street: getDefaultTestData().customerDetails!.address.street,
street: "5050 Silver Oak Dr",
city: 'Rosedale',
state: 'MD',
postalCode: '21237',

View file

@ -23,7 +23,7 @@ const cashReplaceSafeliteCanNotRecalMobileData: Partial<ITestData> = {
...getDefaultTestData().customerDetails!,
address: {
...getDefaultTestData().customerDetails!.address,
postalCode: '43085'
postalCode: '21237'
}
},
@ -46,7 +46,7 @@ const cashReplaceSafeliteCanNotRecalMobileData: Partial<ITestData> = {
appointmentDate: getDefaultTestData().appointmentDetails?.appointmentDate,
serviceAddress: {
// Use street address from current faker seed
street: getDefaultTestData().customerDetails!.address.street,
street: "5050 Silver Oak Dr",
city: 'Rosedale',
state: 'MD',
postalCode: '21237',

View file

@ -20,7 +20,7 @@ const cashReplaceVinMobileData: Partial<ITestData> = {
...getDefaultTestData().customerDetails!,
address: {
...getDefaultTestData().customerDetails!.address,
postalCode: '43085'
postalCode: '21237'
}
},
@ -43,7 +43,7 @@ const cashReplaceVinMobileData: Partial<ITestData> = {
appointmentDate: getDefaultTestData().appointmentDetails?.appointmentDate,
serviceAddress: {
// Use street address from current faker seed
street: getDefaultTestData().customerDetails!.address.street,
street: "5050 Silver Oak Dr",
city: 'Rosedale',
state: 'MD',
postalCode: '21237',