Skip to content

Commit 4c1d090

Browse files
committed
Update tests
1 parent 848be13 commit 4c1d090

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

ui-tests/jupyter_server_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
c.ServerApp.port = 8888
44
c.ServerApp.open_browser = False
5-
# c.ServerApp.root_dir = mkdtemp(prefix='galata-test-')
5+
c.ServerApp.root_dir = mkdtemp(prefix='galata-test-')
66
c.ServerApp.token = ""
77
c.ServerApp.password = ""
88
c.ServerApp.disable_check_xsrf = True

ui-tests/tests/widgets.test.ts

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,59 @@
11
// Copyright (c) Jupyter Development Team.
22
// Distributed under the terms of the Modified BSD License.
33

4-
import { test } from '@jupyterlab/galata';
4+
import { galata, test } from '@jupyterlab/galata';
55

66
import { expect } from '@playwright/test';
77

88
import * as path from 'path';
99

1010
test.describe('Widget Visual Regression', () => {
11-
test.beforeEach(async ({ page, tmpPath }) => {
12-
await page.contents.uploadDirectory(
11+
test.beforeAll(async ({ baseURL, tmpPath }) => {
12+
const contents = galata.newContentsHelper(baseURL);
13+
await contents.uploadDirectory(
1314
path.resolve(__dirname, './notebooks'),
1415
tmpPath
1516
);
16-
await page.dblclick(`text=${tmpPath}`);
17+
});
18+
19+
test.beforeEach(async ({ page, tmpPath }) => {
20+
await page.filebrowser.openDirectory(tmpPath);
21+
});
22+
23+
test.afterAll(async ({ baseURL, tmpPath }) => {
24+
const contents = galata.newContentsHelper(baseURL);
25+
await contents.deleteDirectory(tmpPath);
1726
});
1827

1928
test('Run notebook widgets.ipynb and capture cell outputs', async ({
2029
page,
30+
tmpPath,
2131
}) => {
2232
const notebook = 'widgets.ipynb';
23-
await page.notebook.open(notebook);
24-
expect(await page.notebook.isOpen(notebook)).toBeTruthy();
33+
await page.notebook.openByPath(`${tmpPath}/${notebook}`);
2534
await page.notebook.activate(notebook);
26-
expect(await page.notebook.isActive(notebook)).toBeTruthy();
27-
28-
let numCellImages = 0;
2935

3036
const getCaptureImageName = (id: number): string => {
31-
return `cell-${id}`;
37+
return `cell-${id}.png`;
3238
};
3339

40+
const captures = new Array<Buffer>();
41+
let numCellImages = 0;
42+
3443
await page.notebook.runCellByCell({
3544
onAfterCellRun: async (cellIndex: number) => {
3645
const cell = await page.notebook.getCellOutput(cellIndex);
3746
if (cell) {
38-
expect(cell.screenshot()).toMatchSnapshot(
39-
getCaptureImageName(numCellImages)
40-
);
41-
{
42-
numCellImages++;
43-
}
47+
captures.push(await cell.screenshot());
48+
numCellImages++;
4449
}
4550
},
4651
});
52+
53+
await page.notebook.save();
54+
55+
for (let c = 0; c < numCellImages; ++c) {
56+
expect(captures[c]).toMatchSnapshot(getCaptureImageName(c));
57+
}
4758
});
4859
});

0 commit comments

Comments
 (0)