@@ -51,15 +51,37 @@ class VolViewPage extends Page {
5151 await browser . waitUntil (
5252 async function viewsExist ( ) {
5353 const views = await this_ . views ;
54- if ( ( await views . length ) === 0 ) return false ;
55- const inView = await Promise . all (
56- Array . from ( views ) . map ( ( v ) => v . isDisplayed ( { withinViewport : true } ) )
54+ const viewCount = await views . length ;
55+
56+ if ( viewCount === 0 ) return false ;
57+
58+ // Check if at least one view has real dimensions
59+ const viewsArray = await Promise . all (
60+ Array . from ( { length : viewCount } ) . map ( async ( _ , i ) => {
61+ const view = views [ i ] ;
62+ const [ width , height , exists ] = await Promise . all ( [
63+ view . getAttribute ( 'width' ) . catch ( ( ) => null ) ,
64+ view . getAttribute ( 'height' ) . catch ( ( ) => null ) ,
65+ view . isExisting ( ) . catch ( ( ) => false ) ,
66+ ] ) ;
67+
68+ // Canvas should have real dimensions, not be a 1x1 placeholder
69+ // Accept any size > 10 as a real view
70+ if ( width && height && exists ) {
71+ const w = parseInt ( width , 10 ) ;
72+ const h = parseInt ( height , 10 ) ;
73+ return w > 10 && h > 10 ;
74+ }
75+ return false ;
76+ } )
5777 ) ;
58- return inView . every ( Boolean ) ;
78+
79+ return viewsArray . some ( Boolean ) ;
5980 } ,
6081 {
6182 timeout,
62- timeoutMsg : `expected at least 1 view to be displayed in viewport` ,
83+ interval : 1000 ,
84+ timeoutMsg : `expected at least 1 view to be rendered with real dimensions` ,
6385 }
6486 ) ;
6587 }
@@ -169,65 +191,20 @@ class VolViewPage extends Page {
169191 return exists ? pwfEditor : null ;
170192 }
171193
172- async getVolumePresetsPanel ( ) {
173- const titles = $ ( 'div.v-expansion-panel' ) . $$ ( 'div.v-expansion-panel-title' ) ;
174- const length = await titles . length ;
175- if ( length === 0 ) return null ;
176-
177- const titleTexts = await Promise . all (
178- Array . from ( { length } ) . map ( async ( _ , i ) => ( {
179- element : titles [ i ] ,
180- text : await titles [ i ] . getText ( ) ,
181- } ) )
182- ) ;
183-
184- const found = titleTexts . find ( ( { text } ) => text . includes ( 'Color Presets' ) ) ;
185- return found ?. element || null ;
186- }
187-
188- async getCinematicRenderingPanel ( ) {
189- const titles = $ ( 'div.v-expansion-panel' ) . $$ ( 'div.v-expansion-panel-title' ) ;
190- const length = await titles . length ;
191- if ( length === 0 ) return null ;
192-
193- const titleTexts = await Promise . all (
194- Array . from ( { length } ) . map ( async ( _ , i ) => ( {
195- element : titles [ i ] ,
196- text : await titles [ i ] . getText ( ) ,
197- } ) )
198- ) ;
199-
200- const found = titleTexts . find ( ( { text } ) =>
201- text . includes ( 'Cinematic Rendering' )
202- ) ;
203- return found ?. element || null ;
204- }
205-
206194 get create3DViewMessage ( ) {
207195 return $ ( 'div.text-body-2.text-center.text-medium-emphasis' ) ;
208196 }
209197
210198 async getView3D ( ) {
211- // The 3D view is the second view in the default layout (index 1)
212- // All views have the same data-testid, so we need to get by position
213- const views = $$ ( 'div[data-testid="vtk-view vtk-two-view"]' ) ;
214- const length = await views . length ;
215- if ( length >= 2 ) {
216- // The Volume (3D) view is at index 1 in the default layout
217- return views [ 1 ] ;
218- }
219- return null ;
199+ const view3D = $ ( 'div[data-testid="vtk-view vtk-volume-view"]' ) ;
200+ const exists = await view3D . isExisting ( ) ;
201+ return exists ? view3D : null ;
220202 }
221203
222204 async getView2D ( ) {
223- // Get the first view (Coronal at index 0 in default layout)
224- const views = $$ ( 'div[data-testid="vtk-view vtk-two-view"]' ) ;
225- const length = await views . length ;
226- if ( length >= 1 ) {
227- // The Coronal (2D) view is at index 0 in the default layout
228- return views [ 0 ] ;
229- }
230- return null ;
205+ const view2D = $ ( 'div[data-testid="vtk-view vtk-two-view"]' ) ;
206+ const exists = await view2D . isExisting ( ) ;
207+ return exists ? view2D : null ;
231208 }
232209}
233210
0 commit comments