@@ -15,6 +15,7 @@ import {
1515 type ElementDataSource ,
1616 type InterfacePageConfig ,
1717} from './page.zod' ;
18+ import { ComponentPropsMap } from './component.zod' ;
1819
1920describe ( 'PageComponentSchema' , ( ) => {
2021 it ( 'should accept valid minimal component' , ( ) => {
@@ -666,6 +667,9 @@ describe('ElementDataSourceSchema `filter` — one filter orthography platform-w
666667 /** The issues a parse raised under `key` (top-level), whatever else it raised. */
667668 const issuesUnder = ( r : ParseResult , key : string ) =>
668669 r . success ? [ ] : r . error ! . issues . filter ( ( i ) => i . path [ 0 ] === key ) ;
670+ /** The issues located EXACTLY at `path` (dotted) — `filter` is not `filter.0`. */
671+ const issuesAt = ( r : ParseResult , path : string ) =>
672+ r . success ? [ ] : r . error ! . issues . filter ( ( i ) => i . path . join ( '.' ) === path ) ;
669673
670674 it ( 'accepts a ViewFilterRule[] filter — the acceptance criterion' , ( ) => {
671675 // Before #15442 this exact value was REFUSED here (`invalid_type`, expected
@@ -727,34 +731,36 @@ describe('ElementDataSourceSchema `filter` — one filter orthography platform-w
727731 // seventeen off-spec authors at the pin are the seat's objectui follow-up.
728732 const r = ElementDataSourceSchema . safeParse ( { object : 'account' , filter : TUPLE_ARRAY } ) ;
729733 expect ( r . success ) . toBe ( false ) ;
730- expect ( issuesUnder ( r , 'filter' ) ) . toEqual ( [ ] ) ;
731- const atElement = r . error ! . issues . filter ( ( i ) => i . path . join ( '.' ) === 'filter.0' ) ;
732- expect ( atElement . map ( ( i ) => i . code ) ) . toEqual ( [ 'invalid_type' ] ) ;
734+ expect ( issuesAt ( r , 'filter' ) ) . toEqual ( [ ] ) ;
735+ expect ( issuesAt ( r , 'filter.0' ) . map ( ( i ) => i . code ) ) . toEqual ( [ 'invalid_type' ] ) ;
736+ expect ( issuesAt ( r , 'filter.0' ) [ 0 ] ) . toMatchObject ( { expected : 'object' } ) ;
733737 } ) ;
734738
735739 it ( 'shares the array orthography with the props-map `filter` doors — one value, two keys, the same verdicts' , ( ) => {
736740 // `element:record_picker` was the node that carried two orthographies at
737741 // two keys (`properties.filter` the array, `dataSource.filter` the record)
738- // resolved through one `??` in the renderer. The same rule array now raises
739- // no issue at either key, and the same record is refused at both with the
740- // same code — measured through the real `PageComponentSchema`, the door an
741- // authored page actually passes.
742- const both = PageComponentSchema . safeParse ( {
742+ // resolved through one `??` in the renderer. Each key is asked at ITS
743+ // door: the binding through the real `PageComponentSchema` (which parses
744+ // `dataSource` and leaves `properties` a bag — the props-map dispatch is
745+ // the lint's, warning tier), and the props key through the picker's own
746+ // `ComponentPropsMap` entry. The same rule array raises no issue at either;
747+ // the same record is refused at both with the same code.
748+ const binding = PageComponentSchema . safeParse ( {
743749 type : 'element:record_picker' ,
744750 properties : { object : 'account' , filter : RULES } ,
745751 dataSource : { object : 'account' , filter : RULES } ,
746752 } ) ;
747- expect ( both . success ) . toBe ( true ) ;
748- const bothRecords = PageComponentSchema . safeParse ( {
753+ expect ( binding . success ) . toBe ( true ) ;
754+ const bindingRecord = PageComponentSchema . safeParse ( {
749755 type : 'element:record_picker' ,
750- properties : { object : 'account' , filter : RECORD_FORM } ,
756+ properties : { object : 'account' , filter : RULES } ,
751757 dataSource : { object : 'account' , filter : RECORD_FORM } ,
752758 } ) ;
753- expect ( bothRecords . success ) . toBe ( false ) ;
754- const codesAt = ( path : string ) =>
755- bothRecords . error ! . issues . filter ( ( i ) => i . path . join ( '.' ) === path ) . map ( ( i ) => i . code ) ;
756- expect ( codesAt ( 'dataSource. filter' ) ) . toEqual ( [ 'invalid_type' ] ) ;
757- expect ( codesAt ( 'properties .filter') ) . toEqual ( codesAt ( 'dataSource.filter' ) ) ;
759+ expect ( issuesAt ( bindingRecord , 'dataSource.filter' ) . map ( ( i ) => i . code ) ) . toEqual ( [ 'invalid_type' ] ) ;
760+ const picker = ComponentPropsMap [ 'element:record_picker' ] ;
761+ expect ( issuesAt ( picker . safeParse ( { object : 'account' , filter : RULES } ) , 'filter' ) ) . toEqual ( [ ] ) ;
762+ expect ( issuesAt ( picker . safeParse ( { object : 'account' , filter : RECORD_FORM } ) , 'filter' ) . map ( ( i ) => i . code ) )
763+ . toEqual ( issuesAt ( bindingRecord , 'dataSource .filter') . map ( ( i ) => i . code ) ) ;
758764 } ) ;
759765} ) ;
760766
0 commit comments