-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
727 additions
and
167 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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') | ||
}); | ||
}); | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
internal/donor/donorpage/are_you_sure_you_no_longer_need_voucher.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
Oops, something went wrong.