@@ -2,123 +2,196 @@ import { test, expect, _electron as electron } from '@playwright/test';
2
2
import * as path from 'path' ;
3
3
4
4
async function launchElectronApp ( ) {
5
- return await electron . launch ( {
5
+ // Launch JupyterLab Desktop with proper configuration
6
+ const electronApp = await electron . launch ( {
6
7
args : [
8
+ path . join ( __dirname , '../build/out/main/main.js' ) ,
7
9
'--no-sandbox' ,
8
10
'--disable-setuid-sandbox' ,
9
11
'--disable-dev-shm-usage' ,
10
12
'--disable-web-security'
11
13
] ,
14
+ executablePath : undefined , // Use system electron
12
15
env : {
13
16
...process . env ,
14
- NODE_ENV : 'test' ,
15
- DISPLAY : process . env . DISPLAY || ':99'
17
+ NODE_ENV : 'development' ,
18
+ DISPLAY : process . env . DISPLAY || ':99' ,
19
+ // Set Python path to our conda environment
20
+ JUPYTERLAB_DESKTOP_PYTHON_PATH : '/usr/share/miniconda/envs/jlab_server/bin/python'
16
21
}
17
22
} ) ;
23
+
24
+ return electronApp ;
18
25
}
19
26
20
- async function waitForAppReady ( page : any ) {
21
- // Wait for basic page load
22
- await page . waitForLoadState ( 'domcontentloaded' ) ;
23
-
24
- // Give the app some time to render
25
- await page . waitForFunction ( ( ) => {
26
- return document . body && document . body . innerHTML . length > 100 ;
27
- } , { timeout : 10000 } ) ;
27
+ async function waitForAppToLoad ( page : any ) {
28
+ // Wait for the basic page to load
29
+ await page . waitForLoadState ( 'domcontentloaded' , { timeout : 20000 } ) ;
28
30
29
- // Wait a bit more for rendering to complete
30
- await page . waitForFunction ( ( ) => {
31
- return Date . now ( ) > 0 ; // Just a simple delay mechanism
32
- } , { timeout : 3000 } ) ;
31
+ // Wait for the app content to appear
32
+ try {
33
+ await page . waitForSelector ( 'body' , { timeout : 10000 } ) ;
34
+
35
+ // Give it time to initialize
36
+ await page . waitForTimeout ( 5000 ) ;
37
+
38
+ // Debug: Log page dimensions and content
39
+ const dimensions = await page . evaluate ( ( ) => {
40
+ return {
41
+ windowWidth : window . innerWidth ,
42
+ windowHeight : window . innerHeight ,
43
+ bodyScrollHeight : document . body . scrollHeight ,
44
+ bodyContent : document . body . innerHTML . substring ( 0 , 500 )
45
+ } ;
46
+ } ) ;
47
+
48
+ console . log ( 'Page dimensions:' , dimensions . windowWidth , 'x' , dimensions . windowHeight ) ;
49
+ console . log ( 'Body scroll height:' , dimensions . bodyScrollHeight ) ;
50
+ console . log ( 'Body content preview:' , dimensions . bodyContent . substring ( 0 , 100 ) + '...' ) ;
51
+
52
+ // Check if we have any meaningful content
53
+ const hasContent = await page . evaluate ( ( ) => {
54
+ return document . body && document . body . innerHTML . length > 1000 ;
55
+ } ) ;
56
+
57
+ if ( ! hasContent ) {
58
+ console . log ( 'Warning: App may not have loaded properly' ) ;
59
+ }
60
+ } catch ( error ) {
61
+ console . log ( 'Error waiting for app content:' , error ) ;
62
+ // Continue anyway and try to take screenshot
63
+ }
33
64
}
34
65
35
66
test . describe ( 'Documentation Screenshots' , ( ) => {
36
67
test ( 'should capture welcome page' , async ( ) => {
37
68
const electronApp = await launchElectronApp ( ) ;
38
69
const page = await electronApp . firstWindow ( ) ;
39
70
40
- await waitForAppReady ( page ) ;
71
+ await waitForAppToLoad ( page ) ;
41
72
42
- // Take full screenshot of the welcome page
73
+ // Take full screenshot of the welcome page that matches the documentation
43
74
await page . screenshot ( {
44
75
path : 'tests/welcome-page.png' ,
45
- fullPage : true
76
+ fullPage : true
46
77
} ) ;
47
78
48
79
await electronApp . close ( ) ;
49
80
} ) ;
50
81
51
- test ( 'should capture start session interface ' , async ( ) => {
82
+ test ( 'should capture desktop app frame ' , async ( ) => {
52
83
const electronApp = await launchElectronApp ( ) ;
53
84
const page = await electronApp . firstWindow ( ) ;
54
85
55
- await waitForAppReady ( page ) ;
86
+ await waitForAppToLoad ( page ) ;
56
87
57
- // Take screenshot of a reasonable area that should contain session controls
88
+ // Take full application window screenshot
58
89
await page . screenshot ( {
59
- path : 'tests/start-session .png' ,
60
- clip : { x : 0 , y : 50 , width : 400 , height : 300 }
90
+ path : 'tests/desktop-app-frame .png' ,
91
+ fullPage : true // Capture full page for app frame
61
92
} ) ;
62
93
63
94
await electronApp . close ( ) ;
64
95
} ) ;
65
96
66
- test ( 'should capture recent sessions interface ' , async ( ) => {
97
+ test ( 'should capture python environment status ' , async ( ) => {
67
98
const electronApp = await launchElectronApp ( ) ;
68
99
const page = await electronApp . firstWindow ( ) ;
69
100
70
- await waitForAppReady ( page ) ;
101
+ await waitForAppToLoad ( page ) ;
71
102
72
- // Take screenshot of the lower portion where recent sessions might be
73
- await page . screenshot ( {
74
- path : 'tests/recent-sessions .png' ,
75
- clip : { x : 0 , y : 300 , width : 600 , height : 200 }
103
+ // Take screenshot of title bar area (fallback approach)
104
+ await page . screenshot ( {
105
+ path : 'tests/python-env-status .png' ,
106
+ clip : { x : 0 , y : 0 , width : 800 , height : 100 }
76
107
} ) ;
77
108
78
109
await electronApp . close ( ) ;
79
110
} ) ;
80
111
81
- test ( 'should capture desktop app frame ' , async ( ) => {
112
+ test ( 'should capture start session interface ' , async ( ) => {
82
113
const electronApp = await launchElectronApp ( ) ;
83
114
const page = await electronApp . firstWindow ( ) ;
84
115
85
- await waitForAppReady ( page ) ;
86
-
87
- // For desktop app frame, we want the full application window
88
- await page . screenshot ( {
89
- path : 'tests/desktop-app-frame.png' ,
90
- fullPage : true
91
- } ) ;
116
+ await waitForAppToLoad ( page ) ;
117
+
118
+ // Check if this is the main window or title bar
119
+ const dimensions = await page . evaluate ( ( ) => ( {
120
+ width : window . innerWidth ,
121
+ height : window . innerHeight
122
+ } ) ) ;
123
+
124
+ if ( dimensions . height > 100 ) {
125
+ // Main window - take a reasonable clip
126
+ await page . screenshot ( {
127
+ path : 'tests/start-session.png' ,
128
+ clip : { x : 0 , y : 50 , width : 300 , height : 200 }
129
+ } ) ;
130
+ } else {
131
+ // Small window - take full screenshot
132
+ await page . screenshot ( {
133
+ path : 'tests/start-session.png' ,
134
+ fullPage : true
135
+ } ) ;
136
+ }
92
137
93
138
await electronApp . close ( ) ;
94
139
} ) ;
95
140
96
- test ( 'should capture python environment status ' , async ( ) => {
141
+ test ( 'should capture connect to server interface ' , async ( ) => {
97
142
const electronApp = await launchElectronApp ( ) ;
98
143
const page = await electronApp . firstWindow ( ) ;
99
144
100
- await waitForAppReady ( page ) ;
101
-
102
- // Take screenshot of title bar area
103
- await page . screenshot ( {
104
- path : 'tests/python-env-status.png' ,
105
- clip : { x : 0 , y : 0 , width : 800 , height : 100 }
106
- } ) ;
145
+ await waitForAppToLoad ( page ) ;
146
+
147
+ // Check if this is the main window or title bar
148
+ const dimensions = await page . evaluate ( ( ) => ( {
149
+ width : window . innerWidth ,
150
+ height : window . innerHeight
151
+ } ) ) ;
152
+
153
+ if ( dimensions . height > 100 ) {
154
+ // Main window - take a reasonable clip
155
+ await page . screenshot ( {
156
+ path : 'tests/start-session-connect.png' ,
157
+ clip : { x : 0 , y : 100 , width : 250 , height : 100 }
158
+ } ) ;
159
+ } else {
160
+ // Small window - take full screenshot
161
+ await page . screenshot ( {
162
+ path : 'tests/start-session-connect.png' ,
163
+ fullPage : true
164
+ } ) ;
165
+ }
107
166
108
167
await electronApp . close ( ) ;
109
168
} ) ;
110
169
111
- test ( 'should capture connect to server interface' , async ( ) => {
170
+ test ( 'should capture recent sessions interface' , async ( ) => {
112
171
const electronApp = await launchElectronApp ( ) ;
113
172
const page = await electronApp . firstWindow ( ) ;
114
173
115
- await waitForAppReady ( page ) ;
116
-
117
- // Take screenshot of a portion that might contain connect options
118
- await page . screenshot ( {
119
- path : 'tests/start-session-connect.png' ,
120
- clip : { x : 0 , y : 100 , width : 400 , height : 250 }
121
- } ) ;
174
+ await waitForAppToLoad ( page ) ;
175
+
176
+ // Check if this is the main window or title bar
177
+ const dimensions = await page . evaluate ( ( ) => ( {
178
+ width : window . innerWidth ,
179
+ height : window . innerHeight
180
+ } ) ) ;
181
+
182
+ if ( dimensions . height > 100 ) {
183
+ // Main window - take a reasonable clip from lower area
184
+ await page . screenshot ( {
185
+ path : 'tests/recent-sessions.png' ,
186
+ clip : { x : 0 , y : 400 , width : 400 , height : Math . min ( 150 , dimensions . height - 400 ) }
187
+ } ) ;
188
+ } else {
189
+ // Small window - take full screenshot
190
+ await page . screenshot ( {
191
+ path : 'tests/recent-sessions.png' ,
192
+ fullPage : true
193
+ } ) ;
194
+ }
122
195
123
196
await electronApp . close ( ) ;
124
197
} ) ;
0 commit comments