Skip to content

Commit

Permalink
Merge pull request #1663 from ministryofjustice/MLPAB-2445-update-pro…
Browse files Browse the repository at this point in the history
…gress-items

MLPAB-2445 Update progress tracker items
  • Loading branch information
hawx authored Dec 5, 2024
2 parents 1979d09 + 7cabb92 commit a46728e
Show file tree
Hide file tree
Showing 16 changed files with 467 additions and 648 deletions.
12 changes: 6 additions & 6 deletions cypress/e2e/attorney/progress.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ describe('Progress', () => {
cy.visit('/fixtures/attorney?redirect=/progress');
cy.checkA11yApp();

cy.contains('li', 'You’ve signed the LPA In progress');
cy.contains('li', 'All attorneys have signed the LPA Not started');
cy.contains('li', 'LPA signed by you Not completed');
cy.contains('li', 'LPA signed by all attorneys Not completed');
});

it('when signed', () => {
cy.visit('/fixtures/attorney?redirect=/progress&progress=signedByAttorney');
cy.checkA11yApp();

cy.contains('li', 'You’ve signed the LPA Completed');
cy.contains('li', 'All attorneys have signed the LPA In progress');
cy.contains('li', 'LPA signed by you Completed');
cy.contains('li', 'LPA signed by all attorneys Not completed');
});

it('when all signed', () => {
cy.visit('/fixtures/attorney?redirect=/progress&progress=signedByAllAttorneys');
cy.checkA11yApp();

cy.contains('li', 'You’ve signed the LPA Completed');
cy.contains('li', 'All attorneys have signed the LPA Completed');
cy.contains('li', 'LPA signed by you Completed');
cy.contains('li', 'LPA signed by all attorneys Completed');
});
});
40 changes: 22 additions & 18 deletions cypress/e2e/donor/lpa-progress.cy.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
describe('LPA progress', () => {
it('when nothing completed', () => {
cy.visit('/fixtures?redirect=/progress');
cy.checkA11yApp();

cy.contains('li', 'You’ve signed your LPA In progress');
cy.contains('li', 'Your certificate provider has provided their certificate Not started');
cy.contains('li', 'Your attorneys have signed your LPA Not started');
cy.contains('li', 'We have received your LPA Not started');
cy.contains('li', 'Your 4-week waiting period has started Not started');
cy.contains('li', 'Your LPA has been registered Not started');
cy.contains('li', 'LPA paid for Not completed');
cy.contains('li', 'Your identity confirmed Not completed');
cy.contains('li', 'LPA signed by you Not completed');
cy.contains('li', 'LPA certificate provided Not completed');
cy.contains('li', 'LPA signed by all attorneys Not completed');
cy.contains('li', 'OPG’s statutory 4-week waiting period begins Not completed');
cy.contains('li', 'LPA registered by OPG Not completed');
})

it('when LPA submitted', () => {
cy.visit('/fixtures?redirect=/progress&progress=signTheLpa');
cy.checkA11yApp();

cy.contains('li', 'You’ve signed your LPA Completed');
cy.contains('li', 'Charlie Cooper has provided their certificate In progress');
cy.contains('li', 'Your attorneys have signed your LPA Not started');
cy.contains('li', 'We have received your LPA Not started');
cy.contains('li', 'Your 4-week waiting period has started Not started');
cy.contains('li', 'Your LPA has been registered Not started');
cy.contains('li', 'LPA paid for Completed');
cy.contains('li', 'Your identity confirmed Completed');
cy.contains('li', 'LPA signed by you Completed');
cy.contains('li', 'LPA certificate provided Not completed');
cy.contains('li', 'LPA signed by all attorneys Not completed');
cy.contains('li', 'OPG’s statutory 4-week waiting period begins Not completed');
cy.contains('li', 'LPA registered by OPG Not completed');
})

it('when certificate provided', () => {
cy.visit('/fixtures?redirect=/progress&progress=signedByCertificateProvider');
cy.checkA11yApp();

cy.contains('li', 'You’ve signed your LPA Completed');
cy.contains('li', 'Charlie Cooper has provided their certificate Completed');
cy.contains('li', 'Your attorneys have signed your LPA In progress');
cy.contains('li', 'We have received your LPA Not started');
cy.contains('li', 'Your 4-week waiting period has started Not started');
cy.contains('li', 'Your LPA has been registered Not started');
cy.contains('li', 'LPA paid for Completed');
cy.contains('li', 'Your identity confirmed Completed');
cy.contains('li', 'LPA signed by you Completed');
cy.contains('li', 'LPA certificate provided Completed');
cy.contains('li', 'LPA signed by all attorneys Not completed');
cy.contains('li', 'OPG’s statutory 4-week waiting period begins Not completed');
cy.contains('li', 'LPA registered by OPG Not completed');
})
});
32 changes: 14 additions & 18 deletions cypress/e2e/supporter/view-lpa.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,24 @@ describe('View LPA', () => {
it('shows progress of LPA', () => {
cy.contains('a', 'M-FAKE').click()

cy.contains('h2', 'LPA progress')

cy.contains('li', 'Sam Smith has paid In progress')
cy.contains('li', 'Sam Smith has confirmed their identity Not started')
cy.contains('li', 'Sam Smith has signed the LPA Not started')
cy.contains('li', 'The certificate provider has provided their certificate Not started')
cy.contains('li', 'All attorneys have signed the LPA Not started')
cy.contains('li', 'OPG has received the LPA Not started')
cy.contains('li', 'The 4-week waiting period has started Not started')
cy.contains('li', 'The LPA has been registered Not started')
cy.contains('li', 'LPA paid for Not completed')
cy.contains('li', 'Sam Smith’s identity confirmed Not completed')
cy.contains('li', 'LPA signed by Sam Smith Not completed')
cy.contains('li', 'LPA certificate provided by Charlie Cooper Not completed')
cy.contains('li', 'LPA signed by all attorneys Not completed')
cy.contains('li', 'OPG’s statutory 4-week waiting period begins Not completed')
cy.contains('li', 'Sam Smith’s LPA registered by OPG Not completed')

cy.visit('/fixtures/supporter?organisation=1&redirect=/dashboard&lpa=1&setLPAProgress=1&progress=registered');

cy.contains('a', 'M-FAKE').click()

cy.contains('li', 'Sam Smith has paid Completed')
cy.contains('li', 'Sam Smith has confirmed their identity Completed')
cy.contains('li', 'Sam Smith has signed the LPA Completed')
cy.contains('li', 'The certificate provider has provided their certificate')
cy.contains('li', 'All attorneys have signed the LPA Completed')
cy.contains('li', 'OPG has received the LPA Completed')
cy.contains('li', 'The 4-week waiting period has started Completed')
cy.contains('li', 'The LPA has been registered Completed')
cy.contains('li', 'LPA paid for Completed')
cy.contains('li', 'Sam Smith’s identity confirmed Completed')
cy.contains('li', 'LPA signed by Sam Smith Completed')
cy.contains('li', 'LPA certificate provided by Charlie Cooper Completed')
cy.contains('li', 'LPA signed by all attorneys Completed')
cy.contains('li', 'OPG’s statutory 4-week waiting period begins Completed')
cy.contains('li', 'Sam Smith’s LPA registered by OPG Completed')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ import (
"github.com/ministryofjustice/opg-modernising-lpa/internal/validation"
)

type lpaProgressData struct {
type progressData struct {
App appcontext.Data
Donor *donordata.Provided
Progress task.Progress
Errors validation.List
}

func LpaProgress(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, progressTracker ProgressTracker) Handler {
func Progress(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, progressTracker ProgressTracker) Handler {
return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error {
lpa, err := lpaStoreResolvingService.Get(r.Context())
if err != nil {
return err
}

data := &lpaProgressData{
data := &progressData{
App: appData,
Donor: donor,
Progress: progressTracker.Progress(lpa),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/mock"
)

func TestGetLpaProgress(t *testing.T) {
func TestGetProgress(t *testing.T) {
w := httptest.NewRecorder()
r, _ := http.NewRequest(http.MethodGet, "/", nil)

Expand All @@ -26,25 +26,25 @@ func TestGetLpaProgress(t *testing.T) {
progressTracker := newMockProgressTracker(t)
progressTracker.EXPECT().
Progress(lpa).
Return(task.Progress{DonorSigned: task.ProgressTask{State: task.StateInProgress}})
Return(task.Progress{DonorSigned: task.ProgressTask{Done: true}})

template := newMockTemplate(t)
template.EXPECT().
Execute(w, &lpaProgressData{
Execute(w, &progressData{
App: testAppData,
Donor: &donordata.Provided{LpaUID: "lpa-uid"},
Progress: task.Progress{DonorSigned: task.ProgressTask{State: task.StateInProgress}},
Progress: task.Progress{DonorSigned: task.ProgressTask{Done: true}},
}).
Return(nil)

err := LpaProgress(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid"})
err := Progress(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid"})
resp := w.Result()

assert.Nil(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
}

func TestGetLpaProgressWhenLpaStoreClientErrors(t *testing.T) {
func TestGetProgressWhenLpaStoreClientErrors(t *testing.T) {
w := httptest.NewRecorder()
r, _ := http.NewRequest(http.MethodGet, "/", nil)

Expand All @@ -53,11 +53,11 @@ func TestGetLpaProgressWhenLpaStoreClientErrors(t *testing.T) {
Get(r.Context()).
Return(nil, expectedError)

err := LpaProgress(nil, lpaStoreResolvingService, nil)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid"})
err := Progress(nil, lpaStoreResolvingService, nil)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid"})
assert.Equal(t, expectedError, err)
}

func TestGetLpaProgressOnTemplateError(t *testing.T) {
func TestGetProgressOnTemplateError(t *testing.T) {
w := httptest.NewRecorder()
r, _ := http.NewRequest(http.MethodGet, "/", nil)

Expand All @@ -76,6 +76,6 @@ func TestGetLpaProgressOnTemplateError(t *testing.T) {
Execute(w, mock.Anything).
Return(expectedError)

err := LpaProgress(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid"})
err := Progress(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid"})
assert.Equal(t, expectedError, err)
}
2 changes: 1 addition & 1 deletion internal/donor/donorpage/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ func Register(
Guidance(tmpls.Get("you_have_submitted_your_lpa.gohtml")))

handleWithDonor(donor.PathProgress, page.None,
LpaProgress(tmpls.Get("lpa_progress.gohtml"), lpaStoreResolvingService, progressTracker))
Progress(tmpls.Get("progress.gohtml"), lpaStoreResolvingService, progressTracker))

handleWithDonor(donor.PathUploadEvidenceSSE, page.None,
UploadEvidenceSSE(documentStore, 3*time.Minute, 2*time.Second, time.Now))
Expand Down
4 changes: 2 additions & 2 deletions internal/supporter/supporterpage/view_lpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ func TestGetViewLPA(t *testing.T) {
progressTracker := newMockProgressTracker(t)
progressTracker.EXPECT().
Progress(lpa).
Return(task.Progress{Paid: task.ProgressTask{State: task.StateInProgress}})
Return(task.Progress{Paid: task.ProgressTask{Done: true}})

template := newMockTemplate(t)
template.EXPECT().
Execute(w, &viewLPAData{
App: testAppData,
Lpa: lpa,
Progress: task.Progress{Paid: task.ProgressTask{State: task.StateInProgress}},
Progress: task.Progress{Paid: task.ProgressTask{Done: true}},
}).
Return(nil)

Expand Down
Loading

0 comments on commit a46728e

Please sign in to comment.