1
+ import { test , expect , _electron as electron } from '@playwright/test' ;
2
+ import * as path from 'path' ;
3
+
4
+ // Helper function to launch electron app
5
+ async function launchElectronApp ( ) {
6
+ return await electron . launch ( {
7
+ args : [
8
+ path . join ( __dirname , '../build/out/main/main.js' ) ,
9
+ '--no-sandbox' ,
10
+ '--disable-setuid-sandbox' ,
11
+ '--disable-dev-shm-usage'
12
+ ] ,
13
+ env : {
14
+ ...process . env ,
15
+ NODE_ENV : 'test' ,
16
+ SKIP_BUNDLED_ENV_SETUP : 'true'
17
+ }
18
+ } ) ;
19
+ }
20
+
21
+ test . describe ( 'JupyterLab Desktop UI Testing' , ( ) => {
22
+ test ( 'should capture different application states' , async ( ) => {
23
+ const electronApp = await launchElectronApp ( ) ;
24
+ const page = await electronApp . firstWindow ( ) ;
25
+
26
+ // Wait for app to fully load
27
+ await page . waitForTimeout ( 8000 ) ;
28
+
29
+ // Capture the initial state - could be welcome screen or main interface
30
+ await page . screenshot ( {
31
+ path : 'tests/snapshots/app-initial-state.png' ,
32
+ fullPage : true
33
+ } ) ;
34
+
35
+ // Try to capture different window states
36
+ // Take a few screenshots with different wait times to capture any dynamic loading
37
+ await page . waitForTimeout ( 2000 ) ;
38
+ await page . screenshot ( {
39
+ path : 'tests/snapshots/app-state-2.png' ,
40
+ fullPage : true
41
+ } ) ;
42
+
43
+ await page . waitForTimeout ( 3000 ) ;
44
+ await page . screenshot ( {
45
+ path : 'tests/snapshots/app-state-3.png' ,
46
+ fullPage : true
47
+ } ) ;
48
+
49
+ expect ( page ) . toBeTruthy ( ) ;
50
+ await electronApp . close ( ) ;
51
+ } ) ;
52
+
53
+ test ( 'should test app dimensions and basic properties' , async ( ) => {
54
+ const electronApp = await launchElectronApp ( ) ;
55
+ const page = await electronApp . firstWindow ( ) ;
56
+
57
+ // Wait for initialization
58
+ await page . waitForTimeout ( 5000 ) ;
59
+
60
+ // Get window properties
61
+ const windowBounds = await electronApp . windows ( ) [ 0 ] . evaluate ( ( ) => {
62
+ return {
63
+ width : window . innerWidth ,
64
+ height : window . innerHeight ,
65
+ title : document . title
66
+ } ;
67
+ } ) ;
68
+
69
+ // Take screenshot with window info
70
+ await page . screenshot ( {
71
+ path : 'tests/snapshots/app-window-properties.png' ,
72
+ fullPage : true
73
+ } ) ;
74
+
75
+ expect ( windowBounds . width ) . toBeGreaterThan ( 0 ) ;
76
+ expect ( windowBounds . height ) . toBeGreaterThan ( 0 ) ;
77
+
78
+ await electronApp . close ( ) ;
79
+ } ) ;
80
+
81
+ test ( 'should capture app in different loading phases' , async ( ) => {
82
+ const electronApp = await launchElectronApp ( ) ;
83
+ const page = await electronApp . firstWindow ( ) ;
84
+
85
+ // Take screenshot immediately after launch
86
+ await page . waitForTimeout ( 1000 ) ;
87
+ await page . screenshot ( {
88
+ path : 'tests/snapshots/app-early-launch.png' ,
89
+ fullPage : true
90
+ } ) ;
91
+
92
+ // Wait a bit more and take another
93
+ await page . waitForTimeout ( 5000 ) ;
94
+ await page . screenshot ( {
95
+ path : 'tests/snapshots/app-mid-launch.png' ,
96
+ fullPage : true
97
+ } ) ;
98
+
99
+ // Final state
100
+ await page . waitForTimeout ( 10000 ) ;
101
+ await page . screenshot ( {
102
+ path : 'tests/snapshots/app-fully-loaded.png' ,
103
+ fullPage : true
104
+ } ) ;
105
+
106
+ expect ( page ) . toBeTruthy ( ) ;
107
+ await electronApp . close ( ) ;
108
+ } ) ;
109
+ } ) ;
0 commit comments