Skip to content

Commit

Permalink
Merge 2199b1f into 26cf3bb
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx authored Oct 31, 2024
2 parents 26cf3bb + 2199b1f commit eea7373
Show file tree
Hide file tree
Showing 33 changed files with 727 additions and 167 deletions.
12 changes: 6 additions & 6 deletions cmd/event-received/mock_Handler_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cypress/e2e/donor/check-your-details.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ describe('Check your details', () => {
cy.visit('/fixtures?redirect=/check-your-details&progress=payForTheLpa&feeType=NoFee&paymentTaskProgress=Pending');
cy.contains('button', 'Continue').click();

cy.url().should('contain', '/we-have-received-voucher-details');
cy.url().should('contain', '/we-have-contacted-voucher');
cy.checkA11yApp();
cy.contains('no fee (exemption)');
cy.contains('We are processing your LPA fee request');
});
});
81 changes: 81 additions & 0 deletions cypress/e2e/donor/what-you-can-do-now.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,85 @@ describe('what you can do now', () => {
cy.url().should('contain', '/what-happens-next-registering-with-court-of-protection')
})
})

context('want a different voucher', () => {
beforeEach(() => {
cy.visit('/fixtures?redirect=/what-is-vouching&progress=payForTheLpa');
cy.get('input[name="yes-no"]').check('yes', { force: true });
cy.contains('button', 'Save and continue').click();
cy.get('#f-first-names').type('Shopping');
cy.get('#f-last-name').type('Voucher');
cy.get('#f-email').type('[email protected]');
cy.contains('button', 'Save and continue').click();
cy.contains('button', 'Continue').click();
cy.contains('a', 'Confirm my identity another way').click();
})

it('keeps the voucher until choice is made', () => {
cy.visitLpa('/enter-voucher');
cy.get('#f-first-names').should('have.value', 'Shopping');
cy.get('#f-last-name').should('have.value', 'Voucher');
cy.get('#f-email').should('have.value', '[email protected]');
});

it('can choose to get ID documents', () => {
cy.contains('label', 'I will get or find ID documents and confirm my own identity').click();
cy.contains('button', 'Continue').click();

cy.url().should('contain', '/are-you-sure-you-no-longer-need-voucher');
cy.checkA11yApp();

cy.contains('button', 'Shopping Voucher no longer needed').click();

cy.contains('You have chosen to find, replace or get new ID');
cy.contains('a', 'Continue').click();

cy.url().should('contain', '/task-list')
});

it('can choose to add a voucher', () => {
cy.contains('label', 'I have someone else who can vouch for me').click();
cy.contains('button', 'Continue').click();

cy.url().should('contain', '/are-you-sure-you-no-longer-need-voucher');
cy.checkA11yApp();

cy.contains('button', 'Shopping Voucher no longer needed').click();

cy.contains('You have chosen to ask someone else');
cy.contains('a', 'Continue').click();

cy.url().should('contain', '/enter-voucher')
})

it('can choose to withdraw LPA', () => {
cy.contains('label', 'I no longer want to make this LPA').click();
cy.contains('button', 'Continue').click();

cy.url().should('contain', '/are-you-sure-you-no-longer-need-voucher');
cy.checkA11yApp();

cy.contains('button', 'Shopping Voucher no longer needed').click();

cy.contains('You have told us you no longer want to make this LPA');
cy.contains('a', 'Continue').click();

cy.url().should('contain', '/withdraw-this-lpa')
})

it('can choose to apply to court of protection', () => {
cy.contains('label', 'I will apply to the Court of Protection to register this LPA').click();
cy.contains('button', 'Continue').click();

cy.url().should('contain', '/are-you-sure-you-no-longer-need-voucher');
cy.checkA11yApp();

cy.contains('button', 'Shopping Voucher no longer needed').click();

cy.contains('You have chosen to have your LPA reviewed by the Court of Protection');
cy.contains('a', 'Continue').click();

cy.url().should('contain', '/what-happens-next-registering-with-court-of-protection')
});
});
})
18 changes: 9 additions & 9 deletions internal/donor/donordata/enum_novoucherdecision.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/donor/donordata/no_voucher_decision.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package donordata
type NoVoucherDecision uint8

const (
ProveOwnID NoVoucherDecision = iota + 1 // prove-own-id
ProveOwnIdentity NoVoucherDecision = iota + 1 // prove-own-identity
SelectNewVoucher // select-new-voucher
WithdrawLPA // withdraw-lpa
ApplyToCOP // apply-to-cop
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package donorpage

import (
"net/http"
"net/url"

"github.com/ministryofjustice/opg-go-common/template"
"github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext"
"github.com/ministryofjustice/opg-modernising-lpa/internal/donor"
"github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/form"
"github.com/ministryofjustice/opg-modernising-lpa/internal/validation"
)

type areYouSureYouNoLongerNeedVoucherData struct {
App appcontext.Data
Errors validation.List
Donor *donordata.Provided
}

func AreYouSureYouNoLongerNeedVoucher(tmpl template.Template, donorStore DonorStore) Handler {
return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, provided *donordata.Provided) error {
data := &areYouSureYouNoLongerNeedVoucherData{
App: appData,
Donor: provided,
}

if r.Method == http.MethodPost {
voucherFullName := provided.Voucher.FullName()

doNext, err := donordata.ParseNoVoucherDecision(r.FormValue("choice"))
if err != nil {
return err
}

provided.WantVoucher = form.YesNoUnknown
nextPage := handleDoNext(doNext, provided).Format(provided.LpaID)

if err := donorStore.DeleteVoucher(r.Context(), provided); err != nil {
return err
}

return donor.PathWeHaveInformedVoucherNoLongerNeeded.RedirectQuery(w, r, appData, provided, url.Values{
"choice": {r.FormValue("choice")},
"next": {nextPage},
"voucherFullName": {voucherFullName},
})
}

return tmpl(w, data)
}
}
Loading

0 comments on commit eea7373

Please sign in to comment.