From 806f27bbd1166b4d71a8eddab5180b9b33459eb8 Mon Sep 17 00:00:00 2001 From: JennyNou <167806377+JennyNou@users.noreply.github.com> Date: Tue, 10 Mar 2026 13:41:58 -0400 Subject: [PATCH] Update flow to cover essential and advanced clients --- .../pages/PolicyHolderDetailsPage.ts | 47 ++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/playwright-tests/pages/PolicyHolderDetailsPage.ts b/playwright-tests/pages/PolicyHolderDetailsPage.ts index 47f11031..d37ba9cb 100644 --- a/playwright-tests/pages/PolicyHolderDetailsPage.ts +++ b/playwright-tests/pages/PolicyHolderDetailsPage.ts @@ -5,16 +5,59 @@ import { AddressForm } from './forms/AddressForm'; export class PolicyHolderDetailsPage extends BasePage { readonly page: Page; - readonly addressForm: AddressForm; + readonly firstNameTextBox: Locator; + readonly lastNameTextBox: Locator; + readonly addressForm: AddressForm; // double check if this is used for advanced flows ? + readonly addressInputBox: Locator; + readonly emailAddressTextBox: Locator; + readonly issPageValue = 'policy-holder-details'; constructor(page: Page) { super(page); this.page = page; + this.firstNameTextBox = page.locator('#firstNameField'); + this.lastNameTextBox = page.locator('#lastNameField'); this.addressForm = new AddressForm(page); + this.emailAddressTextBox = page.locator('#emailField'); + this.addressInputBox = page.locator('input[name="autocomplete"]'); // for essential flows } async fillCustomerDetails(customerDetails: ICustomerDetails){ - await this.addressForm.populateAddress(customerDetails); + // Check if firstName field is empty, then fill it + const firstNameValue = await this.firstNameTextBox.inputValue(); + if (!firstNameValue || firstNameValue.trim() === '') { + if (customerDetails.firstName) { + await this.firstNameTextBox.fill(customerDetails.firstName); + } + } + + // Check if lastName field is empty, then fill it + const lastNameValue = await this.lastNameTextBox.inputValue(); + if (!lastNameValue || lastNameValue.trim() === '') { + if (customerDetails.lastName) { + await this.lastNameTextBox.fill(customerDetails.lastName); + } + } + + // Fill email address for both essential and advanced flows + await this.emailAddressTextBox.fill(customerDetails.email); + + const addressValue = await this.addressInputBox.inputValue(); + + // For essential flows, when address fields are not pre-filled + if (!addressValue || addressValue.trim() === '') { + await this.addressInputBox.click(); + await this.addressInputBox.fill(customerDetails.address.street); + + // Wait for suggestions to load (Google Places has a slight delay) + await this.page.locator('.pac-item').first().waitFor({ state: 'visible', timeout: 5000 }); + + // Click the first result + await this.page.locator('.pac-item').first().click(); + + // Optional: wait for the input to be populated by Google Places + await this.addressInputBox.waitFor({ state: 'attached' }); + } } } \ No newline at end of file