Skip to content

Commit

Permalink
Merge ea5769d into 580ca41
Browse files Browse the repository at this point in the history
  • Loading branch information
acsauk authored Jul 8, 2024
2 parents 580ca41 + ea5769d commit abee72a
Show file tree
Hide file tree
Showing 24 changed files with 175 additions and 147 deletions.
23 changes: 16 additions & 7 deletions cypress/e2e/donor/confirm-person-allowed-to-vouch.cy.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
describe('Enter voucher', () => {
beforeEach(() => {
cy.visit('/fixtures?redirect=/enter-voucher&progress=payForTheLpa');
});

it('can confirm', () => {
cy.get('#f-first-names').type('Sam');
cy.get('#f-last-name').type('Smith');
cy.get('#f-email').type('[email protected]');
cy.contains('button', 'Save and continue').click();

cy.url().should('contain', '/confirm-person-allowed-to-vouch');
});

it('can confirm', () => {
cy.checkA11yApp();

cy.contains('You have entered a name which matches your name, Sam Smith.');
Expand All @@ -20,11 +21,6 @@ describe('Enter voucher', () => {
});

it('can select another', () => {
cy.get('#f-first-names').type('Sam');
cy.get('#f-last-name').type('Smith');
cy.get('#f-email').type('[email protected]');
cy.contains('button', 'Save and continue').click();

cy.get('input[name=yes-no]').check('no');
cy.contains('button', 'Save and continue').click();

Expand All @@ -33,4 +29,17 @@ describe('Enter voucher', () => {
cy.get('#f-last-name').should('have.value', '');
cy.get('#f-email').should('have.value', '');
});

it('errors when not selected', () => {
cy.contains('button', 'Save and continue').click();

cy.url().should('contain', '/confirm-person-allowed-to-vouch');
cy.checkA11yApp();

cy.get('.govuk-error-summary').within(() => {
cy.contains('Select yes, if the person is allowed to vouch for you');
});

cy.contains('.govuk-fieldset .govuk-error-message', 'Select yes, if the person is allowed to vouch for you');
});
});
10 changes: 9 additions & 1 deletion cypress/e2e/donor/what-you-can-do-now.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@ describe('what you can do now', () => {
cy.url().should('contain', '/task-list')
cy.checkA11yApp()

cy.contains('li', "Confirm your identity and sign the LPA").should('contain', 'In progress');
cy.contains('li', "Confirm your identity and sign the LPA").should('contain', 'In progress').click();

cy.url().should('contain', '/what-happens-next-registering-with-court-of-protection')
cy.checkA11yApp()

cy.contains('a', 'Continue').click();

cy.url().should('contain', '/read-your-lpa')
cy.checkA11yApp()
})

it('errors when option not selected', () => {
Expand Down
94 changes: 6 additions & 88 deletions go.sum

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions internal/actor/enum_attorneysact.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions internal/actor/enum_certificateproviderrelationship.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions internal/actor/enum_channel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions internal/actor/enum_identitytask.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions internal/actor/enum_lifesustainingtreatment.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions internal/actor/enum_lpatype.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions internal/actor/enum_replacementattorneysstepin.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions internal/actor/enum_yesnomaybe.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/actor/task_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type IdentityTask uint8
const (
IdentityTaskNotStarted IdentityTask = iota
IdentityTaskInProgress
IdentityTaskPending
IdentityTaskProblem
IdentityTaskCompleted
)
3 changes: 3 additions & 0 deletions internal/localize/enum_lang.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions internal/page/donor/task_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ func taskListSignSection(donor *actor.DonorProvidedDetails) taskListSection {
if donor.RegisteringWithCourtOfProtection {
signPath = page.Paths.WhatHappensNextRegisteringWithCourtOfProtection
}

if !donor.SignedAt.IsZero() {
signPath = page.Paths.YouHaveSubmittedYourLpa
}
}
default:
signPath = page.Paths.HowToConfirmYourIdentityAndSign
Expand Down
18 changes: 18 additions & 0 deletions internal/page/donor/task_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,24 @@ func TestGetTaskList(t *testing.T) {
return sections
},
},
"is applying to court of protection and has signed": {
appData: testAppData,
donor: &actor.DonorProvidedDetails{
LpaID: "lpa-id",
Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}},
DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"},
WantVoucher: form.No,
RegisteringWithCourtOfProtection: true,
SignedAt: testNow,
},
expected: func(sections []taskListSection) []taskListSection {
sections[2].Items = []taskListItem{
{Name: "confirmYourIdentityAndSign", Path: page.Paths.YouHaveSubmittedYourLpa.Format("lpa-id")},
}

return sections
},
},
"attorneys under 18": {
appData: testAppData,
donor: &actor.DonorProvidedDetails{
Expand Down
4 changes: 4 additions & 0 deletions internal/page/donor/witnessing_as_certificate_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func WitnessingAsCertificateProvider(

if data.Errors.None() {
donor.Tasks.ConfirmYourIdentityAndSign = actor.IdentityTaskCompleted
if donor.RegisteringWithCourtOfProtection {
donor.Tasks.ConfirmYourIdentityAndSign = actor.IdentityTaskPending
}

donor.WitnessCodeLimiter = nil
if donor.WitnessedByCertificateProviderAt.IsZero() {
donor.WitnessedByCertificateProviderAt = now()
Expand Down
106 changes: 63 additions & 43 deletions internal/page/donor/witnessing_as_certificate_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,54 +81,74 @@ func TestGetWitnessingAsCertificateProviderWhenTemplateErrors(t *testing.T) {
}

func TestPostWitnessingAsCertificateProvider(t *testing.T) {
form := url.Values{
"witness-code": {"1234"},
}

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

donor := &actor.DonorProvidedDetails{
LpaID: "lpa-id",
DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed},
CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}},
CertificateProvider: actor.CertificateProvider{FirstNames: "Fred"},
WitnessedByCertificateProviderAt: now,
Tasks: actor.DonorTasks{
ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted,
PayForLpa: actor.PaymentTaskCompleted,
testcases := map[string]struct {
registeringWithCOP bool
expectedIdentityAndSignTaskStatus actor.IdentityTask
}{
"registering with COP": {
registeringWithCOP: true,
expectedIdentityAndSignTaskStatus: actor.IdentityTaskPending,
},
"proved ID": {
expectedIdentityAndSignTaskStatus: actor.IdentityTaskCompleted,
},
}

donorStore := newMockDonorStore(t)
donorStore.EXPECT().
Put(r.Context(), donor).
Return(nil)

shareCodeSender := newMockShareCodeSender(t)
shareCodeSender.EXPECT().
SendCertificateProviderPrompt(r.Context(), testAppData, donor).
Return(nil)

lpaStoreClient := newMockLpaStoreClient(t)
lpaStoreClient.EXPECT().
SendLpa(r.Context(), donor).
Return(nil)
for name, tc := range testcases {
t.Run(name, func(t *testing.T) {
form := url.Values{
"witness-code": {"1234"},
}

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

donor := &actor.DonorProvidedDetails{
LpaID: "lpa-id",
DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed},
CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}},
CertificateProvider: actor.CertificateProvider{FirstNames: "Fred"},
WitnessedByCertificateProviderAt: now,
Tasks: actor.DonorTasks{
ConfirmYourIdentityAndSign: tc.expectedIdentityAndSignTaskStatus,
PayForLpa: actor.PaymentTaskCompleted,
},
RegisteringWithCourtOfProtection: tc.registeringWithCOP,
}

donorStore := newMockDonorStore(t)
donorStore.EXPECT().
Put(r.Context(), donor).
Return(nil)

shareCodeSender := newMockShareCodeSender(t)
shareCodeSender.EXPECT().
SendCertificateProviderPrompt(r.Context(), testAppData, donor).
Return(nil)

lpaStoreClient := newMockLpaStoreClient(t)
lpaStoreClient.EXPECT().
SendLpa(r.Context(), donor).
Return(nil)

err := WitnessingAsCertificateProvider(nil, donorStore, shareCodeSender, lpaStoreClient, func() time.Time { return now })(testAppData, w, r, &actor.DonorProvidedDetails{
LpaID: "lpa-id",
DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed},
CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}},
CertificateProvider: actor.CertificateProvider{FirstNames: "Fred"},
Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskCompleted},
RegisteringWithCourtOfProtection: tc.registeringWithCOP,
})
resp := w.Result()

err := WitnessingAsCertificateProvider(nil, donorStore, shareCodeSender, lpaStoreClient, func() time.Time { return now })(testAppData, w, r, &actor.DonorProvidedDetails{
LpaID: "lpa-id",
DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed},
CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}},
CertificateProvider: actor.CertificateProvider{FirstNames: "Fred"},
Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskCompleted},
})
resp := w.Result()
assert.Nil(t, err)
assert.Equal(t, http.StatusFound, resp.StatusCode)
assert.Equal(t, page.Paths.YouHaveSubmittedYourLpa.Format("lpa-id"), resp.Header.Get("Location"))
})
}

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

func TestPostWitnessingAsCertificateProviderWhenPaymentPending(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/page/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (p LpaPath) canVisit(donor *actor.DonorProvidedDetails) bool {
Paths.WitnessingAsCertificateProvider,
Paths.WitnessingAsIndependentWitness,
Paths.YouHaveSubmittedYourLpa:
return donor.DonorIdentityConfirmed()
return donor.DonorIdentityConfirmed() || donor.RegisteringWithCourtOfProtection

case Paths.ConfirmYourCertificateProviderIsNotRelated,
Paths.CheckYourLpa:
Expand Down
3 changes: 3 additions & 0 deletions internal/pay/enum_evidencedelivery.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit abee72a

Please sign in to comment.