@@ -85,6 +85,36 @@ test.describe('app', () => {
8585    expect ( await  page . $$ ( 'canvas' ) ) . toHaveLength ( 2 ) 
8686  } ) 
8787
88+   test ( 'loads a test surface' ,  async  ( {  page } )  =>  { 
89+     await  page . goto ( BASE_URL ) ; 
90+ 
91+     await  loadTestSurfImage ( page ) ; 
92+     await  page . waitForTimeout ( 1000 ) ;  // wait time to work around a bug 
93+ 
94+     expect ( await  page . waitForSelector ( 'canvas' ) ) . toBeTruthy ( ) ; 
95+     expect ( await  page . $$ ( 'canvas' ) ) . toHaveLength ( 1 ) ; 
96+ 
97+     await  loadTestSurfImage ( page ) ; 
98+     expect ( await  page . $$ ( 'canvas' ) ) . toHaveLength ( 2 ) ; 
99+ 
100+     expect ( await  page . textContent ( 'text=/Number of Points: 40962/i' ) ) . toBeTruthy ( ) ; 
101+   } ) ; 
102+ 
103+   test ( 'loads a test image and overlay' ,  async  ( {  page } )  =>  { 
104+     await  page . goto ( BASE_URL ) ; 
105+ 
106+     await  loadTestSurfImage ( page ) ; 
107+ 
108+     await  page . waitForTimeout ( 1000 ) ;  // duplicated code to work around a bug 
109+     await  loadTestSurfImage ( page ) ;  // duplicated code to work around a bug 
110+ 
111+     await  loadTestSurfOverlay ( page ,  'curv' ) ; 
112+ 
113+     await  page . waitForTimeout ( 1000 ) ;  // duplicated code to work around a bug 
114+     await  loadTestSurfOverlay ( page ,  'curv' ) ;  // duplicated code to work around a bug 
115+ 
116+   } ) ; 
117+ 
88118  test ( 'loads an image and checks the menu bar' ,  async  ( {  page } )  =>  { 
89119    await  page . goto ( BASE_URL ) 
90120
@@ -125,5 +155,38 @@ async function loadTestImage(page) {
125155      uri : testLink , 
126156    } , 
127157  } 
128-   await  page . evaluate ( ( m )  =>  window . postMessage ( m ,  '*' ) ,  message ) 
158+   await  page . evaluate ( ( m )  =>  window . postMessage ( m ,  '*' ) ,  message ) ; 
159+ } 
160+ 
161+ async  function  loadTestSurfImage ( page )  { 
162+   const  testLink  =  'https://niivue.github.io/niivue/images/BrainMesh_ICBM152.lh.mz3' ; 
163+   // send a message to the app to load the test image 
164+   const  message  =  { 
165+     type : 'addImage' , 
166+     body : { 
167+       data : '' , 
168+       uri : testLink , 
169+     } , 
170+   } 
171+   await  page . evaluate ( ( m )  =>  window . postMessage ( m ,  '*' ) ,  message ) ; 
172+ } 
173+ 
174+ async  function  loadTestSurfOverlay ( page ,  file_type )  { 
175+   let  testLink ; 
176+ 
177+   if  ( file_type  ===  'curv' )  { 
178+     testLink  =  'https://niivue.github.io/niivue/images/BrainMesh_ICBM152.lh.curv' ; 
179+   }  else  if  ( file_type  ===  'other' )  { 
180+     testLink  =  'https://niivue.github.io/niivue/images/BrainMesh_ICBM152.lh.motor.mz3' ; 
181+   } 
182+   // send a message to the app to load the test image 
183+   const  message  =  { 
184+     type : 'addMeshOverlay' , 
185+     body : { 
186+       index : 0 , 
187+       data : '' , 
188+       uri : String ( testLink ) , 
189+     } , 
190+   } 
191+   await  page . evaluate ( ( m )  =>  window . postMessage ( m ,  '*' ) ,  message ) ; 
129192} 
0 commit comments