Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLPAB-2689: Show dashboard certificate providers until certificate provided and identity confirmed #1691

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions cypress/e2e/certificate-provider/dashboard.cy.js
Original file line number Diff line number Diff line change
@@ -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')
})
})
})
2 changes: 1 addition & 1 deletion internal/dashboard/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
1 change: 1 addition & 0 deletions internal/dashboard/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
37 changes: 30 additions & 7 deletions internal/page/fixtures/certificate_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func CertificateProvider(
"signedByDonor",
"confirmYourDetails",
"confirmYourIdentity",
"provideYourCertificate",
}

return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request) error {
Expand All @@ -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 == "" {
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions web/template/dashboard.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<a class="govuk-button govuk-button--secondary" href="{{ link .App (global.Paths.Progress.Format .Item.Lpa.LpaID) }}">{{ tr .App "trackLpa" }}</a>
</div>
{{ else if .Item.Lpa.Status.IsRegistered }}

{{ else if .Item.Lpa.Status.IsStatutoryWaitingPeriod }}
<div class="govuk-button-group">
<a class="govuk-button" href="{{ link .App (global.Paths.ViewLPA.Format .Item.Lpa.LpaID) }}">{{ tr .App "viewLpa" }}</a>
Expand Down Expand Up @@ -150,7 +150,7 @@
<span class="govuk-!-font-weight-regular">{{ .Item.Lpa.Donor.FullName }}</span>
</h3>
<div>
{{ 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 }}
<strong class="app-tag govuk-tag--yellow">{{ tr .App "readyToSign" }}</strong>
{{ else }}
<strong class="app-tag govuk-tag--blue">{{ tr .App "inProgress" }}</strong>
Expand Down Expand Up @@ -285,7 +285,7 @@
{{ tr .App "theLpasNamedAsAttorneyHaveSuccessfullyRegistered" }}
{{ end }}
</p>

{{ range .AttorneyLpas }}
{{ template "attorneyCard" (card $.App .) }}
{{ end }}
Expand Down Expand Up @@ -333,9 +333,9 @@
{{ range .VoucherLpas }}
{{ template "voucherCard" (card $.App .) }}
{{ end }}
{{ if .NeedsTabs }}</div>{{ end }}
{{ if .NeedsTabs }}</div>{{ end }}
{{ end }}

{{ if .NeedsTabs }}</div>{{ end }}
</div>
</div>
Expand Down
Loading