Skip to content

Commit

Permalink
MLPAB-2198 Allow attorney to opt-out (#1368)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx authored Jul 24, 2024
1 parent 98ce776 commit ed9a0bb
Show file tree
Hide file tree
Showing 41 changed files with 2,340 additions and 287 deletions.
21 changes: 21 additions & 0 deletions cypress/e2e/attorney/opt-out.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { TestEmail, randomShareCode } = require("../../support/e2e");

describe('Opting out', () => {
it('stops me being attorney', () => {
const shareCode = randomShareCode();
cy.visit(`/fixtures/attorney?redirect=&withShareCode=${shareCode}&email=${TestEmail}`);

cy.visit('/attorney-enter-reference-number-opt-out');
cy.checkA11yApp();
cy.get('#f-reference-number').type(shareCode);
cy.contains('button', 'Continue').click();

cy.url().should('contain', '/confirm-you-do-not-want-to-be-an-attorney');
cy.checkA11yApp();
cy.contains('M-FAKE-');

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

cy.url().should('contain', '/you-have-decided-not-to-be-an-attorney');
});
});
22 changes: 22 additions & 0 deletions cypress/e2e/attorney/sign.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ describe('Sign', () => {
cy.contains('h1', 'You’ve formally agreed to be an attorney');
});

it('can be opted out of', () => {
cy.contains('a', 'I do not want to be an attorney').click();

cy.url().should('contain', '/confirm-you-do-not-want-to-be-an-attorney');
cy.checkA11yApp();
cy.contains('button', 'Confirm').click();

cy.url().should('contain', '/you-have-decided-not-to-be-an-attorney');
cy.checkA11yApp();
});

it('shows an error when not selected', () => {
cy.contains('button', 'Submit signature').click();

Expand Down Expand Up @@ -48,6 +59,17 @@ describe('Sign', () => {
cy.contains('h1', 'You’ve formally agreed to be a replacement attorney');
});

it('can be opted out of', () => {
cy.contains('a', 'I do not want to be an attorney').click();

cy.url().should('contain', '/confirm-you-do-not-want-to-be-an-attorney');
cy.checkA11yApp();
cy.contains('button', 'Confirm').click();

cy.url().should('contain', '/you-have-decided-not-to-be-an-attorney');
cy.checkA11yApp();
});

it('shows an error when not selected', () => {
cy.contains('button', 'Submit signature').click();

Expand Down
258 changes: 129 additions & 129 deletions cypress/e2e/attorney/trust-corporation.cy.js
Original file line number Diff line number Diff line change
@@ -1,133 +1,133 @@
const { TestMobile, TestEmail, randomShareCode } = require("../../support/e2e");

describe('As a trust corporation', () => {
beforeEach(() => {
const shareCode = randomShareCode()
cy.visit(`/fixtures/attorney?redirect=/attorney-start&is-trust-corporation=1&progress=readTheLPA&&withShareCode=${shareCode}&email=${TestEmail}`);

// start
cy.contains('a', 'Start').click();
cy.get('form').submit();

// enter reference number
cy.get('#f-reference-number').type(shareCode);
cy.contains('button', 'Save and continue').click();

// acting as an attorney
cy.contains('We have identified the trust corporation’s attorney reference number');
cy.contains('a', 'Continue').click();

// task list
cy.contains('a', 'Confirm your details').click();

// mobile number
cy.get('#f-mobile').type(TestMobile);
cy.contains('button', 'Save and continue').click();

// language preferences
cy.get('[name="language-preference"]').check('cy', { force: true })
cy.contains('button', 'Save and continue').click()

// confirm your company details
cy.contains('07700 900 000');
cy.contains('Welsh');
cy.contains('Confirm your company details');
cy.contains('First Choice Trust Corporation Ltd.');
cy.contains('555555555');
cy.contains('[email protected]');
cy.contains('2 RICHMOND PLACE');
cy.contains('B14 7ED');
cy.contains('button', 'Continue').click();

// task list
cy.contains('Read the LPA').click();
cy.contains('button', 'Continue').click();

// legal rights and responsibilities
cy.contains('Sign the LPA').click();
cy.contains('Before signing, you must read the trust corporation’s legal rights and responsibilities as an attorney.');
cy.contains('a', 'Continue').click();

// what happens when you sign the lpa
cy.contains('What happens when you sign the LPA');
cy.contains('a', 'Continue to signing page').click();
});

it('allows a single signatory', () => {
// sign
cy.contains('Sign the LPA on behalf of the trust corporation');
cy.get('#f-first-names').type('Sign');
cy.get('#f-last-name').type('Signson');
cy.get('#f-professional-title').type('Pro signer');
cy.get('#f-confirm').check({ force: true });
cy.contains('button', 'Submit signature').click();

// would like a 2nd signatory
cy.contains('label', 'No').click();
cy.contains('button', 'Continue').click();

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

it('allows a second signatory', () => {
// sign
cy.contains('Sign the LPA on behalf of the trust corporation');
cy.get('#f-first-names').type('Sign');
cy.get('#f-last-name').type('Signson');
cy.get('#f-professional-title').type('Pro signer');
cy.get('#f-confirm').check({ force: true });
cy.contains('button', 'Submit signature').click();

// would like a 2nd signatory
cy.contains('label', 'Yes').click();
cy.contains('button', 'Continue').click();

// task list
cy.contains('a', 'Return to task list').click();
cy.contains('Sign the LPA (signatory 1)');
cy.contains('Sign the LPA (signatory 2)').click();

// sign
cy.get('#f-first-names').type('Sign2');
cy.get('#f-last-name').type('Signson2');
cy.get('#f-professional-title').type('Pro signer2');
cy.get('#f-confirm').check({ force: true });
cy.contains('button', 'Submit signature').click();

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

it('can remove second signatory', () => {
// sign
cy.contains('Sign the LPA on behalf of the trust corporation');
cy.get('#f-first-names').type('Sign');
cy.get('#f-last-name').type('Signson');
cy.get('#f-professional-title').type('Pro signer');
cy.get('#f-confirm').check({ force: true });
cy.contains('button', 'Submit signature').click();

// would like a 2nd signatory
cy.contains('label', 'Yes').click();
cy.contains('button', 'Continue').click();

// task list
cy.contains('a', 'Return to task list').click();
cy.contains('Sign the LPA (signatory 1)');
cy.contains('Sign the LPA (signatory 2)').click();

// sign
cy.contains('a', 'The trust corporation no longer requires a second signatory').click();

// would like a 2nd signatory
cy.contains('label', 'No').click();
cy.contains('button', 'Continue').click();

// what happens next
cy.contains('First Choice Trust Corporation Ltd. has formally agreed to be an attorney');
cy.contains('a', 'Go to your dashboard');
});
beforeEach(() => {
const shareCode = randomShareCode()
cy.visit(`/fixtures/attorney?redirect=/attorney-start&is-trust-corporation=1&progress=readTheLPA&&withShareCode=${shareCode}&email=${TestEmail}`);

// start
cy.contains('a', 'Start').click();
cy.get('form').submit();

// enter reference number
cy.get('#f-reference-number').type(shareCode);
cy.contains('button', 'Save and continue').click();

// acting as an attorney
cy.contains('We have identified the trust corporation’s attorney reference number');
cy.contains('a', 'Continue').click();

// task list
cy.contains('a', 'Confirm your details').click();

// mobile number
cy.get('#f-mobile').type(TestMobile);
cy.contains('button', 'Save and continue').click();

// language preferences
cy.get('[name="language-preference"]').check('cy', { force: true })
cy.contains('button', 'Save and continue').click()

// confirm your company details
cy.contains('07700 900 000');
cy.contains('Welsh');
cy.contains('Confirm your company details');
cy.contains('First Choice Trust Corporation Ltd.');
cy.contains('555555555');
cy.contains('[email protected]');
cy.contains('2 RICHMOND PLACE');
cy.contains('B14 7ED');
cy.contains('button', 'Continue').click();

// task list
cy.contains('Read the LPA').click();
cy.contains('button', 'Continue').click();

// legal rights and responsibilities
cy.contains('Sign the LPA').click();
cy.contains('Before signing, you must read the trust corporation’s legal rights and responsibilities as an attorney.');
cy.contains('a', 'Continue').click();

// what happens when you sign the lpa
cy.contains('What happens when you sign the LPA');
cy.contains('a', 'Continue to signing page').click();
});

it('allows a single signatory', () => {
// sign
cy.contains('Sign the LPA on behalf of the trust corporation');
cy.get('#f-first-names').type('Sign');
cy.get('#f-last-name').type('Signson');
cy.get('#f-professional-title').type('Pro signer');
cy.get('#f-confirm').check({ force: true });
cy.contains('button', 'Submit signature').click();

// would like a 2nd signatory
cy.contains('label', 'No').click();
cy.contains('button', 'Continue').click();

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

it('allows a second signatory', () => {
// sign
cy.contains('Sign the LPA on behalf of the trust corporation');
cy.get('#f-first-names').type('Sign');
cy.get('#f-last-name').type('Signson');
cy.get('#f-professional-title').type('Pro signer');
cy.get('#f-confirm').check({ force: true });
cy.contains('button', 'Submit signature').click();

// would like a 2nd signatory
cy.contains('label', 'Yes').click();
cy.contains('button', 'Continue').click();

// task list
cy.visitLpa('/task-list');
cy.contains('Sign the LPA (signatory 1)');
cy.contains('Sign the LPA (signatory 2)').click();

// sign
cy.get('#f-first-names').type('Sign2');
cy.get('#f-last-name').type('Signson2');
cy.get('#f-professional-title').type('Pro signer2');
cy.get('#f-confirm').check({ force: true });
cy.contains('button', 'Submit signature').click();

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

it('can remove second signatory', () => {
// sign
cy.contains('Sign the LPA on behalf of the trust corporation');
cy.get('#f-first-names').type('Sign');
cy.get('#f-last-name').type('Signson');
cy.get('#f-professional-title').type('Pro signer');
cy.get('#f-confirm').check({ force: true });
cy.contains('button', 'Submit signature').click();

// would like a 2nd signatory
cy.contains('label', 'Yes').click();
cy.contains('button', 'Continue').click();

// task list
cy.visitLpa('/task-list');
cy.contains('Sign the LPA (signatory 1)');
cy.contains('Sign the LPA (signatory 2)').click();

// sign
cy.contains('a', 'The trust corporation no longer requires a second signatory').click();

// would like a 2nd signatory
cy.contains('label', 'No').click();
cy.contains('button', 'Continue').click();

// what happens next
cy.contains('First Choice Trust Corporation Ltd. has formally agreed to be an attorney');
cy.contains('a', 'Go to your dashboard');
});
});
2 changes: 2 additions & 0 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ func App(
dashboardStore,
lpaStoreClient,
lpaStoreResolvingService,
notifyClient,
appPublicURL,
)

donor.Register(
Expand Down
18 changes: 18 additions & 0 deletions internal/app/attorney_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app
import (
"context"
"errors"
"fmt"
"time"

"github.com/ministryofjustice/opg-modernising-lpa/internal/actor"
Expand Down Expand Up @@ -74,3 +75,20 @@ func (s *attorneyStore) Put(ctx context.Context, attorney *actor.AttorneyProvide
attorney.UpdatedAt = s.now()
return s.dynamoClient.Put(ctx, attorney)
}

func (s *attorneyStore) Delete(ctx context.Context) error {
data, err := page.SessionDataFromContext(ctx)
if err != nil {
return err
}

if data.LpaID == "" || data.SessionID == "" {
return errors.New("attorneyStore.Delete requires LpaID and SessionID")
}

if err := s.dynamoClient.DeleteOne(ctx, dynamo.LpaKey(data.LpaID), dynamo.AttorneyKey(data.SessionID)); err != nil {
return fmt.Errorf("error deleting attorney: %w", err)
}

return nil
}
Loading

0 comments on commit ed9a0bb

Please sign in to comment.