@@ -16,6 +16,10 @@ function createContext(): DevframeHubContext {
1616 resolveOrigin : ( ) => 'http://localhost:5173' ,
1717 getStorageDir : ( ) => storageDir ,
1818 } ,
19+ // Minimal stubs so the built-in `~terminals`/`~messages` getters
20+ // (`when`/`badge`) can be evaluated without a full context.
21+ terminals : { sessions : new Map ( ) } ,
22+ messages : { entries : new Map ( ) } ,
1923 } as unknown as DevframeHubContext
2024}
2125
@@ -189,3 +193,48 @@ describe('devframeDockHost grouping', () => {
189193 } ) ) . toThrow ( 'Dock with id "ghost" is not registered and cannot be updated' )
190194 } )
191195} )
196+
197+ describe ( 'devframeDockHost built-in gating' , ( ) => {
198+ it ( 'includes all three built-ins by default' , ( ) => {
199+ const host = new DevframeDocksHost ( createContext ( ) )
200+ const ids = host . values ( ) . map ( entry => entry . id )
201+ expect ( ids ) . toEqual ( [ '~terminals' , '~messages' , '~settings' ] )
202+ } )
203+
204+ it ( 'treats an empty builtinDocks map as all-enabled' , ( ) => {
205+ const host = new DevframeDocksHost ( createContext ( ) , { } )
206+ const ids = host . values ( ) . map ( entry => entry . id )
207+ expect ( ids ) . toEqual ( [ '~terminals' , '~messages' , '~settings' ] )
208+ } )
209+
210+ it ( 'omits the built-ins gated with `false`, keeping the rest' , ( ) => {
211+ const host = new DevframeDocksHost ( createContext ( ) , { terminals : false , messages : false } )
212+ const ids = host . values ( ) . map ( entry => entry . id )
213+ expect ( ids ) . toEqual ( [ '~settings' ] )
214+ } )
215+
216+ it ( 'keeps an explicitly-enabled built-in and drops an omitted-as-false sibling' , ( ) => {
217+ const host = new DevframeDocksHost ( createContext ( ) , { terminals : true , settings : false } )
218+ const ids = host . values ( ) . map ( entry => entry . id )
219+ expect ( ids ) . toEqual ( [ '~terminals' , '~messages' ] )
220+ } )
221+
222+ it ( 'keeps user views ahead of gated built-ins' , ( ) => {
223+ const host = new DevframeDocksHost ( createContext ( ) , { messages : false , settings : false } )
224+ host . register ( {
225+ type : 'iframe' ,
226+ id : 'app:overview' ,
227+ title : 'Overview' ,
228+ icon : 'ph:gauge-duotone' ,
229+ url : '/__app/' ,
230+ } )
231+
232+ const ids = host . values ( ) . map ( entry => entry . id )
233+ expect ( ids ) . toEqual ( [ 'app:overview' , '~terminals' ] )
234+ } )
235+
236+ it ( 'drops every built-in when includeBuiltin is false, regardless of gating' , ( ) => {
237+ const host = new DevframeDocksHost ( createContext ( ) , { terminals : true , messages : true , settings : true } )
238+ expect ( host . values ( { includeBuiltin : false } ) ) . toEqual ( [ ] )
239+ } )
240+ } )
0 commit comments