@@ -30,6 +30,10 @@ import {
3030 StudioObjectRecordsCanvas ,
3131} from './studio-canvas-preview' ;
3232import type { StudioCanvasListView } from './studio-canvas-preview' ;
33+ // The grid's own module: the registry above holds it behind a lazy wrapper of
34+ // the same name (objectstack#33582), so the grid's behaviour is pinned on the
35+ // module's component, and the wrapper by the lazy-registration block below.
36+ import { StudioObjectRecordsCanvas as ObjectRecordsCanvas } from './studio-object-records-canvas' ;
3337
3438describe ( 'studio-canvas-preview registry' , ( ) => {
3539 it ( 'ships a built-in default for `object` (the records grid)' , ( ) => {
@@ -104,7 +108,7 @@ describe('navEntryListTarget — the runtime reading of an object entry (objectu
104108 } ) ;
105109} ) ;
106110
107- describe ( 'StudioObjectRecordsCanvas — renders the entry it is open on (objectui#11774)' , ( ) => {
111+ describe ( 'the default object canvas — renders the entry it is open on (objectui#11774)' , ( ) => {
108112 /** Stands in for `plugin-view`'s `object-view`, recording the schema it is handed. */
109113 function ObjectViewRecorder ( { schema } : { schema : Record < string , unknown > } ) {
110114 return < pre data-testid = "object-view-schema" > { JSON . stringify ( schema ) } </ pre > ;
@@ -134,7 +138,7 @@ describe('StudioObjectRecordsCanvas — renders the entry it is open on (objectu
134138 render (
135139 < MetadataCtx . Provider value = { METADATA } >
136140 < StudioCanvasNavEntryContext . Provider value = { entry } >
137- < StudioObjectRecordsCanvas type = "object" name = "showcase_task" draft = { { } } />
141+ < ObjectRecordsCanvas type = "object" name = "showcase_task" draft = { { } } />
138142 </ StudioCanvasNavEntryContext . Provider >
139143 </ MetadataCtx . Provider > ,
140144 ) ;
@@ -177,7 +181,7 @@ describe('StudioObjectRecordsCanvas — renders the entry it is open on (objectu
177181 * it is editing: the panel's buffer, handed over through
178182 * `StudioCanvasListViewContext` (beside the published props, like the entry).
179183 */
180- describe ( 'StudioObjectRecordsCanvas — shows the list view its panel edits (objectui#11823)' , ( ) => {
184+ describe ( 'the default object canvas — shows the list view its panel edits (objectui#11823)' , ( ) => {
181185 function ObjectViewRecorder ( { schema } : { schema : Record < string , unknown > } ) {
182186 return < pre data-testid = "object-view-schema" > { JSON . stringify ( schema ) } </ pre > ;
183187 }
@@ -212,7 +216,7 @@ describe('StudioObjectRecordsCanvas — shows the list view its panel edits (obj
212216 < MetadataCtx . Provider value = { METADATA } >
213217 < StudioCanvasNavEntryContext . Provider value = { entry } >
214218 < StudioCanvasListViewContext . Provider value = { edited } >
215- < StudioObjectRecordsCanvas type = "object" name = "showcase_task" draft = { { } } />
219+ < ObjectRecordsCanvas type = "object" name = "showcase_task" draft = { { } } />
216220 </ StudioCanvasListViewContext . Provider >
217221 </ StudioCanvasNavEntryContext . Provider >
218222 </ MetadataCtx . Provider > ,
@@ -254,3 +258,53 @@ describe('StudioObjectRecordsCanvas — shows the list view its panel edits (obj
254258 } ) ;
255259 } ) ;
256260} ) ;
261+
262+ /**
263+ * objectstack#33582 — the registered `object` default is a lazy wrapper of the
264+ * grid's module, not the module's component: the registry module is imported
265+ * by the package entry at load, so a by-value default held the grid and the
266+ * designer strings in the console's eager closure. Drawn through the registry,
267+ * as `StudioDesignSurface` draws it, the wrapper shows its loading line, then
268+ * the grid with the schema the module's own component renders.
269+ */
270+ describe ( 'the registered object default loads the grid on first draw (objectstack#33582)' , ( ) => {
271+ function ObjectViewRecorder ( { schema } : { schema : Record < string , unknown > } ) {
272+ return < pre data-testid = "object-view-schema" > { JSON . stringify ( schema ) } </ pre > ;
273+ }
274+ const METADATA : MetadataContextValue = {
275+ apps : [ ] ,
276+ objects : [ { name : 'showcase_task' , label : 'Task' } ] ,
277+ dashboards : [ ] ,
278+ reports : [ ] ,
279+ pages : [ ] ,
280+ loading : false ,
281+ error : null ,
282+ refresh : async ( ) => { } ,
283+ invalidate : ( ) => { } ,
284+ ensureType : async ( ) => [ ] ,
285+ getItem : async ( ) => null ,
286+ getItemsByType : ( ) => [ ] ,
287+ } ;
288+
289+ beforeAll ( ( ) => {
290+ ComponentRegistry . register ( 'object-view' , ObjectViewRecorder as never , { namespace : 'plugin-view' } ) ;
291+ } ) ;
292+ afterEach ( cleanup ) ;
293+
294+ it ( 'the default is the wrapper, not the grid module\'s own component' , ( ) => {
295+ expect ( getStudioCanvasPreview ( 'object' ) ) . toBe ( StudioObjectRecordsCanvas ) ;
296+ expect ( StudioObjectRecordsCanvas ) . not . toBe ( ObjectRecordsCanvas ) ;
297+ } ) ;
298+
299+ it ( 'drawn through the registry, it loads and draws the grid' , async ( ) => {
300+ const Canvas = getStudioCanvasPreview ( 'object' ) ! ;
301+ render (
302+ < MetadataCtx . Provider value = { METADATA } >
303+ < Canvas type = "object" name = "showcase_task" draft = { { } } />
304+ </ MetadataCtx . Provider > ,
305+ ) ;
306+ const grid = await screen . findByTestId ( 'object-view-schema' ) ;
307+ expect ( JSON . parse ( grid . textContent ?? 'null' ) ) . toEqual ( { type : 'object-view' , objectName : 'showcase_task' } ) ;
308+ expect ( screen . queryByText ( 'Loading studio canvas…' ) ) . toBeNull ( ) ;
309+ } ) ;
310+ } ) ;
0 commit comments