Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx authored Nov 27, 2024
2 parents 5675ae5 + b44d4ca commit 1e13d5d
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 87 deletions.
159 changes: 95 additions & 64 deletions cypress/e2e/donor/confirm-your-identity.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Confirm your identity', () => {
cy.contains('label', 'Sam Smith (donor)').click();
cy.contains('button', 'Continue').click();

cy.url().should('contain', '/one-login-identity-details');
cy.url().should('contain', '/identity-details');
cy.checkA11yApp();

cy.contains('Sam');
Expand Down Expand Up @@ -106,91 +106,122 @@ describe('Confirm your identity', () => {
})

describe('when identity details do not match LPA', () => {
it('can update LPA details', () => {
cy.visit('/fixtures?redirect=/task-list&progress=payForTheLpa');
cy.contains('li', "Confirm your identity")
.should('contain', 'Not started')
.find('a')
.click();
describe('before signing', () => {
it('can update LPA details', () => {
cy.visit('/fixtures?redirect=/task-list&progress=payForTheLpa');
cy.contains('li', "Confirm your identity")
.should('contain', 'Not started')
.find('a')
.click();

cy.url().should('contain', '/confirm-your-identity');
cy.checkA11yApp();
cy.contains('button', 'Continue').click();
cy.url().should('contain', '/confirm-your-identity');
cy.checkA11yApp();
cy.contains('button', 'Continue').click();

cy.contains('label', 'Charlie Cooper (certificate provider)').click();
cy.contains('button', 'Continue').click();
cy.contains('label', 'Charlie Cooper (certificate provider)').click();
cy.contains('button', 'Continue').click();

cy.url().should('contain', '/one-login-identity-details');
cy.checkA11yApp();
cy.url().should('contain', '/identity-details');
cy.checkA11yApp();

cy.contains('dd', 'Sam').parent().contains('span', 'Does not match');
cy.contains('dd', 'Smith').parent().contains('span', 'Does not match');
cy.contains('dd', '2 January 2000').parent().contains('span', 'Does not match');
cy.contains('dd', 'Sam').parent().contains('span', 'Does not match');
cy.contains('dd', 'Smith').parent().contains('span', 'Does not match');
cy.contains('dd', '2 January 2000').parent().contains('span', 'Does not match');

cy.contains('label', 'Yes').click();
cy.contains('button', 'Continue').click();
cy.contains('label', 'Yes').click();
cy.contains('button', 'Continue').click();

cy.url().should('contain', '/one-login-identity-details');
cy.checkA11yApp();
cy.url().should('contain', '/identity-details');
cy.checkA11yApp();

cy.contains('Your LPA details have been updated to match your confirmed identity')
cy.get('main').should('not.contain', 'Sam');
cy.get('main').should('not.contain', 'Smith');
cy.get('main').should('not.contain', '2 January 2000');
})
cy.contains('Your LPA details have been updated to match your confirmed identity')
cy.get('main').should('not.contain', 'Sam');
cy.get('main').should('not.contain', 'Smith');
cy.get('main').should('not.contain', '2 January 2000');
})

it('can withdraw LPA', () => {
cy.visit('/fixtures?redirect=/task-list&progress=payForTheLpa');
cy.contains('li', "Confirm your identity")
.should('contain', 'Not started')
.find('a')
.click();

cy.url().should('contain', '/confirm-your-identity');
cy.checkA11yApp();
cy.contains('button', 'Continue').click();
it('can withdraw LPA', () => {
cy.visit('/fixtures?redirect=/task-list&progress=payForTheLpa');
cy.contains('li', "Confirm your identity")
.should('contain', 'Not started')
.find('a')
.click();

cy.contains('label', 'Charlie Cooper (certificate provider)').click();
cy.contains('button', 'Continue').click();
cy.url().should('contain', '/confirm-your-identity');
cy.checkA11yApp();
cy.contains('button', 'Continue').click();

cy.url().should('contain', '/one-login-identity-details');
cy.checkA11yApp();
cy.contains('label', 'Charlie Cooper (certificate provider)').click();
cy.contains('button', 'Continue').click();

cy.contains('dd', 'Sam').parent().contains('span', 'Does not match');
cy.contains('dd', 'Smith').parent().contains('span', 'Does not match');
cy.contains('dd', '2 January 2000').parent().contains('span', 'Does not match');
cy.url().should('contain', '/identity-details');
cy.checkA11yApp();

cy.contains('label', 'No').click();
cy.contains('button', 'Continue').click();
cy.contains('dd', 'Sam').parent().contains('span', 'Does not match');
cy.contains('dd', 'Smith').parent().contains('span', 'Does not match');
cy.contains('dd', '2 January 2000').parent().contains('span', 'Does not match');

cy.url().should('contain', '/withdraw-this-lpa');
cy.checkA11yApp();
})
cy.contains('label', 'No').click();
cy.contains('button', 'Continue').click();

it('errors when option not selected', () => {
cy.visit('/fixtures?redirect=/task-list&progress=payForTheLpa');
cy.contains('li', "Confirm your identity")
.should('contain', 'Not started')
.find('a')
.click();
cy.url().should('contain', '/withdraw-this-lpa');
cy.checkA11yApp();
})

cy.url().should('contain', '/confirm-your-identity');
cy.checkA11yApp();
cy.contains('button', 'Continue').click();
it('errors when option not selected', () => {
cy.visit('/fixtures?redirect=/task-list&progress=payForTheLpa');
cy.contains('li', "Confirm your identity")
.should('contain', 'Not started')
.find('a')
.click();

cy.contains('label', 'Charlie Cooper (certificate provider)').click();
cy.contains('button', 'Continue').click();
cy.url().should('contain', '/confirm-your-identity');
cy.checkA11yApp();
cy.contains('button', 'Continue').click();

cy.url().should('contain', '/one-login-identity-details');
cy.checkA11yApp();
cy.contains('label', 'Charlie Cooper (certificate provider)').click();
cy.contains('button', 'Continue').click();

cy.contains('button', 'Continue').click();
cy.url().should('contain', '/identity-details');
cy.checkA11yApp();

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

cy.get('.govuk-error-summary').within(() => {
cy.contains('Select yes if you would like to update your details');
});

cy.get('.govuk-error-summary').within(() => {
cy.contains('Select yes if you would like to update your details');
cy.contains('.govuk-error-message', 'Select yes if you would like to update your details');
});
});

cy.contains('.govuk-error-message', 'Select yes if you would like to update your details');
describe('after signing', () => {
it('cannot update details', () => {
cy.visit('/fixtures?redirect=/task-list&progress=signTheLpa&idStatus=donor:post-office');
cy.contains('li', "Sign the LPA")
.should('contain', 'Completed');
cy.contains('li', "Confirm your identity")
.should('contain', 'Pending')
.find('a')
.click();

cy.contains('label', 'confirm my identity another way').click();
cy.contains('button', 'Continue').click();

cy.contains('label', 'Charlie Cooper (certificate provider)').click();
cy.contains('button', 'Continue').click();

cy.url().should('contain', '/identity-details');
cy.checkA11yApp();
cy.contains('Does not match');
cy.contains('cannot be updated');
cy.contains('button', 'Continue').should('not.exist');
cy.contains('a', 'Return to task list').click();

cy.contains('li', "Confirm your identity")
.should('contain', 'Pending');
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/ministryofjustice/opg-modernising-lpa/internal/validation"
)

type oneLoginIdentityDetailsData struct {
type identityDetailsData struct {
App appcontext.Data
Errors validation.List
Provided *donordata.Provided
Expand All @@ -26,13 +26,13 @@ type oneLoginIdentityDetailsData struct {
Form *form.YesNoForm
}

func (d oneLoginIdentityDetailsData) DetailsMatch() bool {
func (d identityDetailsData) DetailsMatch() bool {
return d.FirstNamesMatch && d.LastNameMatch && d.DateOfBirthMatch && d.AddressMatch
}

func OneLoginIdentityDetails(tmpl template.Template, donorStore DonorStore) Handler {
func IdentityDetails(tmpl template.Template, donorStore DonorStore) Handler {
return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, provided *donordata.Provided) error {
data := &oneLoginIdentityDetailsData{
data := &identityDetailsData{
App: appData,
Form: form.NewYesNoForm(form.YesNoUnknown),
Provided: provided,
Expand All @@ -43,7 +43,7 @@ func OneLoginIdentityDetails(tmpl template.Template, donorStore DonorStore) Hand
AddressMatch: provided.Donor.Address.Postcode == provided.IdentityUserData.CurrentAddress.Postcode,
}

if r.Method == http.MethodPost {
if r.Method == http.MethodPost && provided.CanChange() {
f := form.ReadYesNoForm(r, "yesIfWouldLikeToUpdateDetails")
data.Errors = f.Validate()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import (
)

func TestOneLoginIdentityDetailsDataDetailsMatch(t *testing.T) {
assert.True(t, oneLoginIdentityDetailsData{
assert.True(t, identityDetailsData{
FirstNamesMatch: true,
LastNameMatch: true,
DateOfBirthMatch: true,
AddressMatch: true,
}.DetailsMatch())
assert.False(t, oneLoginIdentityDetailsData{LastNameMatch: true, DateOfBirthMatch: true, AddressMatch: true}.DetailsMatch())
assert.False(t, oneLoginIdentityDetailsData{}.DetailsMatch())
assert.False(t, identityDetailsData{LastNameMatch: true, DateOfBirthMatch: true, AddressMatch: true}.DetailsMatch())
assert.False(t, identityDetailsData{}.DetailsMatch())
}

func TestGetOneLoginIdentityDetails(t *testing.T) {
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestGetOneLoginIdentityDetails(t *testing.T) {

template := newMockTemplate(t)
template.EXPECT().
Execute(w, &oneLoginIdentityDetailsData{
Execute(w, &identityDetailsData{
App: testAppData,
Form: form.NewYesNoForm(form.YesNoUnknown),
Provided: tc.donorProvided,
Expand All @@ -89,7 +89,7 @@ func TestGetOneLoginIdentityDetails(t *testing.T) {
}).
Return(nil)

err := OneLoginIdentityDetails(template.Execute, nil)(testAppData, w, r, tc.donorProvided)
err := IdentityDetails(template.Execute, nil)(testAppData, w, r, tc.donorProvided)
resp := w.Result()

assert.Nil(t, err)
Expand Down Expand Up @@ -121,7 +121,7 @@ func TestPostOneLoginIdentityDetailsWhenYes(t *testing.T) {
Put(r.Context(), updated).
Return(nil)

err := OneLoginIdentityDetails(nil, donorStore)(testAppData, w, r, &donordata.Provided{
err := IdentityDetails(nil, donorStore)(testAppData, w, r, &donordata.Provided{
LpaID: "lpa-id",
Donor: donordata.Donor{FirstNames: "b", LastName: "b", DateOfBirth: existingDob, Address: testAddress},
IdentityUserData: identity.UserData{FirstNames: "B", LastName: "B", DateOfBirth: identityDob, CurrentAddress: place.Address{Line1: "a"}},
Expand All @@ -140,7 +140,7 @@ func TestPostOneLoginIdentityDetailsWhenNo(t *testing.T) {
r := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode()))
r.Header.Set("Content-Type", "application/x-www-form-urlencoded")

err := OneLoginIdentityDetails(nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"})
err := IdentityDetails(nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"})
resp := w.Result()

assert.Nil(t, err)
Expand All @@ -160,7 +160,7 @@ func TestPostOneLoginIdentityDetailsWhenDonorStoreError(t *testing.T) {
Put(r.Context(), mock.Anything).
Return(expectedError)

err := OneLoginIdentityDetails(nil, donorStore)(testAppData, w, r, &donordata.Provided{})
err := IdentityDetails(nil, donorStore)(testAppData, w, r, &donordata.Provided{})
resp := w.Result()

assert.Equal(t, expectedError, err)
Expand All @@ -178,12 +178,12 @@ func TestPostOneLoginIdentityDetailsWhenValidationError(t *testing.T) {

template := newMockTemplate(t)
template.EXPECT().
Execute(w, mock.MatchedBy(func(data *oneLoginIdentityDetailsData) bool {
Execute(w, mock.MatchedBy(func(data *identityDetailsData) bool {
return assert.Equal(t, validationError, data.Errors)
})).
Return(nil)

err := OneLoginIdentityDetails(template.Execute, nil)(testAppData, w, r, &donordata.Provided{Donor: donordata.Donor{FirstNames: "a"}})
err := IdentityDetails(template.Execute, nil)(testAppData, w, r, &donordata.Provided{Donor: donordata.Donor{FirstNames: "a"}})
resp := w.Result()

assert.Nil(t, err)
Expand Down
2 changes: 1 addition & 1 deletion internal/donor/donorpage/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func Register(
handleWithDonor(donor.PathIdentityWithOneLoginCallback, page.CanGoBack,
IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore, scheduledStore, eventClient))
handleWithDonor(donor.PathIdentityDetails, page.CanGoBack,
OneLoginIdentityDetails(tmpls.Get("identity_details.gohtml"), donorStore))
IdentityDetails(tmpls.Get("identity_details.gohtml"), donorStore))
handleWithDonor(donor.PathRegisterWithCourtOfProtection, page.None,
RegisterWithCourtOfProtection(tmpls.Get("register_with_court_of_protection.gohtml"), donorStore))

Expand Down
2 changes: 1 addition & 1 deletion internal/donor/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const (
PathHowWillYouConfirmYourIdentity = Path("/how-will-you-confirm-your-identity")
PathHowWouldCertificateProviderPreferToCarryOutTheirRole = Path("/how-would-certificate-provider-prefer-to-carry-out-their-role")
PathHowWouldYouLikeToSendEvidence = Path("/how-would-you-like-to-send-evidence")
PathIdentityDetails = Path("/one-login-identity-details")
PathIdentityDetails = Path("/identity-details")
PathIdentityWithOneLogin = Path("/id/one-login")
PathIdentityWithOneLoginCallback = Path("/id/one-login/callback")
PathLifeSustainingTreatment = Path("/life-sustaining-treatment")
Expand Down
7 changes: 6 additions & 1 deletion internal/page/fixtures/donor.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,9 @@ func updateLPAProgress(
userData = identity.UserData{
Status: identity.StatusExpired,
}
case "post-office":
userData = identity.UserData{}
donorDetails.Tasks.ConfirmYourIdentity = task.IdentityStatePending
default:
userData = identity.UserData{
Status: identity.StatusConfirmed,
Expand All @@ -461,7 +464,9 @@ func updateLPAProgress(

donorDetails.FailedVouchAttempts = attempts
donorDetails.IdentityUserData = userData
donorDetails.Tasks.ConfirmYourIdentity = task.IdentityStateCompleted
if donorDetails.Tasks.ConfirmYourIdentity.IsNotStarted() {
donorDetails.Tasks.ConfirmYourIdentity = task.IdentityStateCompleted
}
}

if data.Progress >= slices.Index(progressValues, "signTheLpa") {
Expand Down
5 changes: 4 additions & 1 deletion lang/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1532,5 +1532,8 @@
"costsIfYouAreEligibleContent": "<p class=\"govuk-body\">Welsh</p>",
"whichFeeYouAreEligibleToPay": "Welsh",
"repeatApplicationNoFeeRequestSubmitted": "<div class=\"govuk-notification-banner__content\"><p class=\"govuk-notification-banner__heading\">Welsh</p><p class=\"govuk-body\">Welsh</p></div>",
"whatHappensNextRepeatApplicationNoFeeContent": "<h3 class=\"govuk-heading-m\">Welsh</h3>"
"whatHappensNextRepeatApplicationNoFeeContent": "<h3 class=\"govuk-heading-m\">Welsh</h3>",
"theDetailsOnYourLpaDoNotMatch": "Welsh",
"theDetailsOnYourLpaCannotBeUpdatedAsSigned": "<p class=\"govuk-body\">Welsh</p>",
"ifYouDoNotWantRegisteredWithConfirmedDetailsWarning": "Welsh"
}
Loading

0 comments on commit 1e13d5d

Please sign in to comment.