Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLPAB-1381: Replace flow to print evidence form with email and post guidance #733

Merged
merged 3 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions internal/app/donor_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,25 +171,6 @@ func (s *donorStore) Put(ctx context.Context, lpa *page.Lpa) error {
}
}

if lpa.UID != "" && lpa.EvidenceFormAddress.Line1 != "" && !lpa.HasSentEvidenceFormRequiredEvent {
if err := s.eventClient.Send(ctx, "evidence-form-required", evidenceFormRequiredEvent{
UID: lpa.UID,
FirstNames: lpa.Donor.FirstNames,
LastName: lpa.Donor.LastName,
Address: address{
Line1: lpa.EvidenceFormAddress.Line1,
Line2: lpa.EvidenceFormAddress.Line2,
Line3: lpa.EvidenceFormAddress.Line3,
TownOrCity: lpa.EvidenceFormAddress.TownOrCity,
Postcode: lpa.EvidenceFormAddress.Postcode,
},
}); err != nil {
s.logger.Print(err)
} else {
lpa.HasSentEvidenceFormRequiredEvent = true
}
}

if lpa.UID != "" && lpa.Tasks.PayForLpa.IsPending() && lpa.HasUnsentReducedFeesEvidence() {
var unsentKeys []string

Expand Down
121 changes: 0 additions & 121 deletions internal/app/donor_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,127 +453,6 @@ func TestDonorStorePutWhenPreviousApplicationLinkedWhenError(t *testing.T) {
assert.Nil(t, err)
}

func TestDonorStorePutWhenEvidenceFormRequired(t *testing.T) {
ctx := context.Background()
now := time.Now()

dynamoClient := newMockDynamoClient(t)
dynamoClient.
On("Put", ctx, &page.Lpa{
PK: "LPA#5",
SK: "#DONOR#an-id",
ID: "5",
UID: "M-1111",
UpdatedAt: now,
Donor: actor.Donor{
FirstNames: "John",
LastName: "Smithe",
},
EvidenceFormAddress: place.Address{
Line1: "line1",
Line2: "line2",
Line3: "line3",
TownOrCity: "town",
Postcode: "post",
},
HasSentApplicationUpdatedEvent: true,
HasSentEvidenceFormRequiredEvent: true,
}).
Return(nil)

eventClient := newMockEventClient(t)
eventClient.
On("Send", ctx, "evidence-form-required", evidenceFormRequiredEvent{
UID: "M-1111",
FirstNames: "John",
LastName: "Smithe",
Address: address{
Line1: "line1",
Line2: "line2",
Line3: "line3",
TownOrCity: "town",
Postcode: "post",
},
}).
Return(nil)

donorStore := &donorStore{dynamoClient: dynamoClient, eventClient: eventClient, now: func() time.Time { return now }}

err := donorStore.Put(ctx, &page.Lpa{
PK: "LPA#5",
SK: "#DONOR#an-id",
ID: "5",
UID: "M-1111",
Donor: actor.Donor{
FirstNames: "John",
LastName: "Smithe",
},
EvidenceFormAddress: place.Address{
Line1: "line1",
Line2: "line2",
Line3: "line3",
TownOrCity: "town",
Postcode: "post",
},
HasSentApplicationUpdatedEvent: true,
})
assert.Nil(t, err)
}

func TestDonorStorePutWhenEvidenceFormRequiredWontResend(t *testing.T) {
ctx := context.Background()
now := time.Now()

dynamoClient := newMockDynamoClient(t)
dynamoClient.
On("Put", ctx, mock.Anything).
Return(nil)

donorStore := &donorStore{dynamoClient: dynamoClient, now: func() time.Time { return now }}

err := donorStore.Put(ctx, &page.Lpa{
PK: "LPA#5",
SK: "#DONOR#an-id",
ID: "5",
UID: "M-1111",
EvidenceFormAddress: place.Address{Line1: "line"},
HasSentApplicationUpdatedEvent: true,
HasSentEvidenceFormRequiredEvent: true,
})
assert.Nil(t, err)
}

func TestDonorStorePutWhenEvidenceFormRequiredWhenError(t *testing.T) {
ctx := context.Background()
now := time.Now()

dynamoClient := newMockDynamoClient(t)
dynamoClient.
On("Put", ctx, mock.Anything).
Return(nil)

eventClient := newMockEventClient(t)
eventClient.
On("Send", ctx, "evidence-form-required", mock.Anything).
Return(expectedError)

logger := newMockLogger(t)
logger.
On("Print", expectedError)

donorStore := &donorStore{dynamoClient: dynamoClient, eventClient: eventClient, logger: logger, now: func() time.Time { return now }}

err := donorStore.Put(ctx, &page.Lpa{
PK: "LPA#5",
SK: "#DONOR#an-id",
ID: "5",
UID: "M-1111",
EvidenceFormAddress: place.Address{Line1: "line"},
HasSentApplicationUpdatedEvent: true,
})
assert.Nil(t, err)
}

func TestDonorStorePutWhenReducedFeeRequested(t *testing.T) {
ctx := context.Background()
now := time.Now()
Expand Down
1 change: 0 additions & 1 deletion internal/page/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ type Lpa struct {

HasSentApplicationUpdatedEvent bool
HasSentPreviousApplicationLinkedEvent bool
HasSentEvidenceFormRequiredEvent bool
}

type Evidence struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/page/donor/can_evidence_be_uploaded.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func CanEvidenceBeUploaded(tmpl template.Template) Handler {
if form.YesNo.IsYes() {
return appData.Redirect(w, r, lpa, page.Paths.UploadEvidence.Format(lpa.ID))
} else {
return appData.Redirect(w, r, lpa, page.Paths.PrintEvidenceForm.Format(lpa.ID))
return appData.Redirect(w, r, lpa, page.Paths.HowToEmailOrPostEvidence.Format(lpa.ID))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/page/donor/can_evidence_be_uploaded_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestGetCanEvidenceBeUploadedWhenTemplateErrors(t *testing.T) {
func TestPostCanEvidenceBeUploaded(t *testing.T) {
testcases := map[form.YesNo]page.LpaPath{
form.Yes: page.Paths.UploadEvidence,
form.No: page.Paths.PrintEvidenceForm,
form.No: page.Paths.HowToEmailOrPostEvidence,
}

for yesNo, redirect := range testcases {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (
"github.com/ministryofjustice/opg-modernising-lpa/internal/validation"
)

type howToSendEvidenceData struct {
type howToEmailOrPostEvidenceData struct {
App page.AppData
Errors validation.List
}

func HowToSendEvidence(tmpl template.Template, payer Payer) Handler {
func HowToEmailOrPostEvidence(tmpl template.Template, payer Payer) Handler {
return func(appData page.AppData, w http.ResponseWriter, r *http.Request, lpa *page.Lpa) error {
data := &howToSendEvidenceData{
data := &howToEmailOrPostEvidenceData{
App: appData,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,39 @@ import (
"github.com/stretchr/testify/mock"
)

func TestGetHowToSendEvidence(t *testing.T) {
func TestGetHowToEmailOrPostEvidence(t *testing.T) {
w := httptest.NewRecorder()
r, _ := http.NewRequest(http.MethodGet, "/about-payment", nil)

template := newMockTemplate(t)
template.
On("Execute", w, &howToSendEvidenceData{App: testAppData}).
On("Execute", w, &howToEmailOrPostEvidenceData{App: testAppData}).
Return(nil)

err := HowToSendEvidence(template.Execute, nil)(testAppData, w, r, &page.Lpa{})
err := HowToEmailOrPostEvidence(template.Execute, nil)(testAppData, w, r, &page.Lpa{})
resp := w.Result()

assert.Nil(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
}

func TestGetHowToSendEvidenceWhenTemplateErrors(t *testing.T) {
func TestGetHowToEmailOrPostEvidenceWhenTemplateErrors(t *testing.T) {
w := httptest.NewRecorder()
r, _ := http.NewRequest(http.MethodGet, "/about-payment", nil)

template := newMockTemplate(t)
template.
On("Execute", w, &howToSendEvidenceData{App: testAppData}).
On("Execute", w, &howToEmailOrPostEvidenceData{App: testAppData}).
Return(expectedError)

err := HowToSendEvidence(template.Execute, nil)(testAppData, w, r, &page.Lpa{})
err := HowToEmailOrPostEvidence(template.Execute, nil)(testAppData, w, r, &page.Lpa{})
resp := w.Result()

assert.Equal(t, expectedError, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
}

func TestPostHowToSendEvidence(t *testing.T) {
func TestPostHowToEmailOrPostEvidence(t *testing.T) {
w := httptest.NewRecorder()
r, _ := http.NewRequest(http.MethodPost, "/about-payment", nil)

Expand All @@ -54,11 +54,11 @@ func TestPostHowToSendEvidence(t *testing.T) {
On("Pay", testAppData, w, r, lpa).
Return(nil)

err := HowToSendEvidence(nil, payer)(testAppData, w, r, lpa)
err := HowToEmailOrPostEvidence(nil, payer)(testAppData, w, r, lpa)
assert.Nil(t, err)
}

func TestPostHowToSendEvidenceWhenPayerErrors(t *testing.T) {
func TestPostHowToEmailOrPostEvidenceWhenPayerErrors(t *testing.T) {
w := httptest.NewRecorder()
r, _ := http.NewRequest(http.MethodPost, "/about-payment", nil)

Expand All @@ -67,6 +67,6 @@ func TestPostHowToSendEvidenceWhenPayerErrors(t *testing.T) {
On("Pay", testAppData, w, r, mock.Anything).
Return(expectedError)

err := HowToSendEvidence(nil, payer)(testAppData, w, r, &page.Lpa{})
err := HowToEmailOrPostEvidence(nil, payer)(testAppData, w, r, &page.Lpa{})
assert.Equal(t, expectedError, err)
}
84 changes: 0 additions & 84 deletions internal/page/donor/provide_address_to_send_evidence_form.go

This file was deleted.

Loading
Loading