Skip to content

Commit

Permalink
MLPAB-1900 Voucher start page (#1413)
Browse files Browse the repository at this point in the history
* Remove unused mocks

* Add voucher start page

* Add test to check translation file has unique keys
  • Loading branch information
hawx authored Aug 8, 2024
1 parent dae8c45 commit d9cf8d7
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 88 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ go-test: ##@testing Runs full go test suite
go test ./... -race -covermode=atomic -coverprofile=coverage.out

go-generate: ##@testing Runs go generate for mocks and enums
git ls-files | grep '.*/mock_.*_test\.go' | xargs rm
mockery
go install ./cmd/enumerator
go generate ./...
Expand Down
52 changes: 49 additions & 3 deletions cmd/mlpa/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"bytes"
"encoding/json"
"io"
"net/http"
Expand Down Expand Up @@ -28,21 +29,66 @@ func TestAwsRegion(t *testing.T) {
assert.Equal(t, "us-west-2", region)
}

func TestLanguageFilesUniqueKeys(t *testing.T) {
for _, path := range []string{"lang/en.json", "lang/cy.json"} {
data, err := os.ReadFile("../../" + path)
if err != nil {
panic(err)
}

keys := map[json.Token]struct{}{}
dec := json.NewDecoder(bytes.NewReader(data))

// skip opening {
_, _ = dec.Token()

for {
tok, err := dec.Token()
if err != nil {
panic(err)
}

if tok == json.Delim('}') {
break
}

// skip value
valTok, _ := dec.Token()

if _, found := keys[tok]; found {
t.Fail()
t.Log(path, "duplicate:", tok)
}

keys[tok] = struct{}{}

if valTok == json.Delim('{') {
for dec.More() {
_, _ = dec.Token()
}

// skip closing }
_, _ = dec.Token()
}
}
}
}

func TestLanguageFilesMatch(t *testing.T) {
en := loadTranslations("../../lang/en.json")
cy := loadTranslations("../../lang/cy.json")

for k := range en {
if _, ok := cy[k]; !ok {
t.Fail()
t.Log("lang/cy.json missing: ", k)
t.Log("lang/cy.json missing:", k)
}
}

for k := range cy {
if _, ok := en[k]; !ok {
t.Fail()
t.Log("lang/en.json missing: ", k)
t.Log("lang/en.json missing:", k)
}
}
}
Expand All @@ -61,7 +107,7 @@ func TestApostrophesAreCurly(t *testing.T) {
for k, v := range cy {
if strings.Contains(v, "'") {
t.Fail()
t.Log("lang/cy.json: ", k)
t.Log("lang/cy.json:", k)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ func App(
page.Guidance(tmpls.Get("certificate_provider_start.gohtml")))
handleRoot(page.PathAttorneyStart, None,
page.Guidance(tmpls.Get("attorney_start.gohtml")))
handleRoot(page.PathVoucherStart, None,
page.Guidance(tmpls.Get("voucher_start.gohtml")))
handleRoot(page.PathDashboard, RequireSession,
page.Dashboard(tmpls.Get("dashboard.gohtml"), donorStore, dashboardStore))
handleRoot(page.PathLpaDeleted, RequireSession,
Expand Down
83 changes: 0 additions & 83 deletions internal/notify/mock_Bundle_test.go

This file was deleted.

1 change: 1 addition & 0 deletions internal/page/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
PathSupporterOrganisationDeleted = Path("/organisation-deleted")
PathSupporterSigningInAdvice = Path("/signing-in-with-govuk-one-login")
PathSupporterStart = Path("/supporter-start")
PathVoucherStart = Path("/voucher-start")

PathAttorneyFixtures = Path("/fixtures/attorney")
PathAuthRedirect = Path("/auth/redirect")
Expand Down
2 changes: 2 additions & 0 deletions internal/templatefn/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ type appPaths struct {
SignOut page.Path
Start page.Path
SupporterFixtures page.Path
VoucherStart page.Path

AboutPayment donor.Path
AddCorrespondent donor.Path
Expand Down Expand Up @@ -329,6 +330,7 @@ var paths = appPaths{
SignOut: page.PathSignOut,
Start: page.PathStart,
SupporterFixtures: page.PathSupporterFixtures,
VoucherStart: page.PathVoucherStart,

AboutPayment: donor.PathAboutPayment,
AddCorrespondent: donor.PathAddCorrespondent,
Expand Down
3 changes: 2 additions & 1 deletion lang/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1310,5 +1310,6 @@
"someOfTheseDetailsCanNoLongerBeChanged": "Welsh",
"whichFeeTypeYouAreApplyingFor": "pa fath o ffi yr ydych yn gwneud cais amdano",
"emailGreetingDonor": "Welsh {{.DonorFullName}},",
"emailGreetingCorrespondent": "Welsh: {{.LpaUID}} {{.CorrespondentFullName}} {{.DonorFullNamePossessive}} {{.LpaType}}"
"emailGreetingCorrespondent": "Welsh: {{.LpaUID}} {{.CorrespondentFullName}} {{.DonorFullNamePossessive}} {{.LpaType}}",
"voucherStartContent": "<p class=\"govuk-body\">Welsh</p>"
}
3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1239,5 +1239,6 @@
"someOfTheseDetailsCanNoLongerBeChanged": "Some of these details can no longer be changed because they have been successfully matched with your confirmed identity details.",
"whichFeeTypeYouAreApplyingFor": "which fee type you are applying for",
"emailGreetingDonor": "Dear {{.DonorFullName}},",
"emailGreetingCorrespondent": "Our ref: {{.LpaUID}}\n\nDear {{.CorrespondentFullName}}\n\nRe: {{.DonorFullNamePossessive}} Lasting Power of Attorney for {{.LpaType}}"
"emailGreetingCorrespondent": "Our ref: {{.LpaUID}}\n\nDear {{.CorrespondentFullName}}\n\nRe: {{.DonorFullNamePossessive}} Lasting Power of Attorney for {{.LpaType}}",
"voucherStartContent": "<p class=\"govuk-body\">Vouching allows you to verify the identity of someone you know well. This might be because they do not have ID documentation or failed an ID check.</p><p class=\"govuk-body govuk-!-font-weight-bold\">To vouch for someone, you must:</p><ul class=\"govuk-list govuk-list--bullet\"><li>be 18 years old or older</li><li>be able to confirm your own identity</li><li>have known the person for at least 2 years</li><li>be willing to sign a declaration</li></ul><p class=\"govuk-body govuk-!-font-weight-bold\">You cannot vouch for someone if you are:</p><ul class=\"govuk-list govuk-list--bullet\"><li>named on their lasting power of attorney (LPA) as an attorney, replacement attorney or certificate provider</li><li>in a relationship with them</li><li>live at the same address as them</li></ul><h2 class=\"govuk-heading-m\">What you will need to do</h2><p class=\"govuk-body\">You will need to confirm your own identity using GOV.UK One Login.</p><p class=\"govuk-body\">You will need either:</p><ul class=\"govuk-list govuk-list--bullet\"><li>a National Insurance number</li><li>a UK passport</li><li>a UK driving licence</li></ul><p class=\"govuk-body\">We will then ask you to verify the person’s identity and sign a declaration.</p>"
}
20 changes: 20 additions & 0 deletions web/template/voucher_start.gohtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{ template "page" . }}

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

{{ trHtml .App "voucherStartContent" }}

<p class="govuk-body">
<a href="{{ link .App global.Paths.VoucherStart.Format }}" role="button" draggable="false" class="govuk-button govuk-button--start" data-module="govuk-button">
{{ tr .App "start" }}
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" />
</svg>
</a>
</p>
</div>
</div>
{{ end }}

0 comments on commit d9cf8d7

Please sign in to comment.