-
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.
MLPAB-2213: Fix attorney and replacements duplicates bug (#1376)
- Loading branch information
Showing
29 changed files
with
300 additions
and
160 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
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 |
---|---|---|
@@ -1 +1 @@ | ||
nodejs 20.15.1 | ||
nodejs 20.16.0 |
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
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,33 @@ | ||
package donor | ||
|
||
import ( | ||
"net/http" | ||
"net/url" | ||
|
||
"github.com/ministryofjustice/opg-go-common/template" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/actor" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/page" | ||
"github.com/ministryofjustice/opg-modernising-lpa/internal/validation" | ||
) | ||
|
||
type chooseAttorneysGuidanceData struct { | ||
App page.AppData | ||
Errors validation.List | ||
Donor *actor.DonorProvidedDetails | ||
} | ||
|
||
func ChooseAttorneysGuidance(tmpl template.Template, newUID func() actoruid.UID) Handler { | ||
return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { | ||
data := &chooseAttorneysGuidanceData{ | ||
App: appData, | ||
Donor: donor, | ||
} | ||
|
||
if r.Method == http.MethodPost { | ||
return page.Paths.ChooseAttorneys.RedirectQuery(w, r, appData, donor, url.Values{"id": {newUID().String()}}) | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package donor | ||
|
||
import ( | ||
"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" | ||
"github.com/stretchr/testify/mock" | ||
) | ||
|
||
func TestGetChooseAttorneysGuidance(t *testing.T) { | ||
w := httptest.NewRecorder() | ||
r, _ := http.NewRequest(http.MethodGet, "/", nil) | ||
|
||
template := newMockTemplate(t) | ||
template.EXPECT(). | ||
Execute(w, &chooseAttorneysGuidanceData{ | ||
App: testAppData, | ||
Donor: &actor.DonorProvidedDetails{}, | ||
}). | ||
Return(nil) | ||
|
||
err := ChooseAttorneysGuidance(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) | ||
resp := w.Result() | ||
|
||
assert.Nil(t, err) | ||
assert.Equal(t, http.StatusOK, resp.StatusCode) | ||
} | ||
|
||
func TestGetChooseAttorneysGuidanceWhenTemplateErrors(t *testing.T) { | ||
w := httptest.NewRecorder() | ||
r, _ := http.NewRequest(http.MethodGet, "/", nil) | ||
|
||
template := newMockTemplate(t) | ||
template.EXPECT(). | ||
Execute(w, mock.Anything). | ||
Return(expectedError) | ||
|
||
err := ChooseAttorneysGuidance(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) | ||
resp := w.Result() | ||
|
||
assert.Equal(t, expectedError, err) | ||
assert.Equal(t, http.StatusOK, resp.StatusCode) | ||
} | ||
|
||
func TestPostChooseAttorneysGuidance(t *testing.T) { | ||
w := httptest.NewRecorder() | ||
r, _ := http.NewRequest(http.MethodPost, "/", nil) | ||
r.Header.Add("Content-Type", page.FormUrlEncoded) | ||
|
||
err := ChooseAttorneysGuidance(nil, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) | ||
resp := w.Result() | ||
|
||
assert.Nil(t, err) | ||
assert.Equal(t, http.StatusFound, resp.StatusCode) | ||
assert.Equal(t, page.Paths.ChooseAttorneys.Format("lpa-id")+"?id="+testUID.String(), resp.Header.Get("Location")) | ||
} |
Oops, something went wrong.