@@ -14,6 +14,7 @@ import { appDevDependencies } from "../../../../../config/dev-dependencies";
1414import GeneralPartnerBuilder from "../../../../../presentation/test/builder/GeneralPartnerBuilder" ;
1515import PostTransitionPageType from "../../../../../presentation/controller/postTransition/pageType" ;
1616import { PartnerKind } from "@companieshouse/api-sdk-node/dist/services/limited-partnerships" ;
17+ import { ApiErrors } from "domain/entities/UIErrors" ;
1718
1819describe ( "Update General Partner Legal Entity Page" , ( ) => {
1920 const URL = getUrl ( UPDATE_GENERAL_PARTNER_PERSON_URL ) ;
@@ -138,6 +139,28 @@ describe("Update General Partner Legal Entity Page", () => {
138139 expect ( appDevDependencies . generalPartnerGateway . generalPartners [ 0 ] . data ?. nationality1 ) . toEqual ( "British" ) ;
139140 expect ( appDevDependencies . generalPartnerGateway . generalPartners [ 0 ] . data ?. nationality2 ) . toEqual ( "Irish" ) ;
140141 } ) ;
142+
143+ it ( "should replay entered data when a validation error occurs" , async ( ) => {
144+ const apiErrors : ApiErrors = {
145+ errors : { forename : "forename is invalid" }
146+ } ;
147+ appDevDependencies . generalPartnerGateway . feedErrors ( apiErrors ) ;
148+
149+ const res = await request ( app ) . post ( URL ) . send ( {
150+ pageType : PostTransitionPageType . updateGeneralPartnerPerson ,
151+ "forename" : "INVALID-FORENAME" ,
152+ "surname" : "Doe" ,
153+ "nationality1" : "British" ,
154+ "nationality2" : "Irish"
155+ } ) ;
156+
157+ expect ( res . status ) . toBe ( 200 ) ;
158+ expect ( res . text ) . toContain ( "forename is invalid" ) ;
159+ expect ( res . text ) . toContain ( "INVALID-FORENAME" ) ;
160+ expect ( res . text ) . toContain ( "Doe" ) ;
161+ expect ( res . text ) . toContain ( '<option value="British" selected>British</option>' ) ;
162+ expect ( res . text ) . toContain ( '<option value="Irish" selected>Irish</option>' ) ;
163+ } ) ;
141164 } ) ;
142165
143166 } ) ;
0 commit comments