Update flow to cover essential and advanced clients
This commit is contained in:
parent
92f15d5019
commit
806f27bbd1
1 changed files with 45 additions and 2 deletions
|
|
@ -5,16 +5,59 @@ import { AddressForm } from './forms/AddressForm';
|
||||||
|
|
||||||
export class PolicyHolderDetailsPage extends BasePage {
|
export class PolicyHolderDetailsPage extends BasePage {
|
||||||
readonly page: Page;
|
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';
|
readonly issPageValue = 'policy-holder-details';
|
||||||
|
|
||||||
constructor(page: Page) {
|
constructor(page: Page) {
|
||||||
super(page);
|
super(page);
|
||||||
this.page = page;
|
this.page = page;
|
||||||
|
this.firstNameTextBox = page.locator('#firstNameField');
|
||||||
|
this.lastNameTextBox = page.locator('#lastNameField');
|
||||||
this.addressForm = new AddressForm(page);
|
this.addressForm = new AddressForm(page);
|
||||||
|
this.emailAddressTextBox = page.locator('#emailField');
|
||||||
|
this.addressInputBox = page.locator('input[name="autocomplete"]'); // for essential flows
|
||||||
}
|
}
|
||||||
|
|
||||||
async fillCustomerDetails(customerDetails: ICustomerDetails){
|
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' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue