diff --git a/cypress/e2e/certificate-provider/dashboard.cy.js b/cypress/e2e/certificate-provider/dashboard.cy.js new file mode 100644 index 0000000000..aaedbf9d25 --- /dev/null +++ b/cypress/e2e/certificate-provider/dashboard.cy.js @@ -0,0 +1,51 @@ +describe('Dashboard', () => { + context('confirmed identity', () => { + it('shows the certificate provider card', () => { + cy.visit('/fixtures/certificate-provider?redirect=/task-list&progress=confirmYourIdentity'); + + cy.contains('li', 'Confirm your details').should('contain', 'Completed'); + cy.contains('li', 'Confirm your identity').should('contain', 'Completed'); + cy.contains('li', 'Provide your certificate').should('contain', 'Not started'); + + cy.visit('/dashboard') + + cy.contains('I’m a certificate provider').click() + cy.contains('Property and affairs'); + cy.contains('Sam Smith'); + cy.contains('strong', 'In progress'); + cy.contains('a', 'Go to task list') + }) + }) + + context('provided certificate', () => { + it('does not show the certificate provider card', () => { + cy.visit('/fixtures/certificate-provider?redirect=/task-list&progress=provideYourCertificate'); + + cy.contains('li', 'Confirm your details').should('contain', 'Completed'); + cy.contains('li', 'Confirm your identity').should('contain', 'Completed'); + cy.contains('li', 'Provide your certificate').should('contain', 'Completed'); + + cy.visit('/dashboard') + + cy.contains('I’m a certificate provider').should('not.exist') + }) + }) + + context('provided certificate but identity mismatch', () => { + it('shows the certificate provider card', () => { + cy.visit('/fixtures/certificate-provider?redirect=/task-list&progress=provideYourCertificate&idStatus=mismatch'); + + cy.contains('li', 'Confirm your details').should('contain', 'Completed'); + cy.contains('li', 'Confirm your identity').should('contain', 'Pending'); + cy.contains('li', 'Provide your certificate').should('contain', 'Completed'); + + cy.visit('/dashboard') + + cy.contains('I’m a certificate provider').click() + cy.contains('Property and affairs'); + cy.contains('Sam Smith'); + cy.contains('strong', 'In progress'); + cy.contains('a', 'Go to task list') + }) + }) +}) diff --git a/internal/dashboard/store.go b/internal/dashboard/store.go index 410dda91bb..70bd78df73 100644 --- a/internal/dashboard/store.go +++ b/internal/dashboard/store.go @@ -206,7 +206,7 @@ func (s *Store) GetAll(ctx context.Context) (results dashboarddata.Results, err lpaID := certificateProviderProvidedDetails.LpaID - if !certificateProviderProvidedDetails.SignedAt.IsZero() { + if !certificateProviderProvidedDetails.SignedAt.IsZero() && certificateProviderProvidedDetails.Tasks.ConfirmYourIdentity.IsCompleted() { delete(certificateProviderMap, lpaID) } diff --git a/internal/dashboard/store_test.go b/internal/dashboard/store_test.go index dfa3b06f85..c7d509e9ee 100644 --- a/internal/dashboard/store_test.go +++ b/internal/dashboard/store_test.go @@ -105,6 +105,7 @@ func TestDashboardStoreGetAll(t *testing.T) { SK: dynamo.CertificateProviderKey(sessionID), LpaID: "signed-by-cp", SignedAt: time.Now(), + Tasks: certificateproviderdata.Tasks{ConfirmYourIdentity: task.IdentityStateCompleted}, } lpaReferenced := &lpadata.Lpa{LpaID: "referenced", LpaUID: "X"} lpaReferencedLink := map[string]any{ diff --git a/internal/page/fixtures/certificate_provider.go b/internal/page/fixtures/certificate_provider.go index 0556e8e6e8..f8c7839745 100644 --- a/internal/page/fixtures/certificate_provider.go +++ b/internal/page/fixtures/certificate_provider.go @@ -45,6 +45,7 @@ func CertificateProvider( "signedByDonor", "confirmYourDetails", "confirmYourIdentity", + "provideYourCertificate", } return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request) error { @@ -62,6 +63,7 @@ func CertificateProvider( useRealUID = r.FormValue("uid") == "real" donorChannel = r.FormValue("donorChannel") isSupported = r.FormValue("is-supported") == "1" + idStatus = r.FormValue("idStatus") ) if certificateProviderSub == "" { @@ -269,14 +271,35 @@ func CertificateProvider( } if progress >= slices.Index(progressValues, "confirmYourIdentity") { - certificateProvider.IdentityUserData = identity.UserData{ - Status: identity.StatusConfirmed, - CheckedAt: time.Now(), - FirstNames: donorDetails.CertificateProvider.FirstNames, - LastName: donorDetails.CertificateProvider.LastName, - DateOfBirth: certificateProvider.DateOfBirth, + var userData identity.UserData + + switch idStatus { + case "mismatch": + userData = identity.UserData{ + Status: identity.StatusConfirmed, + CheckedAt: time.Now(), + FirstNames: "a", + LastName: "b", + DateOfBirth: certificateProvider.DateOfBirth, + } + certificateProvider.Tasks.ConfirmYourIdentity = task.IdentityStatePending + default: + userData = identity.UserData{ + Status: identity.StatusConfirmed, + CheckedAt: time.Now(), + FirstNames: donorDetails.CertificateProvider.FirstNames, + LastName: donorDetails.CertificateProvider.LastName, + DateOfBirth: certificateProvider.DateOfBirth, + } + certificateProvider.Tasks.ConfirmYourIdentity = task.IdentityStateCompleted } - certificateProvider.Tasks.ConfirmYourIdentity = task.IdentityStateCompleted + + certificateProvider.IdentityUserData = userData + } + + if progress >= slices.Index(progressValues, "provideYourCertificate") { + certificateProvider.SignedAt = time.Now() + certificateProvider.Tasks.ProvideTheCertificate = task.StateCompleted } if err := certificateProviderStore.Put(certificateProviderCtx, certificateProvider); err != nil { diff --git a/web/template/dashboard.gohtml b/web/template/dashboard.gohtml index 04b15c06f7..20f960a775 100644 --- a/web/template/dashboard.gohtml +++ b/web/template/dashboard.gohtml @@ -51,7 +51,7 @@ {{ tr .App "trackLpa" }} {{ else if .Item.Lpa.Status.IsRegistered }} - + {{ else if .Item.Lpa.Status.IsStatutoryWaitingPeriod }}
{{ tr .App "viewLpa" }} @@ -150,7 +150,7 @@ {{ .Item.Lpa.Donor.FullName }}
- {{ if and .Item.CertificateProvider.Tasks.ReadTheLpa.IsCompleted (not .Item.Lpa.SignedAt.IsZero) .Item.Lpa.Tasks.PayForLpa.IsCompleted }} + {{ if and .Item.CertificateProvider.Tasks.ReadTheLpa.IsCompleted (not .Item.Lpa.SignedAt.IsZero) .Item.Lpa.Paid .Item.CertificateProvider.Tasks.ConfirmYourIdentity.IsCompleted }} {{ tr .App "readyToSign" }} {{ else }} {{ tr .App "inProgress" }} @@ -285,7 +285,7 @@ {{ tr .App "theLpasNamedAsAttorneyHaveSuccessfullyRegistered" }} {{ end }}

- + {{ range .AttorneyLpas }} {{ template "attorneyCard" (card $.App .) }} {{ end }} @@ -333,9 +333,9 @@ {{ range .VoucherLpas }} {{ template "voucherCard" (card $.App .) }} {{ end }} - {{ if .NeedsTabs }}
{{ end }} + {{ if .NeedsTabs }}
{{ end }} {{ end }} - + {{ if .NeedsTabs }}{{ end }}