Skip to content

Commit

Permalink
MLPAB-1291 Hide submitted replacement attorney cards (#732)
Browse files Browse the repository at this point in the history
And create a brand new fixtures page for attorneys and certificate providers
  • Loading branch information
hawx authored Sep 28, 2023
1 parent f6143cd commit 4c0e004
Show file tree
Hide file tree
Showing 33 changed files with 725 additions and 305 deletions.
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ coverage:
- "./internal/identity/yoti*"
- "./internal/telemetry"
- "./internal/page/fixtures.go"
- "./internal/page/attorney_fixtures.go"
- "./internal/page/certificate_provider_fixtures.go"
- "./internal/page/testing_start.go"
- "./cmd/mlpa/main.go"
- "./cmd/mock-notify/main.go"
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/attorney/confirm-your-details.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TestMobile } from '../../support/e2e';

describe('Confirm your details', () => {
beforeEach(() => {
cy.visit('/testing-start?redirect=/mobile-number&lpa.attorneys=1&attorneyProvided=1&loginAs=attorney');
cy.visit('/fixtures/attorney?redirect=/mobile-number');

cy.get('#f-mobile').type(TestMobile);
cy.contains('Continue').click();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Legal rights and responsibilities', () => {
it('can continue to next page', () => {
cy.visit('/testing-start?redirect=/legal-rights-and-responsibilities&lpa.complete=1&lpa.attorneys=1&lpa.signedByDonor=1&attorneyProvided=1&loginAs=attorney');
cy.visit('/fixtures/attorney?redirect=/legal-rights-and-responsibilities');

cy.contains('h1', "Your legal rights and responsibilities")

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/attorney/mobile-number.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TestMobile } from "../../support/e2e";

describe('Mobile number', () => {
beforeEach(() => {
cy.visit('/testing-start?lpa.complete=1&attorneyProvided=1&redirect=/mobile-number&loginAs=attorney');
cy.visit('/fixtures/attorney?redirect=/mobile-number');
});

it('can be completed', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/attorney/read-the-lpa.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Read the LPA', () => {
it('displays the LPA details with actor specific content', () => {
cy.visit('/testing-start?redirect=/read-the-lpa&lpa.complete=1&attorneyProvided=1&loginAs=attorney');
cy.visit('/fixtures/attorney?redirect=/read-the-lpa');

cy.contains('dt', "When attorneys can use the LPA")
cy.contains('dt', "Attorney names")
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/attorney/sign.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe('Sign', () => {
describe('as an attorney', () => {
beforeEach(() => {
cy.visit('/testing-start?cookiesAccepted=1&redirect=/sign&lpa.complete=1&attorneyProvided=1&asCertificateProvider=certified&loginAs=attorney');
cy.visit('/fixtures/attorney?redirect=/sign&progress=signedByCertificateProvider');
});

it('can be signed', () => {
Expand Down Expand Up @@ -31,7 +31,7 @@ describe('Sign', () => {

describe('as a replacement attorney', () => {
beforeEach(() => {
cy.visit('/testing-start?cookiesAccepted=1&redirect=/sign&lpa.complete=1&withReplacementAttorney=1&lpa.signedByDonor=1&asCertificateProvider=certified&replacementAttorneyProvided=1&loginAs=attorney');
cy.visit('/fixtures/attorney?redirect=/sign&is-replacement=1&progress=signedByCertificateProvider');
});

it('can be signed', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/attorney/task-list.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Task list', () => {
beforeEach(() => {
cy.visit('/testing-start?redirect=/task-list&lpa.complete=1&attorneyProvided=1&loginAs=attorney');
cy.visit('/fixtures/attorney?redirect=/task-list');
});

it('shows tasks', () => {
Expand Down
16 changes: 8 additions & 8 deletions cypress/e2e/attorney/trust-corporation.cy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { TestMobile } = require("../../support/e2e");
const { TestMobile, TestEmail } = require("../../support/e2e");

describe('As a trust corporation', () => {
beforeEach(() => {
cy.visit('/testing-start?redirect=/attorney-start&lpa.complete=1&lpa.trustCorporation=complete&useTestShareCode=1&sendAttorneyShare=1&lpa.signedByDonor=1&asCertificateProvider=certified');
cy.visit('/fixtures/attorney?redirect=/attorney-start&is-trust-corporation=1&progress=signedByCertificateProvider&use-test-code=1&email=' + TestEmail);

// start
cy.contains('a', 'Start').click();
Expand All @@ -25,11 +25,11 @@ describe('As a trust corporation', () => {
// confirm your company details
cy.contains(TestMobile);
cy.contains('Confirm your company details');
cy.contains('My company');
cy.contains('First Choice Trust Corporation Ltd.');
cy.contains('555555555');
cy.contains('[email protected]');
cy.contains('123 Fake Street');
cy.contains('FF1 1FF');
cy.contains('2 RICHMOND PLACE');
cy.contains('B14 7ED');
cy.contains('button', 'Continue').click();

// read the lpa
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('As a trust corporation', () => {
cy.contains('button', 'Continue').click();

// what happens next
cy.contains('My company has formally agreed to be an attorney');
cy.contains('First Choice Trust Corporation Ltd. has formally agreed to be an attorney');
cy.contains('a', 'Go to your dashboard');
});

Expand Down Expand Up @@ -89,7 +89,7 @@ describe('As a trust corporation', () => {
cy.contains('button', 'Submit signature').click();

// what happens next
cy.contains('My company has formally agreed to be an attorney');
cy.contains('First Choice Trust Corporation Ltd. has formally agreed to be an attorney');
cy.contains('a', 'Go to your dashboard');
});

Expand Down Expand Up @@ -119,7 +119,7 @@ describe('As a trust corporation', () => {
cy.contains('button', 'Continue').click();

// what happens next
cy.contains('My company has formally agreed to be an attorney');
cy.contains('First Choice Trust Corporation Ltd. has formally agreed to be an attorney');
cy.contains('a', 'Go to your dashboard');
});
});
8 changes: 4 additions & 4 deletions cypress/e2e/attorney/what-happens-when-you-sign-the-lpa.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('What happens when you sign the LPA', () => {
it('as a property and affairs attorney', () => {
cy.visit('/testing-start?redirect=/what-happens-when-you-sign-the-lpa&lpa.complete=1&attorneyProvided=1&lpa.signedByDonor=1&asCertificateProvider=certified&loginAs=attorney');
cy.visit('/fixtures/attorney?redirect=/what-happens-when-you-sign-the-lpa&progress=signedByCertificateProvider');

cy.contains('h1', "What happens when you sign the LPA")
cy.contains('p', "you’re officially saying that you want to be an attorney on")
Expand All @@ -13,23 +13,23 @@ describe('What happens when you sign the LPA', () => {
});

it('as a personal welfare attorney', () => {
cy.visit('/testing-start?redirect=/what-happens-when-you-sign-the-lpa&lpa.complete=1&attorneyProvided=1&lpa.type=hw&loginAs=attorney');
cy.visit('/fixtures/attorney?redirect=/what-happens-when-you-sign-the-lpa&lpa-type=hw&progress=signedByCertificateProvider');

cy.contains('p', "you’re officially saying that you want to be an attorney on")
cy.contains('li', "their personal and medical care")
cy.contains('strong', "cannot act on their behalf")
});

it('as a property and affairs replacement attorney', () => {
cy.visit('/testing-start?redirect=/what-happens-when-you-sign-the-lpa&lpa.complete=1&replacementAttorneyProvided=1&loginAs=attorney');
cy.visit('/fixtures/attorney?redirect=/what-happens-when-you-sign-the-lpa&progress=signedByCertificateProvider&is-replacement=1');

cy.contains('p', "you’re saying that you want to be a replacement attorney")
cy.contains('li', "make decisions about their money or property")
cy.contains('strong', "should only do these things if the donor asks you to")
});

it('as a personal welfare replacement attorney', () => {
cy.visit('/testing-start?redirect=/what-happens-when-you-sign-the-lpa&lpa.complete=1&replacementAttorneyProvided=1&lpa.type=hw&loginAs=attorney');
cy.visit('/fixtures/attorney?redirect=/what-happens-when-you-sign-the-lpa&lpa-type=hw&progress=signedByCertificateProvider&is-replacement=1');

cy.contains('p', "you’re saying that you want to be a replacement attorney ")
cy.contains('li', "their personal and medical care")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Certificate provided', () => {
beforeEach(() => {
cy.visit('/testing-start?redirect=/certificate-provided&loginAs=certificate-provider');
cy.visit('/fixtures/certificate-provider?redirect=/certificate-provided');
});

it('has a button to the dashboard', () => {
Expand Down
10 changes: 5 additions & 5 deletions cypress/e2e/certificate-provider/confirm-your-details.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Confirm your details', () => {
it('shows details', () => {
cy.visit('/testing-start?redirect=/enter-date-of-birth&lpa.certificateProvider=1&asCertificateProvider=1&loginAs=certificate-provider');
cy.visit('/fixtures/certificate-provider?redirect=/enter-date-of-birth');

cy.get('#f-date-of-birth').type('1');
cy.get('#f-date-of-birth-month').type('2');
Expand All @@ -20,8 +20,8 @@ describe('Confirm your details', () => {
cy.url().should('contain', '/your-role');
});

it('redirects to tasklist when details have already been confirmed', () => {
cy.visit('/testing-start?redirect=/confirm-your-details&lpa.certificateProvider=1&asCertificateProvider=1&cp.confirmYourDetails=1&loginAs=certificate-provider');
it('redirects to tasklist when LPA has already been witnessed', () => {
cy.visit('/fixtures/certificate-provider?redirect=/confirm-your-details&progress=signedByDonor');

cy.url().should('contain', '/confirm-your-details');
cy.checkA11yApp();
Expand All @@ -32,8 +32,8 @@ describe('Confirm your details', () => {
cy.contains('li', 'Confirm your details').should('contain', 'Completed');
});

it('redirects to tasklist when LPA has already been witnessed', () => {
cy.visit('/testing-start?redirect=/confirm-your-details&lpa.certificateProvider=1&asCertificateProvider=1&lpa.signedByDonor=1&loginAs=certificate-provider');
it('redirects to tasklist when details have already been confirmed', () => {
cy.visit('/fixtures/certificate-provider?redirect=/confirm-your-details&progress=detailsConfirmed');

cy.url().should('contain', '/confirm-your-details');
cy.checkA11yApp();
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/certificate-provider/enter-date-of-birth.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Enter date of birth', () => {
beforeEach(() => {
cy.visit('/testing-start?redirect=/enter-date-of-birth&asCertificateProvider=1&loginAs=certificate-provider');
cy.visit('/fixtures/certificate-provider?redirect=/enter-date-of-birth');
});

it('can be completed', () => {
Expand Down
14 changes: 6 additions & 8 deletions cypress/e2e/certificate-provider/enter-reference-number.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const { TestEmail } = require("../../support/e2e");

describe('Enter reference number', () => {
it('can enter a valid reference number', { pageLoadTimeout: 6000 }, () => {
cy.visit('/testing-start?lpa.complete=1&startCpFlowDonorHasPaid=1&useTestShareCode=1');
beforeEach(() => {
cy.visit('/fixtures/certificate-provider?redirect=/certificate-provider-start&use-test-code=1&email=' + TestEmail);
});

it('can enter a valid reference number', { pageLoadTimeout: 6000 }, () => {
cy.contains('a', 'Start').click()

cy.checkA11yApp();
Expand All @@ -13,8 +17,6 @@ describe('Enter reference number', () => {
});

it('errors when empty number', () => {
cy.visit('/testing-start?lpa.complete=1&startCpFlowDonorHasPaid=1&useTestShareCode=1');

cy.contains('a', 'Start').click()

cy.checkA11yApp();
Expand All @@ -29,8 +31,6 @@ describe('Enter reference number', () => {
});

it('errors when incorrect code', () => {
cy.visit('/testing-start?lpa.complete=1&startCpFlowDonorHasPaid=1&useTestShareCode=1');

cy.contains('a', 'Start').click()

cy.checkA11yApp();
Expand All @@ -46,8 +46,6 @@ describe('Enter reference number', () => {
});

it('errors when incorrect code length', () => {
cy.visit('/testing-start?lpa.complete=1&startCpFlowDonorHasPaid=1&useTestShareCode=1');

cy.contains('a', 'Start').click()

cy.checkA11yApp();
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/certificate-provider/provide-certificate.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Provide the certificate', () => {
beforeEach(() => {
cy.visit('/testing-start?redirect=/provide-certificate&lpa.complete=1&asCertificateProvider=1&loginAs=certificate-provider');
cy.visit('/fixtures/certificate-provider?redirect=/provide-certificate&progress=signedByDonor');
});

it('can provide the certificate', () => {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/certificate-provider/read-the-lpa.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe('Read the LPA', () => {
describe('when the LPA is signed', () => {
beforeEach(() => {
cy.visit('/testing-start?redirect=/read-the-lpa&lpa.complete=1&asCertificateProvider=1&loginAs=certificate-provider');
cy.visit('/fixtures/certificate-provider?redirect=/read-the-lpa&progress=signedByDonor');
});

it('displays the LPA details and goes to provide certificate', () => {
Expand All @@ -18,7 +18,7 @@ describe('Read the LPA', () => {

describe('when the LPA is not yet signed', () => {
beforeEach(() => {
cy.visit('/testing-start?redirect=/read-the-lpa&lpa.certificateProvider=1&lpa.yourDetails=1&asCertificateProvider=1&loginAs=certificate-provider');
cy.visit('/fixtures/certificate-provider?redirect=/read-the-lpa');
});

it('displays the LPA details and goes to task list', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Select your identity options', () => {
beforeEach(() => {
cy.visit('/testing-start?redirect=/select-your-identity-options&lpa.complete=1&asCertificateProvider=1&loginAs=certificate-provider');
cy.visit('/fixtures/certificate-provider?redirect=/select-your-identity-options');
});

it('can select on first page', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/certificate-provider/start.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Start', () => {
beforeEach(() => {
cy.visit('/testing-start?startCpFlowDonorHasPaid=1');
cy.visit('/certificate-provider-start');
});

it('can be completed', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/certificate-provider/task-list.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Task list', () => {
beforeEach(() => {
cy.visit('/testing-start?redirect=/task-list&lpa.complete=1&asCertificateProvider=1&loginAs=certificate-provider');
cy.visit('/fixtures/certificate-provider?redirect=/task-list&progress=signedByDonor');
});

it('shows tasks', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/certificate-provider/who-is-eligible.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Who is eligible', () => {
beforeEach(() => {
cy.visit('/testing-start?redirect=/certificate-provider-who-is-eligible&loginAs=certificate-provider');
cy.visit('/fixtures/certificate-provider?redirect=/certificate-provider-who-is-eligible');
});

it('can continue', () => {
Expand Down
6 changes: 5 additions & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func App(

rootMux := http.NewServeMux()

rootMux.Handle(paths.TestingStart.String(), page.TestingStart(sessionStore, donorStore, random.String, shareCodeSender, localizer, certificateProviderStore, attorneyStore, logger, time.Now))
rootMux.Handle(paths.TestingStart.String(), page.TestingStart(sessionStore, donorStore, random.String, localizer, certificateProviderStore, attorneyStore, logger, time.Now))

handleRoot := makeHandle(rootMux, errorHandler, sessionStore)

Expand All @@ -109,6 +109,10 @@ func App(
page.SignOut(logger, sessionStore, oneLoginClient, appPublicURL))
handleRoot(paths.Fixtures, None,
page.Fixtures(tmpls.Get("fixtures.gohtml")))
handleRoot(paths.CertificateProviderFixtures, None,
page.CertificateProviderFixtures(tmpls.Get("certificate_provider_fixtures.gohtml"), sessionStore, shareCodeSender, donorStore, certificateProviderStore))
handleRoot(paths.AttorneyFixtures, None,
page.AttorneyFixtures(tmpls.Get("attorney_fixtures.gohtml"), sessionStore, shareCodeSender, donorStore, certificateProviderStore, attorneyStore))
handleRoot(paths.YourLegalRightsAndResponsibilities, None,
page.Guidance(tmpls.Get("your_legal_rights_and_responsibilities_general.gohtml")))
handleRoot(page.Paths.Start, None,
Expand Down
15 changes: 8 additions & 7 deletions internal/app/dashboard_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ministryofjustice/opg-modernising-lpa/internal/actor"
"github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo"
"github.com/ministryofjustice/opg-modernising-lpa/internal/page"
"golang.org/x/exp/maps"
)

// An lpaLink is used to join an actor to an LPA.
Expand Down Expand Up @@ -131,6 +132,11 @@ func (s *dashboardStore) GetAll(ctx context.Context) (donor, attorney, certifica
}

if entry, ok := attorneyMap[attorneyProvidedDetails.LpaID]; ok {
if attorneyProvidedDetails.IsReplacement && !entry.Lpa.SubmittedAt.IsZero() {
delete(attorneyMap, attorneyProvidedDetails.LpaID)
continue
}

entry.Attorney = attorneyProvidedDetails
attorneyMap[attorneyProvidedDetails.LpaID] = entry
continue
Expand All @@ -154,13 +160,8 @@ func (s *dashboardStore) GetAll(ctx context.Context) (donor, attorney, certifica
}
}

for _, value := range certificateProviderMap {
certificateProvider = append(certificateProvider, value)
}

for _, value := range attorneyMap {
attorney = append(attorney, value)
}
certificateProvider = maps.Values(certificateProviderMap)
attorney = maps.Values(attorneyMap)

byUpdatedAt := func(a, b page.LpaAndActorTasks) int {
if a.Lpa.UpdatedAt.After(b.Lpa.UpdatedAt) {
Expand Down
Loading

0 comments on commit 4c0e004

Please sign in to comment.