@@ -373,8 +373,9 @@ describe('Mellomlagring', () => {
373
373
cy . findByRole ( 'heading' , { name : TEXTS . statiske . summaryPage . title } ) . should ( 'exist' ) ;
374
374
} ) ;
375
375
376
- it ( 'when submission data contains invalid country' , ( ) => {
377
- cy . mocksUseRouteVariant ( 'get-soknad:form-select-invalid-country-v1' ) ;
376
+ it ( 'when form-v2 does not allow value anymore' , ( ) => {
377
+ cy . mocksUseRouteVariant ( 'get-form:success-v2' ) ;
378
+ cy . mocksUseRouteVariant ( 'get-soknad:form-select-invalid-instrument-v1' ) ;
378
379
379
380
cy . visit (
380
381
'/fyllut/testselect/oppsummering?sub=digital&innsendingsId=df6c8a69-9eb0-4878-b51f-38b3849ef9b6&lang=nb-NO' ,
@@ -385,50 +386,62 @@ describe('Mellomlagring', () => {
385
386
. within ( ( ) => {
386
387
cy . get ( 'dt' ) . should ( 'have.length' , 3 ) ;
387
388
cy . get ( 'dt' ) . eq ( 0 ) . should ( 'contain.text' , 'Velg instrument' ) ;
388
- cy . get ( 'dd' ) . eq ( 0 ) . should ( 'contain.text' , 'Piano' ) ;
389
+ cy . get ( 'dd' ) . eq ( 0 ) . should ( 'contain.text' , 'Piano' ) ; // <- invalid in form v2
389
390
cy . get ( 'dt' ) . eq ( 1 ) . should ( 'contain.text' , 'Velg land du vil reise til' ) ;
390
- cy . get ( 'dd' ) . eq ( 1 ) . should ( 'contain.text' , 'Invalid country ' ) ; // <- invalid (dataSrc=url)
391
+ cy . get ( 'dd' ) . eq ( 1 ) . should ( 'contain.text' , 'Italia ' ) ;
391
392
cy . get ( 'dt' ) . eq ( 2 ) . should ( 'contain.text' , 'Velg valuta du vil betale med' ) ;
392
393
cy . get ( 'dd' ) . eq ( 2 ) . should ( 'contain.text' , 'Euro (EUR)' ) ;
393
394
} ) ;
394
395
cy . findByText ( / A l l e s t e g s o m m a n g l e r i n f o r m a s j o n e r m a r k e r t m e d / ) . should ( 'exist' ) ;
395
396
cy . findByRole ( 'button' , { name : TEXTS . grensesnitt . navigation . saveAndContinue } ) . should ( 'not.exist' ) ;
396
397
cy . findByRole ( 'heading' , { name : TEXTS . statiske . summaryPage . title } ) . should ( 'exist' ) ;
397
398
} ) ;
399
+ } ) ;
398
400
399
- it ( 'when form-v2 does not allow value anymore' , ( ) => {
400
- cy . mocksUseRouteVariant ( 'get-form:success-v2' ) ;
401
- cy . mocksUseRouteVariant ( 'get-soknad:form-select-invalid-instrument-v1' ) ;
401
+ describe ( 'allows user to continue to sendinn application' , ( ) => {
402
+ it ( 'when submission data is complete and valid' , ( ) => {
403
+ cy . mocksUseRouteVariant ( 'get-soknad:form-select-complete-v1' ) ;
404
+
405
+ cy . intercept ( 'PUT' , '/fyllut/api/send-inn/utfyltsoknad' , ( req ) => {
406
+ const { submission, attachments, ...rest } = req . body ;
407
+ expect ( submission . data . velgInstrument ) . to . deep . eq ( { label : 'Piano' , value : 'piano' } ) ;
408
+ expect ( submission . data . velgLand ) . to . deep . eq ( { label : 'Italia' , value : 'IT' } ) ;
409
+ expect ( submission . data . velgValutaDuVilBetaleMed ) . to . deep . eq ( { label : 'Euro (EUR)' , value : 'EUR' } ) ;
410
+ expect ( attachments ) . to . have . length ( 1 ) ;
411
+ expect ( attachments [ 0 ] . vedleggsnr ) . to . eq ( 'P2' ) ;
412
+ } ) . as ( 'submitMellomlagring' ) ;
402
413
403
414
cy . visit (
404
415
'/fyllut/testselect/oppsummering?sub=digital&innsendingsId=df6c8a69-9eb0-4878-b51f-38b3849ef9b6&lang=nb-NO' ,
405
416
) ;
406
417
cy . wait ( '@getMellomlagring' ) ;
418
+ cy . findByRole ( 'button' , { name : / V e i l e d n i n g / } ) . should ( 'exist' ) ;
407
419
cy . get ( 'dl' )
408
420
. eq ( 0 )
409
421
. within ( ( ) => {
410
422
cy . get ( 'dt' ) . should ( 'have.length' , 3 ) ;
411
423
cy . get ( 'dt' ) . eq ( 0 ) . should ( 'contain.text' , 'Velg instrument' ) ;
412
- cy . get ( 'dd' ) . eq ( 0 ) . should ( 'contain.text' , 'Piano' ) ; // <- invalid in form v2
424
+ cy . get ( 'dd' ) . eq ( 0 ) . should ( 'contain.text' , 'Piano' ) ;
413
425
cy . get ( 'dt' ) . eq ( 1 ) . should ( 'contain.text' , 'Velg land du vil reise til' ) ;
414
426
cy . get ( 'dd' ) . eq ( 1 ) . should ( 'contain.text' , 'Italia' ) ;
415
427
cy . get ( 'dt' ) . eq ( 2 ) . should ( 'contain.text' , 'Velg valuta du vil betale med' ) ;
416
428
cy . get ( 'dd' ) . eq ( 2 ) . should ( 'contain.text' , 'Euro (EUR)' ) ;
417
429
} ) ;
418
- cy . findByText ( / A l l e s t e g s o m m a n g l e r i n f o r m a s j o n e r m a r k e r t m e d / ) . should ( 'exist' ) ;
419
- cy . findByRole ( 'button' , { name : TEXTS . grensesnitt . navigation . saveAndContinue } ) . should ( 'not.exist' ) ;
430
+ cy . findByRole ( 'button' , { name : TEXTS . grensesnitt . navigation . saveAndContinue } ) . should ( 'exist' ) ;
431
+ cy . findByText ( / A l l e s t e g s o m m a n g l e r i n f o r m a s j o n e r m a r k e r t m e d / ) . should ( 'not.exist' ) ;
420
432
cy . findByRole ( 'heading' , { name : TEXTS . statiske . summaryPage . title } ) . should ( 'exist' ) ;
433
+
434
+ cy . clickSaveAndContinue ( ) ;
435
+ cy . wait ( '@submitMellomlagring' ) ;
421
436
} ) ;
422
- } ) ;
423
437
424
- describe ( 'allows user to continue to sendinn application' , ( ) => {
425
- it ( 'when submission data is complete and valid' , ( ) => {
426
- cy . mocksUseRouteVariant ( 'get-soknad:form-select-complete-v1' ) ;
438
+ it ( 'even if submission data contains an invalid country' , ( ) => {
439
+ cy . mocksUseRouteVariant ( 'get-soknad:form-select-invalid-country-v1' ) ;
427
440
428
441
cy . intercept ( 'PUT' , '/fyllut/api/send-inn/utfyltsoknad' , ( req ) => {
429
- const { submission, attachments, ... rest } = req . body ;
442
+ const { submission, attachments } = req . body ;
430
443
expect ( submission . data . velgInstrument ) . to . deep . eq ( { label : 'Piano' , value : 'piano' } ) ;
431
- expect ( submission . data . velgLand ) . to . deep . eq ( { label : 'Italia ' , value : 'IT ' } ) ;
444
+ expect ( submission . data . velgLand ) . to . deep . eq ( { label : 'Invalid country ' , value : 'INVALID ' } ) ;
432
445
expect ( submission . data . velgValutaDuVilBetaleMed ) . to . deep . eq ( { label : 'Euro (EUR)' , value : 'EUR' } ) ;
433
446
expect ( attachments ) . to . have . length ( 1 ) ;
434
447
expect ( attachments [ 0 ] . vedleggsnr ) . to . eq ( 'P2' ) ;
@@ -438,15 +451,14 @@ describe('Mellomlagring', () => {
438
451
'/fyllut/testselect/oppsummering?sub=digital&innsendingsId=df6c8a69-9eb0-4878-b51f-38b3849ef9b6&lang=nb-NO' ,
439
452
) ;
440
453
cy . wait ( '@getMellomlagring' ) ;
441
- cy . findByRole ( 'button' , { name : / V e i l e d n i n g / } ) . should ( 'exist' ) ;
442
454
cy . get ( 'dl' )
443
455
. eq ( 0 )
444
456
. within ( ( ) => {
445
457
cy . get ( 'dt' ) . should ( 'have.length' , 3 ) ;
446
458
cy . get ( 'dt' ) . eq ( 0 ) . should ( 'contain.text' , 'Velg instrument' ) ;
447
459
cy . get ( 'dd' ) . eq ( 0 ) . should ( 'contain.text' , 'Piano' ) ;
448
460
cy . get ( 'dt' ) . eq ( 1 ) . should ( 'contain.text' , 'Velg land du vil reise til' ) ;
449
- cy . get ( 'dd' ) . eq ( 1 ) . should ( 'contain.text' , 'Italia ' ) ;
461
+ cy . get ( 'dd' ) . eq ( 1 ) . should ( 'contain.text' , 'Invalid country ' ) ; // <- invalid (dataSrc=url)
450
462
cy . get ( 'dt' ) . eq ( 2 ) . should ( 'contain.text' , 'Velg valuta du vil betale med' ) ;
451
463
cy . get ( 'dd' ) . eq ( 2 ) . should ( 'contain.text' , 'Euro (EUR)' ) ;
452
464
} ) ;
@@ -459,6 +471,28 @@ describe('Mellomlagring', () => {
459
471
} ) ;
460
472
} ) ;
461
473
} ) ;
474
+
475
+ it ( 'Allows user to submit complete submission' , ( ) => {
476
+ cy . mocksUseRouteVariant ( 'get-soknad:nav083501-complete-v1' ) ;
477
+ cy . intercept ( 'PUT' , '/fyllut/api/send-inn/utfyltsoknad' , ( req ) => {
478
+ const { submission, attachments } = req . body ;
479
+ expect ( submission . data . landvelger ) . to . deep . eq ( { label : 'Frankrike' , value : 'FR' } ) ;
480
+ expect ( attachments ) . to . have . length ( 2 ) ;
481
+ expect ( attachments [ 0 ] . label ) . to . eq ( 'Personinntektsskjema' ) ;
482
+ expect ( attachments [ 1 ] . label ) . to . eq ( 'Resultatregnskap' ) ;
483
+ } ) . as ( 'submitMellomlagring' ) ;
484
+ cy . intercept ( 'GET' , '/fyllut/api/send-inn/soknad/2db25aab-3524-4426-a333-489542bf16bf' ) . as ( 'getMellomlagring' ) ;
485
+
486
+ cy . visit (
487
+ '/fyllut/nav083501/oppsummering?sub=digital&innsendingsId=2db25aab-3524-4426-a333-489542bf16bf&lang=nb-NO' ,
488
+ ) ;
489
+ cy . wait ( '@getMellomlagring' ) ;
490
+ cy . findByRole ( 'button' , { name : TEXTS . grensesnitt . navigation . saveAndContinue } ) . should ( 'exist' ) ;
491
+ cy . findByText ( / A l l e s t e g s o m m a n g l e r i n f o r m a s j o n e r m a r k e r t m e d / ) . should ( 'not.exist' ) ;
492
+ cy . findByRole ( 'heading' , { name : TEXTS . statiske . summaryPage . title } ) . should ( 'exist' ) ;
493
+ cy . clickSaveAndContinue ( ) ;
494
+ cy . wait ( '@submitMellomlagring' ) ;
495
+ } ) ;
462
496
} ) ;
463
497
} ) ;
464
498
} ) ;
0 commit comments