@@ -133,8 +133,8 @@ function stateLockBadge(): HTMLElement | null {
133133}
134134
135135/** Mount the console record page and wait for the record read and the header. */
136- async function mountRecordPage ( record : Record < string , unknown > , fields : Record < string , unknown > ) {
137- const objects = [ objectDef ( fields ) ] ;
136+ async function mountRecordPage ( record : Record < string , unknown > , fields : Record < string , unknown > , served ?: any [ ] ) {
137+ const objects = served ?? [ objectDef ( fields ) ] ;
138138 const dataSource = makeDataSource ( record ) ;
139139 render (
140140 < MemoryRouter initialEntries = { [ `/apps/fin/${ OBJECT_NAME } /${ RECORD_ID } ` ] } >
@@ -245,3 +245,48 @@ describe('console record header — a record whose state locks every edit-form f
245245 expect ( stateLockBadge ( ) ) . toBeNull ( ) ;
246246 } ) ;
247247} ) ;
248+
249+ /**
250+ * objectstack#38249 — an object whose whole-record hand lock (`uiReadonlyWhen`)
251+ * holds locks its inline lines in the edit form too, so the record page greys
252+ * Edit even though its field groups place a child collection — unless a child
253+ * field owns a hand lock that could open a line cell.
254+ */
255+ describe ( 'console record header — a hand-locked document with inline lines (objectstack#38249)' , ( ) => {
256+ const LINE_OBJECT = 'ebqu_claim_line' ;
257+ const parent = {
258+ ...objectDef ( {
259+ id : { type : 'text' , label : 'Id' } ,
260+ name : { type : 'text' , label : 'Title' } ,
261+ status : { type : 'text' , label : 'Status' } ,
262+ } ) ,
263+ uiReadonlyWhen : "record.status == 'approved'" ,
264+ groupSubforms : [ { childObject : LINE_OBJECT , relationshipField : 'claim' } ] ,
265+ } ;
266+ const line = ( amount : Record < string , unknown > = { } ) => ( {
267+ name : LINE_OBJECT ,
268+ label : 'Claim line' ,
269+ fields : {
270+ claim : { type : 'master_detail' , label : 'Claim' , reference : OBJECT_NAME } ,
271+ amount : { type : 'currency' , label : 'Amount' , ...amount } ,
272+ } ,
273+ } ) ;
274+
275+ it ( 'draws Edit disabled when the object lock holds and no line cell can open' , async ( ) => {
276+ await mountRecordPage ( APPROVED , { } , [ parent , line ( ) ] ) ;
277+ await waitFor ( ( ) => expect ( headerEditButton ( ) ) . toBeDisabled ( ) ) ;
278+ expect ( stateLockBadge ( ) ) . toBeInTheDocument ( ) ;
279+ } ) ;
280+
281+ it ( "CONTROL: a child field whose own uiReadonlyWhen is 'false' keeps Edit enabled" , async ( ) => {
282+ await mountRecordPage ( APPROVED , { } , [ parent , line ( { uiReadonlyWhen : 'false' } ) ] ) ;
283+ expect ( headerEditButton ( ) ) . not . toBeDisabled ( ) ;
284+ expect ( stateLockBadge ( ) ) . toBeNull ( ) ;
285+ } ) ;
286+
287+ it ( 'CONTROL: a state the object lock does not hold keeps Edit enabled' , async ( ) => {
288+ await mountRecordPage ( DRAFT , { } , [ parent , line ( ) ] ) ;
289+ expect ( headerEditButton ( ) ) . not . toBeDisabled ( ) ;
290+ expect ( stateLockBadge ( ) ) . toBeNull ( ) ;
291+ } ) ;
292+ } ) ;
0 commit comments