@@ -79,7 +79,12 @@ const ALL_BOOTS_TIMEOUT_MS = BOOTS * (BOOT_TIMEOUT_MS + BLOCK_GRACE_MS + 30_000)
7979
8080const SCAFFOLD = {
8181 manifest : { id : 'com.example.order' , namespace : 'order' , version : '1.0.0' , type : 'app' , name : 'order' } ,
82- objects : [ { name : 'order_item' , label : 'Item' , fields : { title : { type : 'text' , label : 'Title' } } } ] ,
82+ objects : [ {
83+ name : 'order_item' ,
84+ label : 'Item' ,
85+ sharingModel : 'private' ,
86+ fields : { title : { type : 'text' , label : 'Title' } } ,
87+ } ] ,
8388} ;
8489
8590const ESC = String . fromCharCode ( 27 ) ;
@@ -217,40 +222,72 @@ function recorded(): BootReading[] {
217222 return readings as BootReading [ ] ;
218223}
219224
220- /** Where the block's header is, and what printed in the four lines under it. */
221- function blockOf ( r : BootReading ) : { header : number ; under : string [ ] } {
225+ /** One boot's reading of the screen: where the block starts and ends, and what printed inside it. */
226+ interface ScreenReading {
227+ boot : number ;
228+ /** The block header's line, or -1. */
229+ header : number ;
230+ /** The block's last row (`Disable`), or -1. */
231+ disable : number ;
232+ /** Lines between the header and the last row that are not the block's own rows. */
233+ foreign : string [ ] ;
234+ /** The `🔑 Dev admin` line, or -1. */
235+ credential : number ;
236+ /** The banner's last row (`Press Ctrl+C to stop`), or -1. */
237+ tail : number ;
238+ }
239+
240+ function readScreen ( r : BootReading ) : ScreenReading {
222241 const header = r . lines . findIndex ( ( l ) => l . includes ( BLOCK_HEADER ) ) ;
223- expect ( header , `boot ${ r . boot } : no MCP connect block on the screen` ) . toBeGreaterThan ( - 1 ) ;
224- return { header, under : r . lines . slice ( header + 1 , header + 1 + BLOCK_ROWS . length ) } ;
242+ const disable = header < 0 ? - 1 : r . lines . findIndex ( ( l , i ) => i > header && BLOCK_ROWS [ 3 ] . test ( l ) ) ;
243+ const foreign = header < 0 || disable < 0
244+ ? [ ]
245+ : r . lines . slice ( header + 1 , disable ) . filter ( ( l ) => ! BLOCK_ROWS . some ( ( row ) => row . test ( l ) ) ) . map ( ( l ) => l . trim ( ) ) ;
246+ return {
247+ boot : r . boot ,
248+ header,
249+ disable,
250+ foreign,
251+ credential : r . lines . findIndex ( ( l ) => l . includes ( CREDENTIAL ) ) ,
252+ tail : r . lines . findIndex ( ( l ) => l . includes ( BANNER_TAIL ) ) ,
253+ } ;
254+ }
255+
256+ /**
257+ * Every boot's reading, after the control: each boot printed the whole block,
258+ * its banner tail and its credential line, so every verdict below is a reading
259+ * of something that is there rather than of an absence.
260+ */
261+ function screens ( ) : ScreenReading [ ] {
262+ const all = recorded ( ) . map ( readScreen ) ;
263+ const absent = all . flatMap ( ( s ) => [
264+ ...( s . header < 0 || s . disable < 0 ? [ `boot ${ s . boot } : no whole MCP connect block on the screen` ] : [ ] ) ,
265+ ...( s . tail < 0 ? [ `boot ${ s . boot } : no banner tail` ] : [ ] ) ,
266+ ...( s . credential < 0 ? [ `boot ${ s . boot } : no credential line — the boot did not seed its dev admin` ] : [ ] ) ,
267+ ] ) ;
268+ expect ( absent , 'the control: every boot prints the block, the banner and the credential line' ) . toEqual ( [ ] ) ;
269+ return all ;
225270}
226271
227272describe ( '#22410 — `os dev` prints the banner, then the MCP block, each block whole' , ( ) => {
228273 it ( 'the MCP block\'s rows are contiguous on every boot' , ( ) => {
229- for ( const r of recorded ( ) ) {
230- const { under } = blockOf ( r ) ;
231- under . forEach ( ( line , i ) => {
232- expect ( line , `boot ${ r . boot } : row ${ i + 1 } under the block header is not the block's own` ) . toMatch ( BLOCK_ROWS [ i ] ) ;
233- } ) ;
234- }
274+ const split = screens ( )
275+ . filter ( ( s ) => s . disable - s . header !== BLOCK_ROWS . length || s . foreign . length > 0 )
276+ . map ( ( s ) => `boot ${ s . boot } : ${ s . foreign . length } foreign line(s) inside the block: ${ JSON . stringify ( s . foreign ) } ` ) ;
277+ expect ( split , `${ split . length } of ${ BOOTS } boots split the block` ) . toEqual ( [ ] ) ;
235278 } ) ;
236279
237280 it ( 'the dev admin credential line sits outside the block on every boot' , ( ) => {
238- for ( const r of recorded ( ) ) {
239- const { header } = blockOf ( r ) ;
240- const credential = r . lines . findIndex ( ( l ) => l . includes ( CREDENTIAL ) ) ;
241- // Present, so "outside" is a reading and not an absence.
242- expect ( credential , `boot ${ r . boot } : no credential line — the boot did not seed its dev admin` ) . toBeGreaterThan ( - 1 ) ;
243- const inside = credential > header && credential <= header + BLOCK_ROWS . length ;
244- expect ( inside , `boot ${ r . boot } : the credential line printed inside the MCP block` ) . toBe ( false ) ;
245- }
281+ const inside = screens ( )
282+ . filter ( ( s ) => s . credential > s . header && s . credential < s . disable )
283+ . map ( ( s ) => `boot ${ s . boot } : the credential line printed inside the MCP block` ) ;
284+ expect ( inside , `${ inside . length } of ${ BOOTS } boots printed the credential inside the block` ) . toEqual ( [ ] ) ;
246285 } ) ;
247286
248287 it ( 'the block comes after the whole banner on every boot — one fixed order' , ( ) => {
249- for ( const r of recorded ( ) ) {
250- const { header } = blockOf ( r ) ;
251- const tail = r . lines . findIndex ( ( l ) => l . includes ( BANNER_TAIL ) ) ;
252- expect ( tail , `boot ${ r . boot } : no banner tail` ) . toBeGreaterThan ( - 1 ) ;
253- expect ( header , `boot ${ r . boot } : the MCP block started before the banner finished` ) . toBeGreaterThan ( tail ) ;
254- }
288+ const early = screens ( )
289+ . filter ( ( s ) => s . header < s . tail )
290+ . map ( ( s ) => `boot ${ s . boot } : the MCP block started before the banner finished` ) ;
291+ expect ( early , `${ early . length } of ${ BOOTS } boots printed the block inside or above the banner` ) . toEqual ( [ ] ) ;
255292 } ) ;
256293} ) ;
0 commit comments