-
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
12 changed files
with
280 additions
and
20 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
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,33 @@ | ||
describe('View LPA', () => { | ||
beforeEach(() => { | ||
cy.visit('/fixtures/supporter?organisation=1&redirect=/dashboard&lpa=1'); | ||
cy.checkA11yApp(); | ||
}); | ||
|
||
it('can continue making an LPA', () => { | ||
cy.contains('a', 'M-FAKE').click() | ||
|
||
cy.url().should('contain', '/view-lpa'); | ||
cy.checkA11yApp(); | ||
|
||
cy.contains('h1', 'Property and affairs LPA') | ||
cy.contains('div', 'M-FAKE') | ||
|
||
cy.contains('a', 'Donor access') | ||
cy.contains('a', 'View LPA summary') | ||
cy.contains('a', 'Go to task list').click() | ||
|
||
cy.url().should('contain', '/task-list'); | ||
cy.checkA11yApp(); | ||
|
||
cy.contains('Provide your details').click() | ||
|
||
cy.url().should('contain', '/your-details'); | ||
cy.checkA11yApp(); | ||
|
||
cy.get('#f-first-names').type('2'); | ||
cy.contains('button', 'Continue').click(); | ||
cy.contains('a', 'Dashboard').click(); | ||
cy.contains('Sam2 Smith'); | ||
}); | ||
}) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package supporter | ||
|
||
import ( | ||
"errors" | ||
"net/http" | ||
|
||
"github.com/ministryofjustice/opg-go-common/template" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/actor" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/page" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/validation" | ||
) | ||
|
||
type viewLPAData struct { | ||
App page.AppData | ||
Errors validation.List | ||
Donor *actor.DonorProvidedDetails | ||
} | ||
|
||
func ViewLPA(tmpl template.Template, donorStore DonorStore) Handler { | ||
return func(appData page.AppData, w http.ResponseWriter, r *http.Request, organisation *actor.Organisation) error { | ||
sessionData, err := page.SessionDataFromContext(r.Context()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
lpaID := r.FormValue("id") | ||
if lpaID == "" { | ||
return errors.New("lpaID missing from query") | ||
} | ||
|
||
sessionData.LpaID = lpaID | ||
|
||
ctx := page.ContextWithSessionData(r.Context(), sessionData) | ||
|
||
donor, err := donorStore.Get(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return tmpl(w, &viewLPAData{ | ||
App: appData, | ||
Donor: donor, | ||
}) | ||
} | ||
} |
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,92 @@ | ||
package supporter | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"github.com/ministryofjustice/opg-modernising-lpa/internal/actor" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/page" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetViewLPA(t *testing.T) { | ||
w := httptest.NewRecorder() | ||
r, _ := http.NewRequestWithContext(page.ContextWithSessionData(context.Background(), &page.SessionData{}), http.MethodGet, "/?id=lpa-id", nil) | ||
|
||
donor := &actor.DonorProvidedDetails{LpaID: "lpa-id"} | ||
|
||
donorStore := newMockDonorStore(t) | ||
donorStore.EXPECT(). | ||
Get(page.ContextWithSessionData(r.Context(), &page.SessionData{LpaID: "lpa-id"})). | ||
Return(donor, nil) | ||
|
||
template := newMockTemplate(t) | ||
template.EXPECT(). | ||
Execute(w, &viewLPAData{ | ||
App: testAppData, | ||
Donor: donor, | ||
}). | ||
Return(nil) | ||
|
||
err := ViewLPA(template.Execute, donorStore)(testAppData, w, r, &actor.Organisation{}) | ||
|
||
assert.Nil(t, err) | ||
} | ||
|
||
func TestGetViewLPAWithSessionMissing(t *testing.T) { | ||
w := httptest.NewRecorder() | ||
r, _ := http.NewRequestWithContext(page.ContextWithSessionData(context.Background(), &page.SessionData{}), http.MethodGet, "/", nil) | ||
|
||
err := ViewLPA(nil, nil)(testAppData, w, r, &actor.Organisation{}) | ||
|
||
assert.Error(t, err) | ||
} | ||
|
||
func TestGetViewLPAMissingLPAId(t *testing.T) { | ||
w := httptest.NewRecorder() | ||
r, _ := http.NewRequest(http.MethodGet, "/", nil) | ||
|
||
err := ViewLPA(nil, nil)(testAppData, w, r, &actor.Organisation{}) | ||
|
||
assert.Error(t, err) | ||
} | ||
|
||
func TestGetViewLPAWithDonorStoreError(t *testing.T) { | ||
w := httptest.NewRecorder() | ||
r, _ := http.NewRequestWithContext(page.ContextWithSessionData(context.Background(), &page.SessionData{}), http.MethodGet, "/?id=lpa-id", nil) | ||
|
||
donorStore := newMockDonorStore(t) | ||
donorStore.EXPECT(). | ||
Get(page.ContextWithSessionData(r.Context(), &page.SessionData{LpaID: "lpa-id"})). | ||
Return(nil, expectedError) | ||
|
||
err := ViewLPA(nil, donorStore)(testAppData, w, r, &actor.Organisation{}) | ||
|
||
assert.Error(t, err) | ||
} | ||
|
||
func TestGetViewLPAWhenTemplateError(t *testing.T) { | ||
w := httptest.NewRecorder() | ||
r, _ := http.NewRequestWithContext(page.ContextWithSessionData(context.Background(), &page.SessionData{}), http.MethodGet, "/?id=lpa-id", nil) | ||
|
||
donor := &actor.DonorProvidedDetails{LpaID: "lpa-id"} | ||
|
||
donorStore := newMockDonorStore(t) | ||
donorStore.EXPECT(). | ||
Get(page.ContextWithSessionData(r.Context(), &page.SessionData{LpaID: "lpa-id"})). | ||
Return(donor, nil) | ||
|
||
template := newMockTemplate(t) | ||
template.EXPECT(). | ||
Execute(w, &viewLPAData{ | ||
App: testAppData, | ||
Donor: donor, | ||
}). | ||
Return(expectedError) | ||
|
||
err := ViewLPA(template.Execute, donorStore)(testAppData, w, r, &actor.Organisation{}) | ||
|
||
assert.Error(t, err) | ||
} |
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,24 @@ | ||
{{ template "page" . }} | ||
|
||
{{ define "pageTitle" }}{{ trFormat .App "viewLPA" }}{{ end }} | ||
|
||
{{ define "main" }} | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-full"> | ||
<span class="govuk-caption-xl">{{ .Donor.Donor.FullName }}</span> | ||
<h1 class="govuk-heading-xl">{{ tr .App .Donor.Type.String }} {{tr .App "lpa"}}</h1> | ||
|
||
<div class="govuk-inset-text"> | ||
<span class="govuk-!-font-weight-bold">{{ tr .App "referenceNumber" }}</span> {{ .Donor.LpaUID }} | ||
</div> | ||
|
||
<div class="govuk-button-group"> | ||
<a class="govuk-button govuk-button--secondary" href="{{ link $.App (global.Paths.TaskList.Format .Donor.LpaID) }}" data-module="govuk-button">{{ tr .App "goToTaskList" }}</a> | ||
<a class="govuk-button govuk-button--secondary" href="#" data-module="govuk-button">{{ tr .App "viewLPASummary" }}</a> | ||
<a class="govuk-button govuk-button--secondary" href="#" data-module="govuk-button">{{ tr .App "donorAccess" }}</a> | ||
</div> | ||
|
||
<hr class="govuk-section-break govuk-section-break--m govuk-section-break--visible"> | ||
</div> | ||
</div> | ||
{{ end }} |