-
Notifications
You must be signed in to change notification settings - Fork 10
/
ui.spec.ts
70 lines (64 loc) · 2.27 KB
/
ui.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { expect, galata, test } from '@jupyterlab/galata';
import path from 'path';
test.use({ autoGoto: false });
test.describe('UI Test', () => {
const fileList = ['test.jGIS', 'buildings.qgz', 'shapefile-test.jGIS'];
test.describe('File operations', () => {
test.beforeAll(async ({ request }) => {
const content = galata.newContentsHelper(request);
await content.deleteDirectory('/testDir');
await content.uploadDirectory(
path.resolve(__dirname, './gis-files'),
'/testDir'
);
});
let errors = 0;
test.beforeEach(async ({ page }) => {
const unrelatedErrors = [
// This error is related to plotly dependency, installed with qgis.
"@jupyter-widgets/base doesn't exist in shared scope default"
];
page.setViewportSize({ width: 1920, height: 1080 });
page.on('console', message => {
if (message.type() === 'error') {
for (let pattern of unrelatedErrors) {
if (message.text().includes(pattern)) {
return;
}
}
console.log('CONSOLE ERROR', message);
errors += 1;
}
});
});
test.afterEach(async ({ page }) => {
errors = 0;
});
for (const file of fileList) {
test(`Should be able to render ${file} without error`, async ({
page
}) => {
await page.goto();
const fullPath = `testDir/${file}`;
await page.notebook.openByPath(fullPath);
await page.notebook.activate(fullPath);
await page.locator('div.jGIS-Spinner').waitFor({ state: 'hidden' });
await page.waitForTimeout(1000);
if (await page.getByRole('button', { name: 'Ok' }).isVisible()) {
await page.getByRole('button', { name: 'Ok' }).click();
}
await page
.getByRole('tablist', { name: 'main sidebar' })
.getByRole('tab', { name: 'JupyterGIS Control Panel' })
.click();
await page
.getByRole('tablist', { name: 'alternate sidebar' })
.getByRole('tab', { name: 'JupyterGIS Control Panel' })
.click();
await page.waitForTimeout(1000);
expect(errors).toBe(0);
await expect(page.locator('.ol-unselectable').first()).toBeAttached();
});
}
});
});