@@ -316,44 +316,34 @@ await Host.Scenario(_ =>
316316 [ Fact ]
317317 public async Task SubmitApplication_TwiceBySameUser_ReturnsBadRequest ( )
318318 {
319- // Create and submit the first application
320- var firstApplication = CreateDraftApplication ( ) ;
321- firstApplication . Id = Fixture . draftTestApplicationId2 ;
322-
323- // Save first draft
324- await Host . Scenario ( _ =>
325- {
326- _ . WithExistingUser ( Fixture . AuthenticatedBcscUserIdentity , Fixture . AuthenticatedBcscUser ) ;
327- _ . Put . Json ( new SaveDraftApplicationRequest ( firstApplication ) ) . ToUrl ( $ "/api/draftapplications/{ firstApplication . Id } ") ;
328- _ . StatusCodeShouldBeOk ( ) ;
329- } ) ;
330-
331- // Submit first application
332- await Host . Scenario ( _ =>
319+ // Assert user already has submitted application
320+ var applicationsResponse = await Host . Scenario ( _ =>
333321 {
334- _ . WithExistingUser ( Fixture . AuthenticatedBcscUserIdentity , Fixture . AuthenticatedBcscUser ) ;
335- _ . Post . Json ( new ApplicationSubmissionRequest ( firstApplication . Id ! ) ) . ToUrl ( "/api/applications" ) ;
322+ _ . WithExistingUser ( this . Fixture . AuthenticatedBcscUserIdentity , this . Fixture . AuthenticatedBcscUser ) ;
323+ _ . Get . Url ( "/api/applications" ) ;
336324 _ . StatusCodeShouldBeOk ( ) ;
337325 } ) ;
326+ var applications = await applicationsResponse . ReadAsJsonAsync < Application [ ] > ( ) ;
327+ applications . Where ( application => application . Status == ApplicationStatus . Submitted ) . ShouldNotBeEmpty ( ) ;
328+
329+ // Create and submit application
330+ var firstApplication = CreateDraftApplication ( ) ;
331+ firstApplication . Id = Fixture . draftTestApplicationId4 ;
332+ firstApplication . CertificationTypes = new [ ] { CertificationType . EceAssistant } ;
338333
339- // Create and attempt to submit a second application for the same user
340- var secondApplication = CreateDraftApplication ( ) ;
341- secondApplication . Id = Fixture . draftTestApplicationId3 ;
342-
343-
344- // Save second draft
334+ // Save draft
345335 await Host . Scenario ( _ =>
346336 {
347337 _ . WithExistingUser ( Fixture . AuthenticatedBcscUserIdentity , Fixture . AuthenticatedBcscUser ) ;
348- _ . Put . Json ( new SaveDraftApplicationRequest ( secondApplication ) ) . ToUrl ( $ "/api/draftapplications/{ secondApplication . Id } ") ;
338+ _ . Put . Json ( new SaveDraftApplicationRequest ( firstApplication ) ) . ToUrl ( $ "/api/draftapplications/{ firstApplication . Id } ") ;
349339 _ . StatusCodeShouldBeOk ( ) ;
350340 } ) ;
351341
352- // Attempt to submit second application — should fail
342+ // Submit application
353343 await Host . Scenario ( _ =>
354344 {
355345 _ . WithExistingUser ( Fixture . AuthenticatedBcscUserIdentity , Fixture . AuthenticatedBcscUser ) ;
356- _ . Post . Json ( new ApplicationSubmissionRequest ( secondApplication . Id ! ) ) . ToUrl ( "/api/applications" ) ;
346+ _ . Post . Json ( new ApplicationSubmissionRequest ( firstApplication . Id ! ) ) . ToUrl ( "/api/applications" ) ;
357347 _ . StatusCodeShouldBe ( HttpStatusCode . BadRequest ) ;
358348 } ) ;
359349 }
0 commit comments