diff --git a/cypress/e2e/donor/check-you-can-sign.cy.js b/cypress/e2e/donor/check-you-can-sign.cy.js new file mode 100644 index 0000000000..a09f10cfeb --- /dev/null +++ b/cypress/e2e/donor/check-you-can-sign.cy.js @@ -0,0 +1,37 @@ +describe('Check you can sign', () => { + describe('first time', () => { + beforeEach(() => { + cy.visit('/fixtures?redirect=/check-you-can-sign'); + }); + + it('can be submitted', () => { + cy.checkA11yApp(); + cy.contains('a', 'Return to task list').should('not.exist'); + + cy.get('#f-yes-no').check({ force: true }); + + cy.contains('button', 'Save and continue').click(); + cy.url().should('contain', '/your-preferred-language'); + }); + + it('errors when empty', () => { + cy.contains('button', 'Save and continue').click(); + + cy.get('.govuk-error-summary').within(() => { + cy.contains('Select yes if you will be able to sign the LPA yourself'); + }); + + cy.contains('fieldset .govuk-error-message', 'Select yes if you will be able to sign the LPA yourself'); + }); + }); + + describe('after completing', () => { + beforeEach(() => { + cy.visit('/fixtures?redirect=/check-you-can-sign&progress=chooseYourAttorneys'); + }); + + it('shows task list button', () => { + cy.contains('a', 'Return to task list'); + }); + }); +}); diff --git a/internal/donor/donorpage/check_you_can_sign.go b/internal/donor/donorpage/check_you_can_sign.go index f30d35e5f4..4743180acd 100644 --- a/internal/donor/donorpage/check_you_can_sign.go +++ b/internal/donor/donorpage/check_you_can_sign.go @@ -12,16 +12,18 @@ import ( ) type checkYouCanSignData struct { - App appcontext.Data - Errors validation.List - Form *form.YesNoForm + App appcontext.Data + Errors validation.List + Form *form.YesNoForm + CanTaskList bool } func CheckYouCanSign(tmpl template.Template, donorStore DonorStore) Handler { return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, provided *donordata.Provided) error { data := &checkYouCanSignData{ - App: appData, - Form: form.NewYesNoForm(provided.Donor.CanSign), + App: appData, + Form: form.NewYesNoForm(provided.Donor.CanSign), + CanTaskList: !provided.Type.Empty(), } if r.Method == http.MethodPost { diff --git a/web/template/donor/check_you_can_sign.gohtml b/web/template/donor/check_you_can_sign.gohtml index 5b7b8b6056..b00cdce61d 100644 --- a/web/template/donor/check_you_can_sign.gohtml +++ b/web/template/donor/check_you_can_sign.gohtml @@ -23,13 +23,18 @@ {{ trHtml .App "ifYouCannotTickTheBoxGuidance" }} - {{ template "radios-fielset" (fieldset . .Form.FieldName .Form.YesNo.String + {{ template "radios-fieldset" (fieldset . .Form.FieldName .Form.YesNo.String (legend "willYouBeAbleToSign" "govuk-fieldset__legend--m") (item .Form.Options.Yes.String "yesByddaf") (item .Form.Options.No.String "noNaFyddaf" "hint" "wellGiveYouMoreInformationAboutWhatToDo") ) }} - {{ template "continue-button" . }} + {{ if .CanTaskList }} + {{ template "buttons" (button .App "saveAndContinue") }} + {{ else }} + {{ template "button" (button .App "saveAndContinue") }} + {{ end }} + {{ template "csrf-field" . }}