@@ -5,6 +5,7 @@ const SETTINGS_ID = 'jupyterlab-execute-time:settings';
5
5
const NOTEBOOK_ID = '@jupyterlab/notebook-extension:tracker' ;
6
6
7
7
test . describe ( 'Windowed notebook' , ( ) => {
8
+ const fileName = '100_code_cells.ipynb' ;
8
9
test . use ( {
9
10
mockSettings : {
10
11
...galata . DEFAULT_SETTINGS ,
@@ -14,11 +15,21 @@ test.describe('Windowed notebook', () => {
14
15
} ,
15
16
} ,
16
17
} ) ;
17
- test . beforeEach ( openNotebook ( '100_code_cells.ipynb' ) ) ;
18
+ test . beforeEach ( openNotebook ( fileName ) ) ;
18
19
test . afterEach ( cleanup ) ;
19
20
20
- test ( 'Node attaches after scrolling into view' , async ( { page } ) => {
21
+ test ( 'Node attaches after scrolling into view' , async ( { page, tmpPath } ) => {
22
+ // Run all cells; this will scroll us to the end
21
23
await page . notebook . run ( ) ;
24
+ // Select first cell
25
+ await page . notebook . selectCells ( 0 ) ;
26
+ await page . notebook . save ( ) ;
27
+ // Reopen the notebook to unload the widgets attached during execution
28
+ await page . notebook . close ( false ) ;
29
+ await page . notebook . openByPath ( `${ tmpPath } /${ fileName } ` ) ;
30
+ await page . notebook . activate ( fileName ) ;
31
+ // Wait for the notebook state to settle
32
+ await page . waitForTimeout ( 100 ) ;
22
33
// Check that only a fraction of cells have the widget
23
34
expect ( await page . locator ( '.execute-time' ) . count ( ) ) . toBeLessThan ( 50 ) ;
24
35
// Get the 100th cells locator without scrolling
@@ -36,6 +47,7 @@ test.describe('Windowed notebook', () => {
36
47
} ) ;
37
48
38
49
test . describe ( 'Windowed notebook/hover' , ( ) => {
50
+ const fileName = '100_code_cells.ipynb' ;
39
51
// The hover mode is useful for creating windowed notebook tests
40
52
// because in this mode execution does not move the notebook window.
41
53
test . use ( {
@@ -51,7 +63,8 @@ test.describe('Windowed notebook/hover', () => {
51
63
} ,
52
64
} ,
53
65
} ) ;
54
- test . beforeEach ( openNotebook ( '100_code_cells.ipynb' ) ) ;
66
+
67
+ test . beforeEach ( openNotebook ( fileName ) ) ;
55
68
test . afterEach ( cleanup ) ;
56
69
57
70
test ( 'Only one node per cell is attached when scrolling' , async ( {
@@ -69,6 +82,7 @@ test.describe('Windowed notebook/hover', () => {
69
82
} ) ;
70
83
// Count the visible cells
71
84
const visibleCells = await page . locator ( '.jp-CodeCell:visible' ) . count ( ) ;
85
+ expect ( visibleCells ) . toBeGreaterThan ( 0 ) ;
72
86
// Wait until all visible cells have the widget
73
87
await page
74
88
. locator ( `:nth-match(.execute-time, ${ visibleCells } )` )
@@ -88,7 +102,7 @@ test.describe('Windowed notebook/hover', () => {
88
102
// The number of visible widgets should be approximately equal the number of visible cells
89
103
// If multiple nodes were attached, the count would be equal to `3 * visibleCells`.
90
104
expect ( await page . locator ( `.execute-time` ) . count ( ) ) . toBeLessThanOrEqual (
91
- visibleCells + 2
105
+ visibleCells + 5
92
106
) ;
93
107
} ) ;
94
108
} ) ;
0 commit comments