Skip to content

Fixing demo e2e locally for applicant

toireasam edited this page Apr 16, 2020 · 10 revisions

Applicant e2e fails for demo if reference data doesn't populate the address. if you want to fix this locally to pass the e2e you can change the following files:

in enterApplicantEventPage.js, change the below method enterApplicantDetails to populate the address (instead of ref data)

enterApplicantDetails(applicant) {
  const elementIndex = 0;

  I.fillField(this.fields(elementIndex).applicant.name, applicant.name);
  I.fillField(this.fields(elementIndex).applicant.pbaNumber, applicant.pbaNumber);
  I.fillField(this.fields(elementIndex).applicant.clientCode, applicant.clientCode);
  I.fillField(this.fields(elementIndex).applicant.customerReference, applicant.customerReference);
  within(this.fields(elementIndex).applicant.address, async function() {
    async  function getNumberOfElements() {
      return await I.grabNumberOfVisibleElements(locate('a').withText('I can\'t enter a UK postcode'))
    };
    
    const numOfElements = await getNumberOfElements(elementIndex);
    
    if(numOfElements === 1) {
      postcodeLookup.enterAddressManually(applicant.address);
    }
  });
  
  I.fillField(this.fields(elementIndex).applicant.telephone, applicant.telephoneNumber);
  I.fillField(this.fields(elementIndex).applicant.nameOfPersonToContact, applicant.nameOfPersonToContact);
  I.fillField(this.fields(elementIndex).applicant.mobileNumber, applicant.mobileNumber);
  I.fillField(this.fields(elementIndex).applicant.jobTitle, applicant.jobTitle);
  I.fillField(this.fields(elementIndex).applicant.email, applicant.email);
}

NOTE: you will need to update the applicant fixture to ensure it has all of the fields that's populated in enterAddressManually method