@@ -333,6 +333,51 @@ describe('Checkboxes component', () => {
333
333
. find ( 'span.fds-paragraph' ) // Targets the span with the summary text
334
334
. should ( 'have.text' , expectedText ) ;
335
335
} ) ;
336
+ it ( 'Renders the summary2 component with correct text for Checkboxes with group, hard deletion and Number' , ( ) => {
337
+ cy . interceptLayout ( 'ComponentLayouts' , ( component ) => {
338
+ if ( component . type === 'Checkboxes' && component . id === 'CheckboxesPage-Checkboxes2' ) {
339
+ component . deletionStrategy = 'hard' ;
340
+ component . dataModelBindings . checked = undefined ;
341
+ component . optionsId = 'personsNumber' ;
342
+ }
343
+ } ) ;
344
+ cy . startAppInstance ( appFrontend . apps . componentLibrary , { authenticationLevel : '2' } ) ;
345
+ cy . gotoNavPage ( 'Avkryssningsbokser' ) ;
346
+
347
+ const checkboxes = '[data-componentid=CheckboxesPage-Checkboxes2]' ;
348
+ const summary2 = '[data-componentid=CheckboxesPage-Header-Summary2-Component2]' ;
349
+
350
+ const checkboxText1 = 'Karoline' ;
351
+ const checkboxText2 = 'Kåre' ;
352
+ const checkboxText3 = 'Johanne' ;
353
+ const checkboxText4 = 'Kari' ;
354
+ const checkboxText5 = 'Petter' ;
355
+
356
+ //Check options in checkboxes component
357
+ cy . get ( checkboxes ) . contains ( 'label' , checkboxText1 ) . prev ( 'input[type="checkbox"]' ) . click ( ) ;
358
+ cy . get ( checkboxes ) . contains ( 'label' , checkboxText2 ) . prev ( 'input[type="checkbox"]' ) . click ( ) ;
359
+ cy . get ( checkboxes ) . contains ( 'label' , checkboxText3 ) . prev ( 'input[type="checkbox"]' ) . click ( ) ;
360
+ cy . get ( checkboxes ) . contains ( 'label' , checkboxText4 ) . prev ( 'input[type="checkbox"]' ) . click ( ) ;
361
+ cy . get ( checkboxes ) . contains ( 'label' , checkboxText5 ) . prev ( 'input[type="checkbox"]' ) . click ( ) ;
362
+
363
+ //Uncheck
364
+ cy . get ( checkboxes ) . contains ( 'label' , checkboxText4 ) . prev ( 'input[type="checkbox"]' ) . click ( ) ;
365
+ cy . get ( checkboxes ) . contains ( 'label' , checkboxText5 ) . prev ( 'input[type="checkbox"]' ) . click ( ) ;
366
+
367
+ //Check that checkboxes is correct
368
+ cy . get ( checkboxes ) . contains ( 'label' , checkboxText1 ) . prev ( 'input[type="checkbox"]' ) . should ( 'be.checked' ) ;
369
+ cy . get ( checkboxes ) . contains ( 'label' , checkboxText2 ) . prev ( 'input[type="checkbox"]' ) . should ( 'be.checked' ) ;
370
+ cy . get ( checkboxes ) . contains ( 'label' , checkboxText3 ) . prev ( 'input[type="checkbox"]' ) . should ( 'be.checked' ) ;
371
+ cy . get ( checkboxes ) . contains ( 'label' , checkboxText4 ) . prev ( 'input[type="checkbox"]' ) . should ( 'not.be.checked' ) ;
372
+ cy . get ( checkboxes ) . contains ( 'label' , checkboxText5 ) . prev ( 'input[type="checkbox"]' ) . should ( 'not.be.checked' ) ;
373
+
374
+ const expectedText = [ checkboxText1 , checkboxText2 , checkboxText3 ] . join ( ', ' ) ;
375
+
376
+ cy . get ( `div${ summary2 } ` )
377
+ . next ( )
378
+ . find ( 'span.fds-paragraph' ) // Targets the span with the summary text
379
+ . should ( 'have.text' , expectedText ) ;
380
+ } ) ;
336
381
337
382
//Required
338
383
it ( 'Required validation shows when chekcbox is selected with simpleBinding' , ( ) => {
@@ -395,6 +440,29 @@ describe('Checkboxes component', () => {
395
440
const checkboxText1 = 'Karoline' ;
396
441
cy . contains ( 'label' , checkboxText1 ) . prev ( 'input[type="checkbox"]' ) . check ( ) ;
397
442
443
+ cy . get ( checkboxes ) . contains ( 'span' , 'Du må fylle ut hva skal kjøretøyet brukes til?' ) . should ( 'not.exist' ) ;
444
+ } ) ;
445
+ it ( 'Required validation shows when chekcbox is selected with group, hard delete and Number' , ( ) => {
446
+ cy . interceptLayout ( 'ComponentLayouts' , ( component ) => {
447
+ if ( component . type === 'Checkboxes' && component . id === 'CheckboxesPage-Checkboxes2' ) {
448
+ component . required = true ;
449
+ component . deletionStrategy = 'hard' ;
450
+ component . dataModelBindings . checked = undefined ;
451
+ component . optionsId = 'personsNumber' ;
452
+ }
453
+ } ) ;
454
+ cy . startAppInstance ( appFrontend . apps . componentLibrary , { authenticationLevel : '2' } ) ;
455
+ cy . gotoNavPage ( 'Oppsummering 2.0' ) ;
456
+ cy . findByRole ( 'button' , { name : 'Send inn' } ) . click ( ) ;
457
+ cy . gotoNavPage ( 'Avkryssningsbokser' ) ;
458
+
459
+ const checkboxes = '[data-componentid=CheckboxesPage-Checkboxes2]' ;
460
+
461
+ cy . get ( checkboxes ) . contains ( 'span' , 'Du må fylle ut hva skal kjøretøyet brukes til?' ) . should ( 'exist' ) ;
462
+
463
+ const checkboxText1 = 'Karoline' ;
464
+ cy . contains ( 'label' , checkboxText1 ) . prev ( 'input[type="checkbox"]' ) . check ( ) ;
465
+
398
466
cy . get ( checkboxes ) . contains ( 'span' , 'Du må fylle ut hva skal kjøretøyet brukes til?' ) . should ( 'not.exist' ) ;
399
467
} ) ;
400
468
} ) ;
0 commit comments