Skip to content

Commit

Permalink
Hide submitted replacement attorney cards
Browse files Browse the repository at this point in the history
And create a brand new fixtures page for attorneys
  • Loading branch information
hawx committed Sep 27, 2023
1 parent f6143cd commit 5fafb47
Show file tree
Hide file tree
Showing 17 changed files with 388 additions and 123 deletions.
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
2 changes: 2 additions & 0 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func App(
page.SignOut(logger, sessionStore, oneLoginClient, appPublicURL))
handleRoot(paths.Fixtures, None,
page.Fixtures(tmpls.Get("fixtures.gohtml")))
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 5fafb47

Please sign in to comment.