@@ -25,6 +25,7 @@ import type {
2525 InferActionCollectorType ,
2626 InferNoValueCollectorType ,
2727 ReadOnlyCollector ,
28+ RichTextCollector ,
2829 QrCodeCollector ,
2930 AgreementCollector ,
3031 PhoneNumberCollector ,
@@ -35,6 +36,9 @@ import type {
3536 PhoneNumberOutputValue ,
3637 PhoneNumberExtensionInputValue ,
3738 PhoneNumberExtensionOutputValue ,
39+ RichContentLink ,
40+ CollectorRichContent ,
41+ NoValueCollector ,
3842} from './collector.types.js' ;
3943
4044describe ( 'Collector Types' , ( ) => {
@@ -486,12 +490,32 @@ describe('Collector Types', () => {
486490 key : 'read-only' ,
487491 label : 'Read Only Field' ,
488492 type : 'READ_ONLY' ,
493+ content : '' ,
489494 } ,
490495 } ;
491496
492497 expectTypeOf ( tCollector ) . toEqualTypeOf < ReadOnlyCollector > ( ) ;
493498 } ) ;
494499
500+ it ( 'should correctly infer RichTextCollector Type' , ( ) => {
501+ const tCollector : InferNoValueCollectorType < 'RichTextCollector' > = {
502+ category : 'NoValueCollector' ,
503+ error : null ,
504+ type : 'RichTextCollector' ,
505+ id : 'rich-text-0' ,
506+ name : 'rich-text-0' ,
507+ output : {
508+ key : 'rich-text-0' ,
509+ label : 'Rich Text Field' ,
510+ type : 'LABEL' ,
511+ content : '' ,
512+ richContent : { content : '' , replacements : [ ] } ,
513+ } ,
514+ } ;
515+
516+ expectTypeOf ( tCollector ) . toEqualTypeOf < RichTextCollector > ( ) ;
517+ } ) ;
518+
495519 it ( 'should correctly infer QrCodeCollector Type' , ( ) => {
496520 const tCollector : InferNoValueCollectorType < 'QrCodeCollector' > = {
497521 category : 'NoValueCollector' ,
@@ -534,4 +558,96 @@ describe('Collector Types', () => {
534558 expectTypeOf ( tCollector ) . toEqualTypeOf < AgreementCollector > ( ) ;
535559 } ) ;
536560 } ) ;
561+
562+ describe ( 'Rich Content Types' , ( ) => {
563+ describe ( 'RichContentLink' , ( ) => {
564+ it ( 'should require key, type, value, and href' , ( ) => {
565+ expectTypeOf < RichContentLink > ( ) . toHaveProperty ( 'key' ) . toBeString ( ) ;
566+ expectTypeOf < RichContentLink > ( ) . toHaveProperty ( 'type' ) . toEqualTypeOf < 'link' > ( ) ;
567+ expectTypeOf < RichContentLink > ( ) . toHaveProperty ( 'value' ) . toBeString ( ) ;
568+ expectTypeOf < RichContentLink > ( ) . toHaveProperty ( 'href' ) . toBeString ( ) ;
569+ } ) ;
570+
571+ it ( 'should have optional target constrained to _self or _blank' , ( ) => {
572+ expectTypeOf < RichContentLink > ( )
573+ . toHaveProperty ( 'target' )
574+ . toEqualTypeOf < '_self' | '_blank' | undefined > ( ) ;
575+ } ) ;
576+ } ) ;
577+
578+ describe ( 'CollectorRichContent' , ( ) => {
579+ it ( 'should have required content string and replacements array' , ( ) => {
580+ expectTypeOf < CollectorRichContent > ( ) . toHaveProperty ( 'content' ) . toBeString ( ) ;
581+ expectTypeOf < CollectorRichContent > ( )
582+ . toHaveProperty ( 'replacements' )
583+ . toEqualTypeOf < RichContentLink [ ] > ( ) ;
584+ } ) ;
585+ } ) ;
586+
587+ describe ( 'ReadOnlyCollector' , ( ) => {
588+ it ( 'should have content as string' , ( ) => {
589+ expectTypeOf < ReadOnlyCollector [ 'output' ] [ 'content' ] > ( ) . toBeString ( ) ;
590+ } ) ;
591+
592+ it ( 'should not have richContent' , ( ) => {
593+ expectTypeOf < ReadOnlyCollector [ 'output' ] > ( ) . not . toHaveProperty ( 'richContent' ) ;
594+ } ) ;
595+
596+ it ( 'should have standard collector fields' , ( ) => {
597+ expectTypeOf < ReadOnlyCollector > ( )
598+ . toHaveProperty ( 'category' )
599+ . toEqualTypeOf < 'NoValueCollector' > ( ) ;
600+ expectTypeOf < ReadOnlyCollector > ( )
601+ . toHaveProperty ( 'type' )
602+ . toEqualTypeOf < 'ReadOnlyCollector' > ( ) ;
603+ expectTypeOf < ReadOnlyCollector > ( ) . toHaveProperty ( 'error' ) . toEqualTypeOf < string | null > ( ) ;
604+ } ) ;
605+ } ) ;
606+
607+ describe ( 'RichTextCollector' , ( ) => {
608+ it ( 'should have content as string' , ( ) => {
609+ expectTypeOf < RichTextCollector [ 'output' ] [ 'content' ] > ( ) . toBeString ( ) ;
610+ } ) ;
611+
612+ it ( 'should have required richContent with CollectorRichContent shape' , ( ) => {
613+ expectTypeOf <
614+ RichTextCollector [ 'output' ] [ 'richContent' ]
615+ > ( ) . toEqualTypeOf < CollectorRichContent > ( ) ;
616+ } ) ;
617+
618+ it ( 'should have standard collector fields' , ( ) => {
619+ expectTypeOf < RichTextCollector > ( )
620+ . toHaveProperty ( 'category' )
621+ . toEqualTypeOf < 'NoValueCollector' > ( ) ;
622+ expectTypeOf < RichTextCollector > ( )
623+ . toHaveProperty ( 'type' )
624+ . toEqualTypeOf < 'RichTextCollector' > ( ) ;
625+ expectTypeOf < RichTextCollector > ( ) . toHaveProperty ( 'error' ) . toEqualTypeOf < string | null > ( ) ;
626+ } ) ;
627+ } ) ;
628+
629+ describe ( "NoValueCollector<'ReadOnlyCollector'>" , ( ) => {
630+ it ( 'should resolve to ReadOnlyCollector' , ( ) => {
631+ expectTypeOf < NoValueCollector < 'ReadOnlyCollector' > > ( ) . toEqualTypeOf < ReadOnlyCollector > ( ) ;
632+ } ) ;
633+
634+ it ( 'should have content on output but no richContent' , ( ) => {
635+ type Resolved = NoValueCollector < 'ReadOnlyCollector' > ;
636+ expectTypeOf < Resolved [ 'output' ] [ 'content' ] > ( ) . toBeString ( ) ;
637+ expectTypeOf < Resolved [ 'output' ] > ( ) . not . toHaveProperty ( 'richContent' ) ;
638+ } ) ;
639+ } ) ;
640+
641+ describe ( "NoValueCollector<'RichTextCollector'>" , ( ) => {
642+ it ( 'should resolve to RichTextCollector' , ( ) => {
643+ expectTypeOf < NoValueCollector < 'RichTextCollector' > > ( ) . toEqualTypeOf < RichTextCollector > ( ) ;
644+ } ) ;
645+
646+ it ( 'should have content and richContent on output' , ( ) => {
647+ type Resolved = NoValueCollector < 'RichTextCollector' > ;
648+ expectTypeOf < Resolved [ 'output' ] [ 'content' ] > ( ) . toBeString ( ) ;
649+ expectTypeOf < Resolved [ 'output' ] [ 'richContent' ] > ( ) . toEqualTypeOf < CollectorRichContent > ( ) ;
650+ } ) ;
651+ } ) ;
652+ } ) ;
537653} ) ;
0 commit comments