@@ -16,7 +16,11 @@ async function renderResponse(ok, data) {
1616 getElementById ( id ) { if ( ! elements . has ( id ) ) elements . set ( id , element ( ) ) ; return elements . get ( id ) ; } ,
1717 createElement : element
1818 } ;
19- const code = renderControlPlaneViewHtml ( ) . match ( / < s c r i p t > ( [ \s \S ] * ?) < \/ s c r i p t > / ) [ 1 ] ;
19+ const html = renderControlPlaneViewHtml ( ) ;
20+ const start = html . indexOf ( '<script>' ) ;
21+ const end = html . indexOf ( '</script>' , start ) ;
22+ assert . ok ( start >= 0 && end > start , 'fixed renderer template must contain its inline script' ) ;
23+ const code = html . slice ( start + '<script>' . length , end ) ;
2024 vm . runInNewContext ( code , {
2125 document, window : { addEventListener ( ) { } , devicePixelRatio : 1 } , setInterval ( ) { } ,
2226 fetch : async ( ) => ( { ok, json : async ( ) => data } )
@@ -25,15 +29,23 @@ async function renderResponse(ok, data) {
2529 return elements ;
2630}
2731
32+ let passed = 0 ;
2833( async ( ) => {
2934 const failed = await renderResponse ( false , { ok : false , error : 'snapshot unavailable' } ) ;
3035 assert . strictEqual ( failed . get ( 'status' ) . textContent , 'offline' , 'HTTP errors must not display a healthy empty view' ) ;
36+ passed += 1 ;
3137 const malformed = await renderResponse ( true , { schemaVersion : 'wrong' } ) ;
3238 assert . strictEqual ( malformed . get ( 'status' ) . textContent , 'offline' , 'invalid schemas must be rejected' ) ;
39+ passed += 1 ;
3340 const valid = await renderResponse ( true , {
3441 schemaVersion : 'ecc.control-plane.view.v1' , tasks : [ ] , lanes : [ ] , pairs : [ ] , events : [ ] ,
3542 projection : { agents : [ ] } , thresholds : { ta : 0.35 , ra : 0.7 } , counts : { }
3643 } ) ;
3744 assert . ok ( valid . get ( 'status' ) . textContent . includes ( '0 tasks' ) ) ;
38- console . log ( 'PASS control-plane UI error and schema handling' ) ;
39- } ) ( ) . catch ( error => { console . error ( error . message ) ; process . exitCode = 1 ; } ) ;
45+ passed += 1 ;
46+ console . log ( `Results: Passed: ${ passed } , Failed: 0` ) ;
47+ } ) ( ) . catch ( error => {
48+ console . error ( error . message ) ;
49+ console . log ( `Results: Passed: ${ passed } , Failed: 1` ) ;
50+ process . exitCode = 1 ;
51+ } ) ;
0 commit comments