Skip to content

Commit

Permalink
MLPAB-2385 stop setting paper channel donors CPs relationship to prof…
Browse files Browse the repository at this point in the history
…essional
  • Loading branch information
acsauk committed Dec 18, 2024
1 parent 8b3bb89 commit 6c959a0
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 22 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/certificate-provider/confirm-your-details.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ describe('Confirm your details', () => {

cy.contains('Contact number').should('not.exist');
cy.contains('Mobile number').should('not.exist');
cy.contains('If you notice a mistake in the name, work address or mobile number the donor provided').should('not.exist');
cy.contains('If you notice a mistake in the name, address or mobile number the donor provided').should('not.exist');

cy.contains('If you notice a mistake in the name or work address the donor provided').should('exist');
cy.contains('If you notice a mistake in the name or address the donor provided').should('exist');
})
})
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type confirmYourDetailsData struct {
AddressLabel string
DetailComponentContent string
ShowPhone bool
ShowHomeAddress bool
}

func ConfirmYourDetails(tmpl template.Template, certificateProviderStore CertificateProviderStore) Handler {
Expand Down Expand Up @@ -48,6 +49,7 @@ func ConfirmYourDetails(tmpl template.Template, certificateProviderStore Certifi
AddressLabel: "address",
DetailComponentContent: "whatToDoIfAnyDetailsAreIncorrectCertificateProviderContentLay",
ShowPhone: lpa.CertificateProvider.Phone != "",
ShowHomeAddress: lpa.Donor.Channel.IsPaper() || lpa.CertificateProvider.Relationship.IsProfessionally(),
}

if !data.ShowPhone {
Expand All @@ -56,9 +58,7 @@ func ConfirmYourDetails(tmpl template.Template, certificateProviderStore Certifi

if lpa.Donor.Channel.IsPaper() {
data.PhoneNumberLabel = "contactNumber"
}

if lpa.CertificateProvider.Relationship.IsProfessionally() {
} else if lpa.CertificateProvider.Relationship.IsProfessionally() {
data.AddressLabel = "workAddress"
data.DetailComponentContent = "whatToDoIfAnyDetailsAreIncorrectCertificateProviderContentProfessional"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestGetConfirmYourDetails(t *testing.T) {
AddressLabel string
DetailsComponentContent string
ShowPhone bool
ShowHomeAddress bool
PhoneNumber string
}{
"online donor": {
Expand All @@ -39,6 +40,7 @@ func TestGetConfirmYourDetails(t *testing.T) {
DetailsComponentContent: "whatToDoIfAnyDetailsAreIncorrectCertificateProviderContentLay",
PhoneNumber: "123",
ShowPhone: true,
ShowHomeAddress: true,
},
"lay CP": {
CertificateProviderRelationship: lpadata.Personally,
Expand All @@ -55,6 +57,7 @@ func TestGetConfirmYourDetails(t *testing.T) {
PhoneNumberLabel: "mobileNumber",
PhoneNumber: "123",
ShowPhone: true,
ShowHomeAddress: true,
},
"missing phone": {
CertificateProviderRelationship: lpadata.Personally,
Expand All @@ -67,6 +70,7 @@ func TestGetConfirmYourDetails(t *testing.T) {
AddressLabel: "workAddress",
DetailsComponentContent: "whatToDoIfAnyDetailsAreIncorrectCertificateProviderContentProfessionalMissingPhone",
PhoneNumberLabel: "mobileNumber",
ShowHomeAddress: true,
},
}

Expand Down Expand Up @@ -94,6 +98,7 @@ func TestGetConfirmYourDetails(t *testing.T) {
AddressLabel: tc.AddressLabel,
DetailComponentContent: tc.DetailsComponentContent,
ShowPhone: tc.ShowPhone,
ShowHomeAddress: tc.ShowHomeAddress,
}).
Return(nil)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func EnterDateOfBirth(tmpl template.Template, certificateProviderStore Certifica
return err
}

if lpa.CertificateProvider.Relationship.IsProfessionally() {
if lpa.Donor.Channel.IsPaper() || lpa.CertificateProvider.Relationship.IsProfessionally() {
return certificateprovider.PathWhatIsYourHomeAddress.Redirect(w, r, appData, certificateProvider.LpaID)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,37 @@ func TestPostEnterDateOfBirthWhenProfessionalCertificateProvider(t *testing.T) {
assert.Equal(t, certificateprovider.PathWhatIsYourHomeAddress.Format("lpa-id"), resp.Header.Get("Location"))
}

func TestPostEnterDateOfBirthWhenPaperDonor(t *testing.T) {
w := httptest.NewRecorder()

form := url.Values{
"date-of-birth-day": {"2"},
"date-of-birth-month": {"1"},
"date-of-birth-year": {"1980"},
}

r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode()))
r.Header.Add("Content-Type", page.FormUrlEncoded)

certificateProviderStore := newMockCertificateProviderStore(t)
certificateProviderStore.EXPECT().
Put(r.Context(), &certificateproviderdata.Provided{
LpaID: "lpa-id",
DateOfBirth: date.New("1980", "1", "2"),
Tasks: certificateproviderdata.Tasks{
ConfirmYourDetails: task.StateInProgress,
},
}).
Return(nil)

err := EnterDateOfBirth(nil, certificateProviderStore)(testAppData, w, r, &certificateproviderdata.Provided{LpaID: "lpa-id"}, &lpadata.Lpa{LpaID: "lpa-id", Donor: lpadata.Donor{Channel: lpadata.ChannelPaper}})
resp := w.Result()

assert.Nil(t, err)
assert.Equal(t, http.StatusFound, resp.StatusCode)
assert.Equal(t, certificateprovider.PathWhatIsYourHomeAddress.Format("lpa-id"), resp.Header.Get("Location"))
}

func TestPostEnterDateOfBirthWhenInputRequired(t *testing.T) {
validBirthYear := strconv.Itoa(time.Now().Year() - 40)

Expand Down
3 changes: 0 additions & 3 deletions internal/lpastore/resolving_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ func (s *ResolvingService) merge(lpa *lpadata.Lpa, donor *donordata.Provided) *l
lpa.Drafted = true
lpa.Submitted = true
lpa.Paid = true
// set to Professionally so we always show the certificate provider home
// address question
lpa.CertificateProvider.Relationship = lpadata.Professionally
lpa.Donor.Channel = lpadata.ChannelPaper
} else {
lpa.Drafted = donor.Tasks.CheckYourLpa.IsCompleted()
Expand Down
15 changes: 3 additions & 12 deletions internal/lpastore/resolving_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,7 @@ func TestResolvingServiceGet(t *testing.T) {
Submitted: true,
Drafted: true,
Paid: true,
CertificateProvider: lpadata.CertificateProvider{
Relationship: lpadata.Professionally,
},
Donor: lpadata.Donor{Channel: lpadata.ChannelPaper},
Donor: lpadata.Donor{Channel: lpadata.ChannelPaper},
},
},
"voucher not allowed": {
Expand Down Expand Up @@ -412,10 +409,7 @@ func TestResolvingServiceResolve(t *testing.T) {
Drafted: true,
Submitted: true,
Paid: true,
CertificateProvider: lpadata.CertificateProvider{
Relationship: lpadata.Professionally,
},
Donor: lpadata.Donor{Channel: lpadata.ChannelPaper},
Donor: lpadata.Donor{Channel: lpadata.ChannelPaper},
},
},
}
Expand Down Expand Up @@ -573,10 +567,7 @@ func TestResolvingServiceResolveList(t *testing.T) {
Drafted: true,
Submitted: true,
Paid: true,
CertificateProvider: lpadata.CertificateProvider{
Relationship: lpadata.Professionally,
},
Donor: lpadata.Donor{Channel: lpadata.ChannelPaper},
Donor: lpadata.Donor{Channel: lpadata.ChannelPaper},
}},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{{ $dateOfBirthChangeLink := printf "%s?from=%s#f-date-of-birth" (link .App (global.Paths.CertificateProvider.EnterDateOfBirth.Format .Lpa.LpaID)) .App.Page }}
{{ template "summary-row" (summaryRow $.App "dateOfBirth" (formatDate .App .CertificateProvider.DateOfBirth) $dateOfBirthChangeLink .Lpa.CertificateProvider.FullName true true ) }}

{{ if .Lpa.CertificateProvider.Relationship.IsProfessionally }}
{{ if .ShowHomeAddress }}
{{ $homeAddressChangeLink := printf "%s?from=%s#f-address-line-1" (link .App (global.Paths.CertificateProvider.WhatIsYourHomeAddress.Format .Lpa.LpaID)) .App.Page }}
{{ template "address-summary-row" (summaryRow $.App "homeAddress" .CertificateProvider.HomeAddress $homeAddressChangeLink .Lpa.CertificateProvider.FullName true true ) }}
{{ end }}
Expand Down

0 comments on commit 6c959a0

Please sign in to comment.