Skip to content

Commit 918d3e7

Browse files
committed
Separate file for lite tests?
1 parent 0bcc28e commit 918d3e7

File tree

2 files changed

+90
-37
lines changed

2 files changed

+90
-37
lines changed

ui-tests/tests/lite.spec.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { expect, test, galata } from '@jupyterlab/galata';
2+
import path from 'path';
3+
4+
test.use({ autoGoto: false });
5+
6+
test.describe('UI Test', () => {
7+
const fileList = ['test.jcad', '3M_CONNECTOR.STEP', 'fan.stl'];
8+
let errors = 0;
9+
test.beforeEach(async ({ page }) => {
10+
page.setViewportSize({ width: 1920, height: 1080 });
11+
page.on('console', message => {
12+
if (message.type() === 'error') {
13+
console.log('ERROR MSG', message.text());
14+
errors += 1;
15+
}
16+
});
17+
});
18+
19+
test.afterEach(async ({ page }) => {
20+
errors = 0;
21+
});
22+
23+
for (const file of fileList) {
24+
test(`Should be able to render ${file} without error`, async ({ browser }) => {
25+
const context = await browser.newContext();
26+
const page = await context.newPage();
27+
28+
await page.goto(`lab/index.html?path=${file}`, {waitUntil: 'domcontentloaded'});
29+
console.log('FILE LOADED');
30+
31+
await page.locator('div.jpcad-Spinner').waitFor({ state: 'hidden' });
32+
await page.waitForTimeout(1000);
33+
34+
if (await page.getByRole('button', { name: 'Ok' }).isVisible()) {
35+
await page.getByRole('button', { name: 'Ok' }).click();
36+
}
37+
38+
// await page.sidebar.close('left');
39+
// await page.sidebar.close('right');
40+
await page.waitForTimeout(1000);
41+
42+
const main = await page.waitForSelector('#jp-main-split-panel', { state: 'visible', timeout: 10000 });
43+
44+
console.log('hurrayyyy',main);
45+
46+
expect(errors).toBe(0);
47+
if (main) {
48+
expect(await main.screenshot()).toMatchSnapshot({
49+
name: `Render-${file}.png`,
50+
maxDiffPixelRatio: 0.01
51+
});
52+
}
53+
});
54+
}
55+
});

ui-tests/tests/ui.spec.ts

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,36 @@ test.use({ autoGoto: false });
66
test.describe('UI Test', () => {
77
const fileList = ['test.jcad', '3M_CONNECTOR.STEP', 'fan.stl'];
88

9-
// test.describe('Extension activation test', () => {
10-
// test('should emit an activation console message', async ({
11-
// page
12-
// }) => {
13-
// const logs: string[] = [];
9+
test.describe('Extension activation test', () => {
10+
test('should emit an activation console message', async ({
11+
page
12+
}) => {
13+
const logs: string[] = [];
1414

15-
// page.on('console', message => {
16-
// console.log('CONSOLE MSG:', message.text());
17-
// logs.push(message.text());
18-
// console.log(`Total logs captured: ${logs.length}`);
19-
// });
15+
page.on('console', message => {
16+
console.log('CONSOLE MSG:', message.text());
17+
logs.push(message.text());
18+
console.log(`Total logs captured: ${logs.length}`);
19+
});
20+
21+
console.log('pagey', page);
2022

21-
// await page.goto();
23+
await page.goto('?path=pad.jcad');
2224

23-
// expect(logs.filter(s => s === 'Initializing OCC...')).toHaveLength(1);
24-
// expect(logs.filter(s => s === 'Done!')).toHaveLength(1);
25-
// });
26-
// });
25+
expect(logs.filter(s => s === 'Initializing OCC...')).toHaveLength(1);
26+
expect(logs.filter(s => s === 'Done!')).toHaveLength(1);
27+
});
28+
});
2729

2830
test.describe('File operations', () => {
29-
// test.beforeAll(async ({ request }) => {
30-
// const content = galata.newContentsHelper(request);
31-
// await content.deleteDirectory('/examples');
32-
// await content.uploadDirectory(
33-
// path.resolve(__dirname, '../../examples'),
34-
// '/examples'
35-
// );
36-
// });
31+
test.beforeAll(async ({ request }) => {
32+
const content = galata.newContentsHelper(request);
33+
await content.deleteDirectory('/examples');
34+
await content.uploadDirectory(
35+
path.resolve(__dirname, '../../examples'),
36+
'/examples'
37+
);
38+
});
3739
let errors = 0;
3840
test.beforeEach(async ({ page }) => {
3941
page.setViewportSize({ width: 1920, height: 1080 });
@@ -50,28 +52,24 @@ test.describe('UI Test', () => {
5052
});
5153

5254
for (const file of fileList) {
53-
test(`Should be able to render ${file} without error`, async ({ browser }) => {
54-
const context = await browser.newContext();
55-
const page = await context.newPage();
56-
57-
await page.goto(`lab/index.html?path=${file}`, {waitUntil: 'domcontentloaded'});
58-
console.log('FILE LOADED');
59-
55+
test(`Should be able to render ${file} without error`, async ({
56+
page
57+
}) => {
58+
await page.goto();
59+
const fullPath = `examples/${file}`;
60+
await page.notebook.openByPath(fullPath);
61+
await page.notebook.activate(fullPath);
6062
await page.locator('div.jpcad-Spinner').waitFor({ state: 'hidden' });
6163
await page.waitForTimeout(1000);
6264

6365
if (await page.getByRole('button', { name: 'Ok' }).isVisible()) {
6466
await page.getByRole('button', { name: 'Ok' }).click();
6567
}
6668

67-
// await page.sidebar.close('left');
68-
// await page.sidebar.close('right');
69+
await page.sidebar.close('left');
70+
await page.sidebar.close('right');
6971
await page.waitForTimeout(1000);
70-
71-
const main = await page.waitForSelector('#jp-main-split-panel', { state: 'visible', timeout: 10000 });
72-
73-
console.log('hurrayyyy',main);
74-
72+
const main = await page.$('#jp-main-split-panel');
7573
expect(errors).toBe(0);
7674
if (main) {
7775
expect(await main.screenshot()).toMatchSnapshot({

0 commit comments

Comments
 (0)