@@ -351,3 +351,50 @@ describe('MasterDetailForm — showSubmit gate (Studio screen preview)', () => {
351351 expect ( cancelBtn ) . toHaveTextContent ( '取消' ) ;
352352 } ) ;
353353} ) ;
354+
355+ /**
356+ * objectstack#35804 — the line grid's column headers show each child field's
357+ * help, read from the child object's definition as `getObjectSchema` serves
358+ * it: the definition the record form reads too, so a help another package
359+ * wrote through `objectExtensions.fieldPatches` (applied by the server before
360+ * it serves the object) and the reader's language both arrive here.
361+ */
362+ describe ( 'MasterDetailForm — line column headers show the child fields\' help (objectstack#35804)' , ( ) => {
363+ const lineSchema = {
364+ name : 'po_line' ,
365+ fields : {
366+ po : { type : 'lookup' , label : 'PO' , reference : 'po' } ,
367+ // The served definition: `description` carries what a patch or a
368+ // translation put there, and `inlineHelpText` wins over it.
369+ qty : { type : 'number' , label : 'Qty' , description : 'Whole units only.' } ,
370+ price : { type : 'number' , label : 'Price' , inlineHelpText : 'Tax-inclusive.' , description : 'Not this.' } ,
371+ note : { type : 'text' , label : 'Note' } ,
372+ } ,
373+ } ;
374+ const ds = ( ) =>
375+ makeDataSource ( {
376+ getObjectSchema : vi . fn ( async ( name : string ) => ( name === 'po_line' ? lineSchema : parentSchema ) ) ,
377+ } ) ;
378+ const schema = ( detail : Record < string , unknown > ) =>
379+ ( { objectName : 'po' , mode : 'create' , fields : [ 'ref' ] , details : [ detail ] } ) as any ;
380+
381+ it . each ( [
382+ [ 'derived columns' , { childObject : 'po_line' } ] ,
383+ // The console's shape for a child field's `inlineColumns`: names the
384+ // form hydrates from the child schema (a column declaring its `type`
385+ // opts out of that hydration, and an entry whose every column does loads
386+ // no child schema, so it has no help to show, as it has no lookup
387+ // autofill pairs).
388+ [
389+ 'authored columns' ,
390+ { childObject : 'po_line' , relationshipField : 'po' , columns : [ { name : 'qty' } , { name : 'price' } , { name : 'note' } ] } ,
391+ ] ,
392+ ] ) ( '%s: each header carries its field\'s help, the form\'s own read of it' , async ( _label , detail ) => {
393+ render ( < MasterDetailForm schema = { schema ( detail ) } dataSource = { ds ( ) } /> ) ;
394+ const qtyHelp = await screen . findByRole ( 'button' , { name : 'Whole units only.' } ) ;
395+ expect ( qtyHelp . closest ( 'th' ) ! . textContent ) . toContain ( 'Qty' ) ;
396+ expect ( screen . getByRole ( 'button' , { name : 'Tax-inclusive.' } ) . closest ( 'th' ) ! . textContent ) . toContain ( 'Price' ) ;
397+ // CONTROL: a field with no help draws no info button on its header.
398+ expect ( screen . getByRole ( 'columnheader' , { name : 'Note' } ) . querySelector ( 'button' ) ) . toBeNull ( ) ;
399+ } ) ;
400+ } ) ;
0 commit comments