Skip to content

Commit

Permalink
MLPAB-1886 Add page to check details before sending to voucher (#1311)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx authored Jun 26, 2024
1 parent 3789bb9 commit 7036691
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 8 deletions.
15 changes: 15 additions & 0 deletions cypress/e2e/donor/check-your-details.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe('Check your details', () => {
beforeEach(() => {
cy.visit('/fixtures?redirect=/check-your-details&progress=payForTheLpa');
});

it('shows my details', () => {
cy.checkA11yApp();
cy.contains('Sam Smith');
cy.contains('2 January 2000');
cy.contains('1 RICHMOND PLACE');
cy.contains('a', 'Continue').click();

cy.url().should('contain', '/task-list');
});
});
2 changes: 1 addition & 1 deletion cypress/e2e/donor/confirm-person-allowed-to-vouch.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Enter voucher', () => {
cy.get('input[name=yes-no]').check('yes');
cy.contains('button', 'Save and continue').click();

cy.url().should('contain', '/task-list');
cy.url().should('contain', '/check-your-details');
});

it('can select another', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/donor/enter-voucher.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Enter voucher', () => {
cy.get('#f-email').type('[email protected]');
cy.contains('button', 'Save and continue').click();

cy.url().should('contain', '/task-list');
cy.url().should('contain', '/check-your-details');
});

it('errors when empty', () => {
Expand Down
2 changes: 1 addition & 1 deletion internal/page/donor/confirm_person_allowed_to_vouch.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func ConfirmPersonAllowedToVouch(tmpl template.Template, donorStore DonorStore)
var redirect page.LpaPath
if data.Form.YesNo.IsYes() {
donor.Voucher.Allowed = true
redirect = page.Paths.TaskList
redirect = page.Paths.CheckYourDetails
} else {
donor.Voucher = actor.Voucher{}
redirect = page.Paths.EnterVoucher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestPostConfirmPersonAllowedToVouch(t *testing.T) {
"yes": {
yesNo: form.Yes,
voucher: actor.Voucher{FirstNames: "John", Allowed: true},
redirect: page.Paths.TaskList,
redirect: page.Paths.CheckYourDetails,
},
"no": {
yesNo: form.No,
Expand Down
2 changes: 1 addition & 1 deletion internal/page/donor/enter_voucher.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func EnterVoucher(tmpl template.Template, donorStore DonorStore) Handler {
return page.Paths.ConfirmPersonAllowedToVouch.Redirect(w, r, appData, donor)
}

return page.Paths.TaskList.Redirect(w, r, appData, donor)
return page.Paths.CheckYourDetails.Redirect(w, r, appData, donor)
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/page/donor/enter_voucher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestPostEnterVoucher(t *testing.T) {

assert.Nil(t, err)
assert.Equal(t, http.StatusFound, resp.StatusCode)
assert.Equal(t, page.Paths.TaskList.Format("lpa-id"), resp.Header.Get("Location"))
assert.Equal(t, page.Paths.CheckYourDetails.Format("lpa-id"), resp.Header.Get("Location"))
}

func TestPostEnterVoucherWhenMatches(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions internal/page/donor/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ func Register(
EnterVoucher(tmpls.Get("enter_voucher.gohtml"), donorStore))
handleWithDonor(page.Paths.ConfirmPersonAllowedToVouch, page.CanGoBack,
ConfirmPersonAllowedToVouch(tmpls.Get("confirm_person_allowed_to_vouch.gohtml"), donorStore))
handleWithDonor(page.Paths.CheckYourDetails, page.CanGoBack,
Guidance(tmpls.Get("check_your_details.gohtml")))

handleWithDonor(page.Paths.ReadYourLpa, page.None,
Guidance(tmpls.Get("read_your_lpa.gohtml")))
Expand Down
2 changes: 2 additions & 0 deletions internal/page/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ type AppPaths struct {
ChangeCertificateProviderMobileNumber LpaPath
ChangeIndependentWitnessMobileNumber LpaPath
CheckYouCanSign LpaPath
CheckYourDetails LpaPath
CheckYourLpa LpaPath
ChooseAttorneys LpaPath
ChooseAttorneysAddress LpaPath
Expand Down Expand Up @@ -527,6 +528,7 @@ var Paths = AppPaths{
ChangeCertificateProviderMobileNumber: "/change-certificate-provider-mobile-number",
ChangeIndependentWitnessMobileNumber: "/change-independent-witness-mobile-number",
CheckYouCanSign: "/check-you-can-sign",
CheckYourDetails: "/check-your-details",
CheckYourLpa: "/check-your-lpa",
ChooseAttorneys: "/choose-attorneys",
ChooseAttorneysAddress: "/choose-attorneys-address",
Expand Down
7 changes: 7 additions & 0 deletions internal/templatefn/fn.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func All(globals *Globals) map[string]any {
"details": details,
"inc": inc,
"link": link,
"fromLink": fromLink,
"stringContains": strings.Contains,
"tr": tr,
"trFormat": trFormat,
Expand Down Expand Up @@ -188,6 +189,12 @@ func link(app page.AppData, path string) string {
return app.Lang.URL(path)
}

type lpaIDPath interface{ Format(string) string }

func fromLink(app page.AppData, path lpaIDPath, field string) string {
return app.Lang.URL(path.Format(app.LpaID)) + "?from=" + app.Page + field
}

// checkboxEq allows matching in the checkboxes.gohtml template for a value that
// is a list of strings, or a single string (where we are emulating a switch)
func checkboxEq(needle string, in any) bool {
Expand Down
7 changes: 7 additions & 0 deletions internal/templatefn/fn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ func TestLink(t *testing.T) {
assert.Equal(t, "/cy/dashboard", link(page.AppData{Lang: localize.Cy}, "/dashboard"))
}

func TestFromLink(t *testing.T) {
assert.Equal(t, "/lpa/lpa-id/your-details?from=/previous#f-first-names",
fromLink(page.AppData{LpaID: "lpa-id", Page: "/previous"}, page.Paths.YourDetails, "#f-first-names"))
assert.Equal(t, "/cy/attorney/lpa-id/confirm-your-details?from=/previous",
fromLink(page.AppData{LpaID: "lpa-id", Page: "/previous", Lang: localize.Cy}, page.Paths.Attorney.ConfirmYourDetails, ""))
}

func TestCheckboxEq(t *testing.T) {
assert.True(t, checkboxEq("b", []string{"a", "b", "c"}))
assert.False(t, checkboxEq("d", []string{"a", "b", "c"}))
Expand Down
5 changes: 4 additions & 1 deletion lang/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1212,5 +1212,8 @@
"noINeedToChooseSomeoneElse": "Welsh",
"yesIfPersonIsAllowedToVouchForYou": "Welsh",
"important": "Welsh",
"thePersonYouHaveChosenHasSameSurname": "Welsh"
"thePersonYouHaveChosenHasSameSurname": "Welsh",
"checkYourDetails": "Welsh",
"weWillShareYourDetailsWithVoucher": "Welsh",
"checkYourDetailsAreCorrectBeforeYouContinue": "Welsh"
}
5 changes: 4 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1144,5 +1144,8 @@
"noINeedToChooseSomeoneElse": "No, I need to choose someone else",
"yesIfPersonIsAllowedToVouchForYou": "yes, if the person is allowed to vouch for you",
"important": "Important",
"thePersonYouHaveChosenHasSameSurname": "The person you have chosen to confirm your identity has the same surname as you."
"thePersonYouHaveChosenHasSameSurname": "The person you have chosen to confirm your identity has the same surname as you.",
"checkYourDetails": "Check your details",
"weWillShareYourDetailsWithVoucher": "We will share your details and ask the person vouching for you to verify them.",
"checkYourDetailsAreCorrectBeforeYouContinue": "Check your details are correct before you continue."
}
33 changes: 33 additions & 0 deletions web/template/donor/check_your_details.gohtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{ template "page" . }}

{{ define "pageTitle" }}{{ tr .App "checkYourDetails" }}{{ end }}

{{ define "main" }}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">{{ tr .App "checkYourDetails" }}</h1>
<p class="govuk-body">{{ tr .App "weWillShareYourDetailsWithVoucher" }}</p>
<p class="govuk-body">{{ tr .App "checkYourDetailsAreCorrectBeforeYouContinue" }}</p>

<dl class="govuk-summary-list">
{{ template "summary-row" (summaryRow .App "name"
.Donor.Donor.FullName
(fromLink .App global.Paths.YourDetails "#f-first-names")
"" true true
) }}
{{ template "summary-row" (summaryRow .App "dateOfBirth"
(formatDate .App .Donor.Donor.DateOfBirth)
(fromLink .App global.Paths.YourDetails "#f-date-of-birth")
"" true true
) }}
{{ template "address-summary-row" (addressSummaryRow .App "address"
.Donor.Donor.Address
(fromLink .App global.Paths.YourAddress "#f-address-line-1")
"" true true
) }}
</dl>

{{ template "buttons" (button .App "continue" "link" (global.Paths.TaskList.Format .App.LpaID)) }}
</div>
</div>
{{ end }}

0 comments on commit 7036691

Please sign in to comment.