Skip to content

Commit d2edb0f

Browse files
authored
Fix windowed notebook tests to work with JupyterLab 4.2 (#125)
1 parent e987b16 commit d2edb0f

File tree

3 files changed

+666
-536
lines changed

3 files changed

+666
-536
lines changed

ui-tests/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"test:update": "jlpm playwright test --update-snapshots"
1010
},
1111
"devDependencies": {
12-
"@jupyterlab/galata": "^5.1.0-rc.1",
13-
"@playwright/test": "^1.32.2"
12+
"@jupyterlab/galata": "^5.2.0",
13+
"@playwright/test": "^1.44.0"
1414
}
1515
}

ui-tests/tests/windowed_notebook.spec.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const SETTINGS_ID = 'jupyterlab-execute-time:settings';
55
const NOTEBOOK_ID = '@jupyterlab/notebook-extension:tracker';
66

77
test.describe('Windowed notebook', () => {
8+
const fileName = '100_code_cells.ipynb';
89
test.use({
910
mockSettings: {
1011
...galata.DEFAULT_SETTINGS,
@@ -14,11 +15,21 @@ test.describe('Windowed notebook', () => {
1415
},
1516
},
1617
});
17-
test.beforeEach(openNotebook('100_code_cells.ipynb'));
18+
test.beforeEach(openNotebook(fileName));
1819
test.afterEach(cleanup);
1920

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
2123
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);
2233
// Check that only a fraction of cells have the widget
2334
expect(await page.locator('.execute-time').count()).toBeLessThan(50);
2435
// Get the 100th cells locator without scrolling
@@ -36,6 +47,7 @@ test.describe('Windowed notebook', () => {
3647
});
3748

3849
test.describe('Windowed notebook/hover', () => {
50+
const fileName = '100_code_cells.ipynb';
3951
// The hover mode is useful for creating windowed notebook tests
4052
// because in this mode execution does not move the notebook window.
4153
test.use({
@@ -51,7 +63,8 @@ test.describe('Windowed notebook/hover', () => {
5163
},
5264
},
5365
});
54-
test.beforeEach(openNotebook('100_code_cells.ipynb'));
66+
67+
test.beforeEach(openNotebook(fileName));
5568
test.afterEach(cleanup);
5669

5770
test('Only one node per cell is attached when scrolling', async ({
@@ -69,6 +82,7 @@ test.describe('Windowed notebook/hover', () => {
6982
});
7083
// Count the visible cells
7184
const visibleCells = await page.locator('.jp-CodeCell:visible').count();
85+
expect(visibleCells).toBeGreaterThan(0);
7286
// Wait until all visible cells have the widget
7387
await page
7488
.locator(`:nth-match(.execute-time, ${visibleCells})`)
@@ -88,7 +102,7 @@ test.describe('Windowed notebook/hover', () => {
88102
// The number of visible widgets should be approximately equal the number of visible cells
89103
// If multiple nodes were attached, the count would be equal to `3 * visibleCells`.
90104
expect(await page.locator(`.execute-time`).count()).toBeLessThanOrEqual(
91-
visibleCells + 2
105+
visibleCells + 5
92106
);
93107
});
94108
});

0 commit comments

Comments
 (0)