From 2f297d2c101b4faf5eed6209a44fc8b1838c42e9 Mon Sep 17 00:00:00 2001 From: kpatel8hs4io <31411746+kpatel8hs4io@users.noreply.github.com> Date: Wed, 21 May 2025 19:17:37 -0400 Subject: [PATCH] fix for the afterpay tests related to progress bar validations and updated mobile service location selection --- playwright-tests/pages/BasePage.ts | 11 +++++---- .../pages/OrderConfirmationPage.ts | 4 ++-- playwright-tests/pages/PaymentMethodPage.ts | 2 +- playwright-tests/pages/ServiceLocationPage.ts | 8 +++---- playwright-tests/pages/forms/AddressForm.ts | 24 ++++++++++++++++--- .../tests/CashRepairMobileCreditCard.ts | 13 ++++++++-- .../tests/CashReplaceDynamicRecalMobile.ts | 10 +++++++- .../tests/CashReplaceMultiGlassMobile.ts | 8 +++---- .../CashReplaceSafeliteCanNotRecalMobile.ts | 4 ++-- .../tests/CashReplaceVinMobile.ts | 4 ++-- 10 files changed, 62 insertions(+), 26 deletions(-) diff --git a/playwright-tests/pages/BasePage.ts b/playwright-tests/pages/BasePage.ts index 348ee9476..ab3904e14 100644 --- a/playwright-tests/pages/BasePage.ts +++ b/playwright-tests/pages/BasePage.ts @@ -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}`); diff --git a/playwright-tests/pages/OrderConfirmationPage.ts b/playwright-tests/pages/OrderConfirmationPage.ts index 6e513d7d2..fd3accf88 100644 --- a/playwright-tests/pages/OrderConfirmationPage.ts +++ b/playwright-tests/pages/OrderConfirmationPage.ts @@ -178,12 +178,12 @@ export class OrderConfirmationPage extends BasePage { @step("OrderConfirmationPage >> Validate order") async verifyOrderConfirmationPage(testData: Partial) { - + 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}`); }); - } + } } \ No newline at end of file diff --git a/playwright-tests/pages/PaymentMethodPage.ts b/playwright-tests/pages/PaymentMethodPage.ts index 0705955f9..dab6fed58 100644 --- a/playwright-tests/pages/PaymentMethodPage.ts +++ b/playwright-tests/pages/PaymentMethodPage.ts @@ -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'); } } } diff --git a/playwright-tests/pages/ServiceLocationPage.ts b/playwright-tests/pages/ServiceLocationPage.ts index 375566c04..70dafd68a 100644 --- a/playwright-tests/pages/ServiceLocationPage.ts +++ b/playwright-tests/pages/ServiceLocationPage.ts @@ -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(); diff --git a/playwright-tests/pages/forms/AddressForm.ts b/playwright-tests/pages/forms/AddressForm.ts index acbdadec5..afa9d9c85 100644 --- a/playwright-tests/pages/forms/AddressForm.ts +++ b/playwright-tests/pages/forms/AddressForm.ts @@ -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) { diff --git a/playwright-tests/tests/CashRepairMobileCreditCard.ts b/playwright-tests/tests/CashRepairMobileCreditCard.ts index 892c8d71e..db8ebd8ce 100644 --- a/playwright-tests/tests/CashRepairMobileCreditCard.ts +++ b/playwright-tests/tests/CashRepairMobileCreditCard.ts @@ -12,9 +12,18 @@ setFakerSeedFromTestName("CashRepairMobileCreditCard"); const cashRepairMobileCCData : Partial = { ...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!, diff --git a/playwright-tests/tests/CashReplaceDynamicRecalMobile.ts b/playwright-tests/tests/CashReplaceDynamicRecalMobile.ts index 25bb3bf50..1f3d2e785 100644 --- a/playwright-tests/tests/CashReplaceDynamicRecalMobile.ts +++ b/playwright-tests/tests/CashReplaceDynamicRecalMobile.ts @@ -17,6 +17,14 @@ const cashReplaceDynamicRecalMobileData: Partial = { // 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 = { 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', diff --git a/playwright-tests/tests/CashReplaceMultiGlassMobile.ts b/playwright-tests/tests/CashReplaceMultiGlassMobile.ts index eac5e2263..2974d41d8 100644 --- a/playwright-tests/tests/CashReplaceMultiGlassMobile.ts +++ b/playwright-tests/tests/CashReplaceMultiGlassMobile.ts @@ -12,13 +12,13 @@ setFakerSeedFromTestName("CashReplaceMultiGlassMobile"); const cashReplaceMultiGlassMobileData: Partial = { ...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 = { 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', diff --git a/playwright-tests/tests/CashReplaceSafeliteCanNotRecalMobile.ts b/playwright-tests/tests/CashReplaceSafeliteCanNotRecalMobile.ts index f7d301da1..e1a8f577d 100644 --- a/playwright-tests/tests/CashReplaceSafeliteCanNotRecalMobile.ts +++ b/playwright-tests/tests/CashReplaceSafeliteCanNotRecalMobile.ts @@ -23,7 +23,7 @@ const cashReplaceSafeliteCanNotRecalMobileData: Partial = { ...getDefaultTestData().customerDetails!, address: { ...getDefaultTestData().customerDetails!.address, - postalCode: '43085' + postalCode: '21237' } }, @@ -46,7 +46,7 @@ const cashReplaceSafeliteCanNotRecalMobileData: Partial = { 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', diff --git a/playwright-tests/tests/CashReplaceVinMobile.ts b/playwright-tests/tests/CashReplaceVinMobile.ts index b9acf3542..cf6a9b515 100644 --- a/playwright-tests/tests/CashReplaceVinMobile.ts +++ b/playwright-tests/tests/CashReplaceVinMobile.ts @@ -20,7 +20,7 @@ const cashReplaceVinMobileData: Partial = { ...getDefaultTestData().customerDetails!, address: { ...getDefaultTestData().customerDetails!.address, - postalCode: '43085' + postalCode: '21237' } }, @@ -43,7 +43,7 @@ const cashReplaceVinMobileData: Partial = { 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',