Skip to content

Commit

Permalink
feat: add autofill for policy holder legal person
Browse files Browse the repository at this point in the history
  • Loading branch information
Giulia Ye committed Jul 31, 2024
1 parent 08d8c87 commit 33875af
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/lib/pages/life/beneficiariesPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class BeneficiariesPage extends Page {

if (this.isNamedBeneficiaryLegalPersonDialogOpen()) {
this.changeInputValue(this.businessName, "Pinco Pallino SRL");
this.changeInputValue(this.vatNumber, "01234567890");
this.changeInputValue(this.vatNumber, "34926370544");
this.changeInputValue(this.atecoCode, "81.21");
this.changeInputValue(this.businessPhone, FakeDataService.phone());
this.changeInputValue(this.businessEmail, FakeDataService.email());
Expand Down
72 changes: 60 additions & 12 deletions src/lib/pages/life/checkoutPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,31 @@ import Page from "../page";
export default class CheckoutPage extends Page {
public static path: string = "checkout";

private documentType = "input[name='insured.document.type']";
private documentCode = "input[name='insured.document.code']";
private documentReleaseDate = "input[name='insured.document.releaseDate']";
private documentExpirationDate = "input[name='insured.document.expireDate']";
private documentReleasePlace = "input[name='insured.document.releasePlace']";
private documentReleaseAuthority =
private insuredDocumentType = "input[name='insured.document.type']";
private insuredDocumentCode = "input[name='insured.document.code']";
private insuredDocumentReleaseDate =
"input[name='insured.document.releaseDate']";
private insuredDocumentExpirationDate =
"input[name='insured.document.expireDate']";
private insuredDocumentReleasePlace =
"input[name='insured.document.releasePlace']";
private insuredDocumentReleaseAuthority =
"input[name='insured.document.releaseAuthority']";

//policy holder legal person
private policyHolderLegalPersonDocumentType =
"input[name='policyHolder.legalRepresentative.document.type']";
private policyHolderLegalPersonDocumentCode =
"input[name='policyHolder.legalRepresentative.document.code']";
private policyHolderLegalPersonDocumentReleaseDate =
"input[name='policyHolder.legalRepresentative.document.releaseDate']";
private policyHolderLegalPersonDocumentExpirationDate =
"input[name='policyHolder.legalRepresentative.document.expireDate']";
private policyHolderLegalPersonDocumentReleasePlace =
"input[name='policyHolder.legalRepresentative.document.releasePlace']";
private policyHolderLegalPersonDocumentReleaseAuthority =
"input[name='policyHolder.legalRepresentative.document.releaseAuthority']";

private medicalExams =
"//div[@data-testid='question-wantsToDoMedicalExam']//button[2]";

Expand All @@ -31,12 +48,15 @@ export default class CheckoutPage extends Page {
"//div[@data-testid='question-compliance.confirmObligations']//button";

async autofill(): Promise<void> {
this.changeInputValue(this.documentType, "PASSPORT");
this.changeInputValue(this.documentCode, "ASD123");
this.changeInputValue(this.documentReleaseDate, "01/01/2020");
this.changeInputValue(this.documentExpirationDate, "01/01/2030");
this.changeInputValue(this.documentReleasePlace, FakeDataService.city());
this.changeInputValue(this.documentReleaseAuthority, "PREFECTURE");
this.changeInputValue(this.insuredDocumentType, "PASSPORT");
this.changeInputValue(this.insuredDocumentCode, "ASD123");
this.changeInputValue(this.insuredDocumentReleaseDate, "01/01/2020");
this.changeInputValue(this.insuredDocumentExpirationDate, "01/01/2030");
this.changeInputValue(
this.insuredDocumentReleasePlace,
FakeDataService.city(),
);
this.changeInputValue(this.insuredDocumentReleaseAuthority, "PREFECTURE");
this.clickWithXpath(this.medicalExams);
this.changeInputValue(this.iban, "IT87D0300203280616976634975");
this.clickWithXpath(this.isAccountHolder);
Expand All @@ -45,5 +65,33 @@ export default class CheckoutPage extends Page {
this.clickWithXpath(this.privacyPolicyExtended);
this.clickWithXpath(this.otherPolicies);
this.clickWithXpath(this.confirmObligations);

if (this.isPolicyHolderLegalPerson()) {
this.changeInputValue(
this.policyHolderLegalPersonDocumentType,
"PASSPORT",
);
this.changeInputValue(this.policyHolderLegalPersonDocumentCode, "ASD123");
this.changeInputValue(
this.policyHolderLegalPersonDocumentReleaseDate,
"01/01/2020",
);
this.changeInputValue(
this.policyHolderLegalPersonDocumentExpirationDate,
"01/01/2030",
);
this.changeInputValue(
this.policyHolderLegalPersonDocumentReleasePlace,
FakeDataService.city(),
);
this.changeInputValue(
this.policyHolderLegalPersonDocumentReleaseAuthority,
"PREFECTURE",
);
}
}

isPolicyHolderLegalPerson() {
return !!this.getInput(this.policyHolderLegalPersonDocumentCode);
}
}
185 changes: 158 additions & 27 deletions src/lib/pages/life/personalDataPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,167 @@ import Page from "../page";
export default class PersonalDataPage extends Page {
public static path: string = "dati-personali";

private birthCity = "input[name='insured.cityOfBirth']";
private gender = "input[name='insured.gender']";

private job = "input[name='insured.profession']";
private maritalStatus = "input[name='insured.maritalStatus']";
private familyUnitType = "input[name='insured.familyUnitType']";
private isPoliticallExposed =
// Insured
private insuredName = "input[name$='insured.name']";
private insuredSurname = "input[name$='insured.surname']";
private insuredEmail = "input[name$='insured.email']";
private insuredPhone = "input[name$='insured.phone']";
private insuredBirthCity = "input[name='insured.cityOfBirth']";
private insuredGender = "input[name='insured.gender']";
private insuredJob = "input[name='insured.profession']";
private insuredMaritalStatus = "input[name='insured.maritalStatus']";
private insuredFamilyUnitType = "input[name='insured.familyUnitType']";
private insuredIsPoliticallExposed =
"//div[@data-testid='question-insured.isPoliticallyExposedAndHasAdministrativeResponsibility']//button[2]";
private allInfoViaEmail =
private insuredAllInfoViaEmail =
"//div[@data-testid='question-insured.allCommunicationsByEmail']//button";
private street = "input[name='insured.residence.address.street']";
private streetNumber = "input[name='insured.residence.address.streetNumber']";
private postalCode = "input[name='insured.residence.address.postalCode']";
private city = "input[name='insured.residence.city.name']";
private province = "input[name='insured.residence.province.name']";
private state = "input[name='insured.residence.state.name']";
private insuredStreet = "input[name='insured.residence.address.street']";
private insuredStreetNumber =
"input[name='insured.residence.address.streetNumber']";
private insuredPostalCode =
"input[name='insured.residence.address.postalCode']";
private insuredCity = "input[name='insured.residence.city.name']";
private insuredProvince = "input[name='insured.residence.province.name']";
private insuredState = "input[name='insured.residence.state.name']";

// policy holder legal person
private businessName = "input[name$=businessName]";
private vatNumber = "input[name$=vatNumber]";
private atecoCode = "input[name$=atecoCode]";
private businessPhone = "input[name$=businessPhone]";
private businessEmail = "input[name$=businessEmail]";
private registeredOfficeStreet =
"input[name$='registeredOffice.address.street']";
private registeredOfficeStreetNumber =
"input[name$='registeredOffice.address.streetNumber']";
private registeredOfficePostalCode =
"input[name$='registeredOffice.address.postalCode']";
private registeredOfficeCity = "input[name$='registeredOffice.city.name']";
private registeredOfficeProvince =
"input[name$='registeredOffice.province.name']";
private registeredOfficeState = "input[name$='registeredOffice.state.name']";
private legalRepresentativeName = "input[name$='legalRepresentative.name']";
private legalRepresentativeSurname =
"input[name$='legalRepresentative.surname']";
private legalRepresentativeEmail = "input[name$='legalRepresentative.email']";
private legalRepresentativePhone = "input[name$='legalRepresentative.phone']";
private legalRepresentativeBirthDate =
"input[name$='legalRepresentative.birthDate']";
private legalRepresentativeCityOfBirth =
"input[name$='legalRepresentative.cityOfBirth']";
private legalRepresentativeGender =
"input[name$='legalRepresentative.gender']";
private legalRepresentativeRelationship =
"input[name$='legalRepresentative.relationship']";
private legalRepresentativeIsPoliticallyExposed =
"//div[contains(@data-testid, 'legalRepresentative.isPoliticallyExposedAndHasAdministrativeResponsibility')]//button[2]";
private legalRepresentativeAllCommunicationsByEmail =
"//div[contains(@data-testid, 'legalRepresentative.allCommunicationsByEmail')]//button[2]";
private legalRepresentativeResidenceStreet =
"input[name$='legalRepresentative.residence.address.street']";
private legalRepresentativeResidenceStreetNumber =
"input[name$='legalRepresentative.residence.address.streetNumber']";
private legalRepresentativeResidencePostalCode =
"input[name$='legalRepresentative.residence.address.postalCode']";
private legalRepresentativeResidenceCity =
"input[name$='legalRepresentative.residence.city.name']";
private legalRepresentativeResidenceProvince =
"input[name$='legalRepresentative.residence.province.name']";
private legalRepresentativeResidenceState =
"input[name$='legalRepresentative.residence.state.name']";

async autofill(): Promise<void> {
this.changeInputValue(this.birthCity, FakeDataService.city());
this.changeInputValue(this.gender, "MALE");
this.changeInputValue(this.job, "LIVESTOCK_BREEDER");
this.changeInputValue(this.maritalStatus, "SINGLE");
this.changeInputValue(this.familyUnitType, "SINGLE");
this.clickWithXpath(this.isPoliticallExposed);
this.clickWithXpath(this.allInfoViaEmail);
this.changeInputValue(this.street, FakeDataService.street());
this.changeInputValue(this.streetNumber, "99");
this.changeInputValue(this.postalCode, "20100");
this.changeInputValue(this.city, "Milano");
this.changeInputValue(this.province, "MI");
this.changeInputValue(this.state, "Italia");
this.changeInputValue(this.insuredBirthCity, FakeDataService.city());
this.changeInputValue(this.insuredGender, "MALE");
this.changeInputValue(this.insuredJob, "LIVESTOCK_BREEDER");
this.changeInputValue(this.insuredMaritalStatus, "SINGLE");
this.changeInputValue(this.insuredFamilyUnitType, "SINGLE");
this.clickWithXpath(this.insuredIsPoliticallExposed);
this.clickWithXpath(this.insuredAllInfoViaEmail);
this.changeInputValue(this.insuredStreet, FakeDataService.street());
this.changeInputValue(this.insuredStreetNumber, "99");
this.changeInputValue(this.insuredPostalCode, "20100");
this.changeInputValue(this.insuredCity, "Milano");
this.changeInputValue(this.insuredProvince, "MI");
this.changeInputValue(this.insuredState, "Italia");

if (this.isPolicyHolderLegalPerson()) {
this.changeInputValue(this.businessName, "Pinco Pallino SRL");
this.changeInputValue(this.vatNumber, "34926370544");
this.changeInputValue(this.atecoCode, "81.21");
this.changeInputValue(this.businessPhone, FakeDataService.phone());
this.changeInputValue(this.businessEmail, FakeDataService.email());

this.changeInputValue(
this.registeredOfficeStreet,
FakeDataService.street(),
);
this.changeInputValue(this.registeredOfficeStreetNumber, "99");
this.changeInputValue(this.registeredOfficePostalCode, "20100");
this.changeInputValue(this.registeredOfficeCity, "Milano");
this.changeInputValue(this.registeredOfficeProvince, "MI");
this.changeInputValue(this.registeredOfficeState, "Italia");

this.changeInputValue(
this.legalRepresentativeName,
FakeDataService.firstName(),
);
this.changeInputValue(
this.legalRepresentativeSurname,
FakeDataService.lastName(),
);
this.changeInputValue(
this.legalRepresentativePhone,
FakeDataService.phone(),
);
this.changeInputValue(
this.legalRepresentativeEmail,
FakeDataService.email(),
);
this.changeInputValue(
this.legalRepresentativeBirthDate,
FakeDataService.birthdate(74),
);
this.changeInputValue(
this.legalRepresentativeCityOfBirth,
FakeDataService.city(),
);
this.changeInputValue(this.legalRepresentativeGender, "MALE");
this.changeInputValue(this.legalRepresentativeRelationship, "EMPLOYER");
this.clickWithXpath(this.legalRepresentativeIsPoliticallyExposed);
this.clickWithXpath(this.legalRepresentativeAllCommunicationsByEmail);
this.changeInputValue(
this.legalRepresentativeResidenceStreet,
FakeDataService.street(),
);
this.changeInputValue(
this.legalRepresentativeResidenceStreetNumber,
"99",
);
this.changeInputValue(
this.legalRepresentativeResidencePostalCode,
"20100",
);
this.changeInputValue(this.legalRepresentativeResidenceCity, "Milano");
this.changeInputValue(this.legalRepresentativeResidenceProvince, "MI");
this.changeInputValue(this.legalRepresentativeResidenceState, "Italia");

await this.withDelay(() => {
this.changeInputValue(this.insuredName, FakeDataService.firstName());
});
await this.withDelay(() => {
this.changeInputValue(this.insuredSurname, FakeDataService.lastName());
});
await this.withDelay(() => {
this.changeInputValue(this.insuredEmail, FakeDataService.email());
});
await this.withDelay(() => {
this.changeInputValue(this.insuredPhone, FakeDataService.phone());
});
}
}

isPolicyHolderLegalPerson() {
return !!this.getInput(this.businessName);
}
}

0 comments on commit 33875af

Please sign in to comment.