-
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
14 changed files
with
597 additions
and
33 deletions.
There are no files selected for viewing
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,48 @@ | ||
describe('Confirm your name', () => { | ||
beforeEach(() => { | ||
cy.visit('/fixtures/voucher?redirect=/confirm-your-name'); | ||
}); | ||
|
||
it('shows my name', () => { | ||
cy.checkA11yApp(); | ||
|
||
cy.contains('Vivian'); | ||
cy.contains('Vaughn'); | ||
|
||
cy.contains('button', 'Continue').click(); | ||
cy.get('ul li:first-child').should('contain', 'Completed'); | ||
}); | ||
|
||
it('can update my name', () => { | ||
cy.contains('div', 'Vivian').contains('a', 'Change').click(); | ||
|
||
cy.url().should('contain', '/your-name') | ||
cy.checkA11yApp(); | ||
cy.get('#f-first-names').clear().type('Barry'); | ||
cy.contains('button', 'Save and continue').click(); | ||
|
||
cy.url().should('contain', '/confirm-your-name') | ||
cy.contains('Barry'); | ||
|
||
cy.contains('button', 'Continue').click(); | ||
cy.get('ul li:first-child').should('contain', 'Completed'); | ||
}); | ||
|
||
it('warns when last name matches donor', () => { | ||
cy.contains('div', 'Vivian').contains('a', 'Change').click(); | ||
|
||
cy.url().should('contain', '/your-name') | ||
cy.checkA11yApp(); | ||
cy.get('#f-last-name').clear().type('Smith'); | ||
cy.contains('button', 'Save and continue').click(); | ||
|
||
cy.contains('button', 'Continue').click(); | ||
|
||
cy.url().should('contain', '/confirm-allowed-to-vouch'); | ||
cy.checkA11yApp(); | ||
|
||
cy.contains('label', 'Yes').click(); | ||
cy.contains('button', 'Continue').click(); | ||
cy.get('ul li:first-child').should('contain', 'Completed'); | ||
}); | ||
}); |
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
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
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,57 @@ | ||
package voucherpage | ||
|
||
import ( | ||
"errors" | ||
"net/http" | ||
|
||
"github.com/ministryofjustice/opg-go-common/template" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/form" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/task" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/validation" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/voucher" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/voucher/voucherdata" | ||
) | ||
|
||
type confirmAllowedToVouchData struct { | ||
App appcontext.Data | ||
Errors validation.List | ||
Form *form.YesNoForm | ||
Lpa *lpadata.Lpa | ||
} | ||
|
||
func ConfirmAllowedToVouch(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, voucherStore VoucherStore) Handler { | ||
return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, provided *voucherdata.Provided) error { | ||
lpa, err := lpaStoreResolvingService.Get(r.Context()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
data := &confirmAllowedToVouchData{ | ||
App: appData, | ||
Form: form.NewYesNoForm(form.YesNoUnknown), | ||
Lpa: lpa, | ||
} | ||
|
||
if r.Method == http.MethodPost { | ||
data.Form = form.ReadYesNoForm(r, "yesIfAllowedToVouch") | ||
data.Errors = data.Form.Validate() | ||
|
||
if data.Errors.None() { | ||
if data.Form.YesNo.IsNo() { | ||
return errors.New("// TODO there should be a page here but it hasn't been built yet") | ||
} | ||
|
||
provided.Tasks.ConfirmYourName = task.StateCompleted | ||
if err := voucherStore.Put(r.Context(), provided); err != nil { | ||
return err | ||
} | ||
|
||
return voucher.PathTaskList.Redirect(w, r, appData, appData.LpaID) | ||
} | ||
} | ||
|
||
return tmpl(w, data) | ||
} | ||
} |
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
Oops, something went wrong.