Skip to content

Commit

Permalink
Add test for running in place
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Jan 26, 2024
1 parent 7ffb628 commit 771413f
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
32 changes: 32 additions & 0 deletions galata/test/jupyterlab/notebook-scroll-no-windowing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,38 @@ test.describe('Notebook scroll on execution (no windowing)', () => {
// After running the second cell, the third cell should not be scrolled
await expect(thirdCellLocator).not.toBeInViewport({ ratio: 0.2 });
});

test('should not scroll when running in-place', async ({ page }) => {
const notebook = await page.notebook.getNotebookInPanel();
const thirdCell = await page.notebook.getCell(2);

const scroller = (await notebook.$(
'.jp-WindowedPanel-outer'
)) as ElementHandle<HTMLElement>;
const notebookBbox = await scroller.boundingBox();
const thirdCellBBox = await thirdCell.boundingBox();
await page.mouse.move(notebookBbox.x, notebookBbox.y);
const scrollOffset =
thirdCellBBox.y -
notebookBbox.y -
notebookBbox.height +
thirdCellBBox.height * 0.15;
await Promise.all([page.mouse.wheel(0, scrollOffset)]);
// Select third cell
await page.notebook.enterCellEditingMode(2);

const thirdCellLocator = page.locator(
'.jp-Cell[data-windowed-list-index="2"]'
);
// The third cell should be positioned at the bottom, revealing between 10 to 20% of its content.
await expect(thirdCellLocator).toBeInViewport({ ratio: 0.1 });
await expect(thirdCellLocator).not.toBeInViewport({ ratio: 0.2 });

// Run third cell in-place
await page.notebook.runCell(2, true);
// After running the third cell it should not be scrolled
await expect(thirdCellLocator).not.toBeInViewport({ ratio: 0.2 });

Check failure on line 173 in galata/test/jupyterlab/notebook-scroll-no-windowing.test.ts

View workflow job for this annotation

GitHub Actions / Visual Regression Tests

[jupyterlab] › test/jupyterlab/notebook-scroll-no-windowing.test.ts:144:7 › Notebook scroll on execution (no windowing) › should not scroll when running in-place

2) [jupyterlab] › test/jupyterlab/notebook-scroll-no-windowing.test.ts:144:7 › Notebook scroll on execution (no windowing) › should not scroll when running in-place Error: expect(received).not.toBeInViewport() Call log: - expect.not.toBeInViewport with timeout 5000ms - waiting for locator('.jp-Cell[data-windowed-list-index="2"]') - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - waiting for locator('.jp-Cell[data-windowed-list-index="2"]') - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" 171 | await page.notebook.runCell(2, true); 172 | // After running the third cell it should not be scrolled > 173 | await expect(thirdCellLocator).not.toBeInViewport({ ratio: 0.2 }); | ^ 174 | }); 175 | }); 176 | at /home/runner/work/jupyterlab/jupyterlab/galata/test/jupyterlab/notebook-scroll-no-windowing.test.ts:173:40

Check failure on line 173 in galata/test/jupyterlab/notebook-scroll-no-windowing.test.ts

View workflow job for this annotation

GitHub Actions / Visual Regression Tests

[jupyterlab] › test/jupyterlab/notebook-scroll-no-windowing.test.ts:144:7 › Notebook scroll on execution (no windowing) › should not scroll when running in-place

2) [jupyterlab] › test/jupyterlab/notebook-scroll-no-windowing.test.ts:144:7 › Notebook scroll on execution (no windowing) › should not scroll when running in-place Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).not.toBeInViewport() Call log: - expect.not.toBeInViewport with timeout 5000ms - waiting for locator('.jp-Cell[data-windowed-list-index="2"]') - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - waiting for locator('.jp-Cell[data-windowed-list-index="2"]') - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" - locator resolved to <div tabindex="0" data-windowed-list-index="2" aria-l…>…</div> - unexpected value "viewport ratio 0.36869266629219055" 171 | await page.notebook.runCell(2, true); 172 | // After running the third cell it should not be scrolled > 173 | await expect(thirdCellLocator).not.toBeInViewport({ ratio: 0.2 }); | ^ 174 | }); 175 | }); 176 | at /home/runner/work/jupyterlab/jupyterlab/galata/test/jupyterlab/notebook-scroll-no-windowing.test.ts:173:40
});
});

test.describe('Notebook scroll over long outputs (no windowing)', () => {
Expand Down
32 changes: 32 additions & 0 deletions galata/test/jupyterlab/notebook-scroll.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,38 @@ test.describe('Windowed notebook scroll on execution', () => {
// After running the second cell, the third cell should not be scrolled
await expect(thirdCellLocator).not.toBeInViewport({ ratio: 0.2 });
});

test('should not scroll when running in-place', async ({ page }) => {
const notebook = await page.notebook.getNotebookInPanel();
const thirdCell = await page.notebook.getCell(2);

const scroller = (await notebook.$(
'.jp-WindowedPanel-outer'
)) as ElementHandle<HTMLElement>;
const notebookBbox = await scroller.boundingBox();
const thirdCellBBox = await thirdCell.boundingBox();
await page.mouse.move(notebookBbox.x, notebookBbox.y);
const scrollOffset =
thirdCellBBox.y -
notebookBbox.y -
notebookBbox.height +
thirdCellBBox.height * 0.15;
await Promise.all([page.mouse.wheel(0, scrollOffset)]);
// Select third cell
await page.notebook.enterCellEditingMode(2);

const thirdCellLocator = page.locator(
'.jp-Cell[data-windowed-list-index="2"]'
);
// The third cell should be positioned at the bottom, revealing between 10 to 20% of its content.
await expect(thirdCellLocator).toBeInViewport({ ratio: 0.1 });
await expect(thirdCellLocator).not.toBeInViewport({ ratio: 0.2 });

// Run third cell in-place
await page.notebook.runCell(2, true);
// After running the third cell it should not be scrolled
await expect(thirdCellLocator).not.toBeInViewport({ ratio: 0.2 });
});
});

test.describe('Windowed notebook scroll over long outputs', () => {
Expand Down

0 comments on commit 771413f

Please sign in to comment.