Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix windowed notebook tests to work with JupyterLab 4.2 #125

Merged
merged 7 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ui-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test:update": "jlpm playwright test --update-snapshots"
},
"devDependencies": {
"@jupyterlab/galata": "^5.1.0-rc.1",
"@playwright/test": "^1.32.2"
"@jupyterlab/galata": "^5.2.0",
"@playwright/test": "^1.44.0"
}
}
22 changes: 18 additions & 4 deletions ui-tests/tests/windowed_notebook.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const SETTINGS_ID = 'jupyterlab-execute-time:settings';
const NOTEBOOK_ID = '@jupyterlab/notebook-extension:tracker';

test.describe('Windowed notebook', () => {
const fileName = '100_code_cells.ipynb';
test.use({
mockSettings: {
...galata.DEFAULT_SETTINGS,
Expand All @@ -14,11 +15,21 @@ test.describe('Windowed notebook', () => {
},
},
});
test.beforeEach(openNotebook('100_code_cells.ipynb'));
test.beforeEach(openNotebook(fileName));
test.afterEach(cleanup);

test('Node attaches after scrolling into view', async ({ page }) => {
test('Node attaches after scrolling into view', async ({ page, tmpPath }) => {
// Run all cells; this will scroll us to the end
await page.notebook.run();
// Select first cell
await page.notebook.selectCells(0);
await page.notebook.save();
// Reopen the notebook to unload the widgets attached during execution
await page.notebook.close(false);
await page.notebook.openByPath(`${tmpPath}/${fileName}`);
await page.notebook.activate(fileName);
// Wait for the notebook state to settle
await page.waitForTimeout(100);
// Check that only a fraction of cells have the widget
expect(await page.locator('.execute-time').count()).toBeLessThan(50);
// Get the 100th cells locator without scrolling
Expand All @@ -36,6 +47,7 @@ test.describe('Windowed notebook', () => {
});

test.describe('Windowed notebook/hover', () => {
const fileName = '100_code_cells.ipynb';
// The hover mode is useful for creating windowed notebook tests
// because in this mode execution does not move the notebook window.
test.use({
Expand All @@ -51,7 +63,8 @@ test.describe('Windowed notebook/hover', () => {
},
},
});
test.beforeEach(openNotebook('100_code_cells.ipynb'));

test.beforeEach(openNotebook(fileName));
test.afterEach(cleanup);

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