@@ -180,15 +180,15 @@ describe('DiagramEditorSidePanel', function () {
180180 it ( 'should render a nested field context drawer' , async function ( ) {
181181 const result = renderDrawer ( ) ;
182182 result . plugin . store . dispatch (
183- selectField ( 'flights.routes' , [ 'airline' , 'id ' ] )
183+ selectField ( 'flights.routes' , [ 'airline' , '_id ' ] )
184184 ) ;
185185
186186 await waitForDrawerToOpen ( ) ;
187- expect ( screen . getByTitle ( 'routes.airline.id ' ) ) . to . be . visible ;
187+ expect ( screen . getByTitle ( 'routes.airline._id ' ) ) . to . be . visible ;
188188
189189 const nameInput = screen . getByLabelText ( 'Field name' ) ;
190190 expect ( nameInput ) . to . be . visible ;
191- expect ( nameInput ) . to . have . value ( 'id ' ) ;
191+ expect ( nameInput ) . to . have . value ( '_id ' ) ;
192192
193193 const selectedTypes = getMultiComboboxValues ( 'lg-combobox-datatype' ) ;
194194 expect ( selectedTypes ) . to . have . lengthOf ( 1 ) ;
@@ -198,16 +198,16 @@ describe('DiagramEditorSidePanel', function () {
198198 it ( 'should delete a field' , async function ( ) {
199199 const result = renderDrawer ( ) ;
200200 result . plugin . store . dispatch (
201- selectField ( 'flights.routes' , [ 'airline' , 'id ' ] )
201+ selectField ( 'flights.routes' , [ 'airline' , '_id ' ] )
202202 ) ;
203203
204204 await waitForDrawerToOpen ( ) ;
205- expect ( screen . getByTitle ( 'routes.airline.id ' ) ) . to . be . visible ;
205+ expect ( screen . getByTitle ( 'routes.airline._id ' ) ) . to . be . visible ;
206206
207207 userEvent . click ( screen . getByLabelText ( / d e l e t e f i e l d / i) ) ;
208208
209209 await waitFor ( ( ) => {
210- expect ( screen . queryByText ( 'routes.airline.id ' ) ) . not . to . exist ;
210+ expect ( screen . queryByText ( 'routes.airline._id ' ) ) . not . to . exist ;
211211 } ) ;
212212 expect ( screen . queryByLabelText ( 'Name' ) ) . to . not . exist ;
213213
@@ -219,7 +219,7 @@ describe('DiagramEditorSidePanel', function () {
219219
220220 expect (
221221 modifiedCollection ?. jsonSchema . properties ?. airline . properties
222- ) . to . not . have . property ( 'id ' ) ; // deleted field
222+ ) . to . not . have . property ( '_id ' ) ; // deleted field
223223 expect (
224224 modifiedCollection ?. jsonSchema . properties ?. airline . properties
225225 ) . to . have . property ( 'name' ) ; // sibling field remains
@@ -268,7 +268,7 @@ describe('DiagramEditorSidePanel', function () {
268268 await waitForDrawerToOpen ( ) ;
269269 expect ( screen . getByTitle ( 'routes.airline.name' ) ) . to . be . visible ;
270270
271- updateInputWithBlur ( 'Field name' , 'id ' ) ;
271+ updateInputWithBlur ( 'Field name' , '_id ' ) ;
272272
273273 await waitFor ( ( ) => {
274274 expect ( screen . queryByText ( 'Field already exists.' ) ) . to . exist ;
@@ -359,6 +359,48 @@ describe('DiagramEditorSidePanel', function () {
359359 ) . to . have . members ( [ 'bool' , 'int' ] ) ;
360360 } ) ;
361361 } ) ;
362+
363+ it ( 'top level _id field is treated as readonly' , async function ( ) {
364+ const result = renderDrawer ( ) ;
365+ result . plugin . store . dispatch ( selectField ( 'flights.routes' , [ '_id' ] ) ) ;
366+
367+ await waitForDrawerToOpen ( ) ;
368+ expect ( screen . getByTitle ( 'routes._id' ) ) . to . be . visible ;
369+
370+ expect ( screen . queryByLabelText ( / d e l e t e f i e l d / i) ) . not . to . exist ;
371+ expect ( screen . getByLabelText ( 'Field name' ) ) . to . have . attribute (
372+ 'aria-disabled' ,
373+ 'true'
374+ ) ;
375+ expect ( screen . getByLabelText ( 'Datatype' ) ) . to . have . attribute (
376+ 'aria-disabled' ,
377+ 'true'
378+ ) ;
379+ } ) ;
380+
381+ it ( 'nested _id field is not treated as readonly' , async function ( ) {
382+ const result = renderDrawer ( ) ;
383+ result . plugin . store . dispatch (
384+ selectField ( 'flights.routes' , [ 'airline' , '_id' ] )
385+ ) ;
386+
387+ await waitForDrawerToOpen ( ) ;
388+ expect ( screen . getByTitle ( 'routes.airline._id' ) ) . to . be . visible ;
389+
390+ expect ( screen . queryByLabelText ( / d e l e t e f i e l d / i) ) . to . exist ;
391+ expect ( screen . queryByLabelText ( / d e l e t e f i e l d / i) ) . to . have . attribute (
392+ 'aria-disabled' ,
393+ 'false'
394+ ) ;
395+ expect ( screen . getByLabelText ( 'Field name' ) ) . to . have . attribute (
396+ 'aria-disabled' ,
397+ 'false'
398+ ) ;
399+ expect ( screen . getByLabelText ( 'Datatype' ) ) . to . have . attribute (
400+ 'aria-disabled' ,
401+ 'false'
402+ ) ;
403+ } ) ;
362404 } ) ;
363405
364406 it ( 'should change the content of the drawer when selecting different items' , async function ( ) {
0 commit comments