@@ -526,4 +526,62 @@ suite('capture-eye-modal', () => {
526526 buttonCr = el . shadowRoot ! . querySelector ( '.button-content-credentials' ) ;
527527 assert . notExists ( buttonCr ) ;
528528 } ) ;
529+
530+ suite ( 'updateModalColor color validation' , ( ) => {
531+ test ( 'sets --primary-color for valid hex color' , async ( ) => {
532+ const el = await fixture < CaptureEyeModal > ( html `
533+ < capture-eye-modal > </ capture-eye-modal >
534+ ` ) ;
535+ el . updateModalOptions ( { nid : '1' , color : '#027fe5' } ) ;
536+ await el . updateComplete ;
537+ assert . equal ( el . style . getPropertyValue ( '--primary-color' ) , '#027fe5' ) ;
538+ } ) ;
539+
540+ test ( 'sets --primary-color for valid short hex color' , async ( ) => {
541+ const el = await fixture < CaptureEyeModal > ( html `
542+ < capture-eye-modal > </ capture-eye-modal >
543+ ` ) ;
544+ el . updateModalOptions ( { nid : '1' , color : '#fff' } ) ;
545+ await el . updateComplete ;
546+ assert . equal ( el . style . getPropertyValue ( '--primary-color' ) , '#fff' ) ;
547+ } ) ;
548+
549+ test ( 'sets --primary-color for valid named color' , async ( ) => {
550+ const el = await fixture < CaptureEyeModal > ( html `
551+ < capture-eye-modal > </ capture-eye-modal >
552+ ` ) ;
553+ el . updateModalOptions ( { nid : '1' , color : 'red' } ) ;
554+ await el . updateComplete ;
555+ assert . equal ( el . style . getPropertyValue ( '--primary-color' ) , 'red' ) ;
556+ } ) ;
557+
558+ test ( 'does not set --primary-color for invalid color with semicolon injection' , async ( ) => {
559+ const el = await fixture < CaptureEyeModal > ( html `
560+ < capture-eye-modal > </ capture-eye-modal >
561+ ` ) ;
562+ el . updateModalOptions ( { nid : '1' , color : 'red; --injected: value' } ) ;
563+ await el . updateComplete ;
564+ assert . equal ( el . style . getPropertyValue ( '--primary-color' ) , '' ) ;
565+ } ) ;
566+
567+ test ( 'does not set --primary-color for arbitrary string' , async ( ) => {
568+ const el = await fixture < CaptureEyeModal > ( html `
569+ < capture-eye-modal > </ capture-eye-modal >
570+ ` ) ;
571+ el . updateModalOptions ( { nid : '1' , color : 'not-a-color' } ) ;
572+ await el . updateComplete ;
573+ assert . equal ( el . style . getPropertyValue ( '--primary-color' ) , '' ) ;
574+ } ) ;
575+
576+ test ( 'clears --primary-color when color is empty' , async ( ) => {
577+ const el = await fixture < CaptureEyeModal > ( html `
578+ < capture-eye-modal > </ capture-eye-modal >
579+ ` ) ;
580+ el . updateModalOptions ( { nid : '1' , color : '#027fe5' } ) ;
581+ await el . updateComplete ;
582+ el . updateModalOptions ( { nid : '1' , color : '' } ) ;
583+ await el . updateComplete ;
584+ assert . equal ( el . style . getPropertyValue ( '--primary-color' ) , '' ) ;
585+ } ) ;
586+ } ) ;
529587} ) ;
0 commit comments