Skip to content

Commit

Permalink
Separate file for lite tests?
Browse files Browse the repository at this point in the history
  • Loading branch information
arjxn-py committed Feb 18, 2025
1 parent 0bcc28e commit 918d3e7
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 37 deletions.
55 changes: 55 additions & 0 deletions ui-tests/tests/lite.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { expect, test, galata } from '@jupyterlab/galata';
import path from 'path';

test.use({ autoGoto: false });

test.describe('UI Test', () => {
const fileList = ['test.jcad', '3M_CONNECTOR.STEP', 'fan.stl'];
let errors = 0;
test.beforeEach(async ({ page }) => {
page.setViewportSize({ width: 1920, height: 1080 });
page.on('console', message => {
if (message.type() === 'error') {
console.log('ERROR MSG', message.text());
errors += 1;
}
});
});

test.afterEach(async ({ page }) => {
errors = 0;
});

for (const file of fileList) {
test(`Should be able to render ${file} without error`, async ({ browser }) => {
const context = await browser.newContext();
const page = await context.newPage();

await page.goto(`lab/index.html?path=${file}`, {waitUntil: 'domcontentloaded'});
console.log('FILE LOADED');

await page.locator('div.jpcad-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.sidebar.close('left');
// await page.sidebar.close('right');
await page.waitForTimeout(1000);

const main = await page.waitForSelector('#jp-main-split-panel', { state: 'visible', timeout: 10000 });

console.log('hurrayyyy',main);

expect(errors).toBe(0);
if (main) {
expect(await main.screenshot()).toMatchSnapshot({

Check failure on line 48 in ui-tests/tests/lite.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests

tests/lite.spec.ts:24:9 › UI Test › Should be able to render test.jcad without error

1) tests/lite.spec.ts:24:9 › UI Test › Should be able to render test.jcad without error ────────── Error: A snapshot doesn't exist at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/tests/lite.spec.ts-snapshots/Render-test-jcad-linux.png, writing actual. 46 | expect(errors).toBe(0); 47 | if (main) { > 48 | expect(await main.screenshot()).toMatchSnapshot({ | ^ 49 | name: `Render-${file}.png`, 50 | maxDiffPixelRatio: 0.01 51 | }); at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/tests/lite.spec.ts:48:41

Check failure on line 48 in ui-tests/tests/lite.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests

tests/lite.spec.ts:24:9 › UI Test › Should be able to render 3M_CONNECTOR.STEP without error

2) tests/lite.spec.ts:24:9 › UI Test › Should be able to render 3M_CONNECTOR.STEP without error ── Error: A snapshot doesn't exist at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/tests/lite.spec.ts-snapshots/Render-3M-CONNECTOR-STEP-linux.png, writing actual. 46 | expect(errors).toBe(0); 47 | if (main) { > 48 | expect(await main.screenshot()).toMatchSnapshot({ | ^ 49 | name: `Render-${file}.png`, 50 | maxDiffPixelRatio: 0.01 51 | }); at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/tests/lite.spec.ts:48:41

Check failure on line 48 in ui-tests/tests/lite.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests

tests/lite.spec.ts:24:9 › UI Test › Should be able to render fan.stl without error

3) tests/lite.spec.ts:24:9 › UI Test › Should be able to render fan.stl without error ──────────── Error: A snapshot doesn't exist at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/tests/lite.spec.ts-snapshots/Render-fan-stl-linux.png, writing actual. 46 | expect(errors).toBe(0); 47 | if (main) { > 48 | expect(await main.screenshot()).toMatchSnapshot({ | ^ 49 | name: `Render-${file}.png`, 50 | maxDiffPixelRatio: 0.01 51 | }); at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/tests/lite.spec.ts:48:41

Check failure on line 48 in ui-tests/tests/lite.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests Lite

tests/lite.spec.ts:24:9 › UI Test › Should be able to render test.jcad without error

1) tests/lite.spec.ts:24:9 › UI Test › Should be able to render test.jcad without error ────────── Error: A snapshot doesn't exist at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/tests/lite.spec.ts-snapshots/Render-test-jcad-linux.png, writing actual. 46 | expect(errors).toBe(0); 47 | if (main) { > 48 | expect(await main.screenshot()).toMatchSnapshot({ | ^ 49 | name: `Render-${file}.png`, 50 | maxDiffPixelRatio: 0.01 51 | }); at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/tests/lite.spec.ts:48:41

Check failure on line 48 in ui-tests/tests/lite.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests Lite

tests/lite.spec.ts:24:9 › UI Test › Should be able to render 3M_CONNECTOR.STEP without error

2) tests/lite.spec.ts:24:9 › UI Test › Should be able to render 3M_CONNECTOR.STEP without error ── Error: A snapshot doesn't exist at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/tests/lite.spec.ts-snapshots/Render-3M-CONNECTOR-STEP-linux.png, writing actual. 46 | expect(errors).toBe(0); 47 | if (main) { > 48 | expect(await main.screenshot()).toMatchSnapshot({ | ^ 49 | name: `Render-${file}.png`, 50 | maxDiffPixelRatio: 0.01 51 | }); at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/tests/lite.spec.ts:48:41

Check failure on line 48 in ui-tests/tests/lite.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests Lite

tests/lite.spec.ts:24:9 › UI Test › Should be able to render fan.stl without error

3) tests/lite.spec.ts:24:9 › UI Test › Should be able to render fan.stl without error ──────────── Error: A snapshot doesn't exist at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/tests/lite.spec.ts-snapshots/Render-fan-stl-linux.png, writing actual. 46 | expect(errors).toBe(0); 47 | if (main) { > 48 | expect(await main.screenshot()).toMatchSnapshot({ | ^ 49 | name: `Render-${file}.png`, 50 | maxDiffPixelRatio: 0.01 51 | }); at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/tests/lite.spec.ts:48:41
name: `Render-${file}.png`,
maxDiffPixelRatio: 0.01
});
}
});
}
});
72 changes: 35 additions & 37 deletions ui-tests/tests/ui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,36 @@ test.use({ autoGoto: false });
test.describe('UI Test', () => {
const fileList = ['test.jcad', '3M_CONNECTOR.STEP', 'fan.stl'];

// test.describe('Extension activation test', () => {
// test('should emit an activation console message', async ({
// page
// }) => {
// const logs: string[] = [];
test.describe('Extension activation test', () => {
test('should emit an activation console message', async ({
page
}) => {
const logs: string[] = [];

// page.on('console', message => {
// console.log('CONSOLE MSG:', message.text());
// logs.push(message.text());
// console.log(`Total logs captured: ${logs.length}`);
// });
page.on('console', message => {
console.log('CONSOLE MSG:', message.text());
logs.push(message.text());
console.log(`Total logs captured: ${logs.length}`);
});

console.log('pagey', page);

// await page.goto();
await page.goto('?path=pad.jcad');

// expect(logs.filter(s => s === 'Initializing OCC...')).toHaveLength(1);
// expect(logs.filter(s => s === 'Done!')).toHaveLength(1);
// });
// });
expect(logs.filter(s => s === 'Initializing OCC...')).toHaveLength(1);
expect(logs.filter(s => s === 'Done!')).toHaveLength(1);
});
});

test.describe('File operations', () => {
// test.beforeAll(async ({ request }) => {
// const content = galata.newContentsHelper(request);
// await content.deleteDirectory('/examples');
// await content.uploadDirectory(
// path.resolve(__dirname, '../../examples'),
// '/examples'
// );
// });
test.beforeAll(async ({ request }) => {
const content = galata.newContentsHelper(request);
await content.deleteDirectory('/examples');
await content.uploadDirectory(
path.resolve(__dirname, '../../examples'),
'/examples'
);
});
let errors = 0;
test.beforeEach(async ({ page }) => {
page.setViewportSize({ width: 1920, height: 1080 });
Expand All @@ -50,28 +52,24 @@ test.describe('UI Test', () => {
});

for (const file of fileList) {
test(`Should be able to render ${file} without error`, async ({ browser }) => {
const context = await browser.newContext();
const page = await context.newPage();

await page.goto(`lab/index.html?path=${file}`, {waitUntil: 'domcontentloaded'});
console.log('FILE LOADED');

test(`Should be able to render ${file} without error`, async ({
page
}) => {
await page.goto();

Check failure on line 58 in ui-tests/tests/ui.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests Lite

tests/ui.spec.ts:55:11 › UI Test › File operations › Should be able to render test.jcad without error

5) tests/ui.spec.ts:55:11 › UI Test › File operations › Should be able to render test.jcad without error Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: page.evaluate: Execution context was destroyed, most likely because of a navigation 56 | page 57 | }) => { > 58 | await page.goto(); | ^ 59 | const fullPath = `examples/${file}`; 60 | await page.notebook.openByPath(fullPath); 61 | await page.notebook.activate(fullPath); at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/node_modules/@jupyterlab/galata/src/jupyterlabpage.ts:717:17 at check (/home/runner/work/JupyterCAD/JupyterCAD/ui-tests/node_modules/@jupyterlab/galata/src/utils.ts:183:33) at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/node_modules/@jupyterlab/galata/src/utils.ts:193:10 at Object.waitForCondition (/home/runner/work/JupyterCAD/JupyterCAD/ui-tests/node_modules/@jupyterlab/galata/src/utils.ts:178:10) at JupyterLabPage.waitForCondition (/home/runner/work/JupyterCAD/JupyterCAD/ui-tests/node_modules/@jupyterlab/galata/src/jupyterlabpage.ts:636:18) at Proxy.JupyterLabPage.waitForAppStarted (/home/runner/work/JupyterCAD/JupyterCAD/ui-tests/node_modules/@jupyterlab/galata/src/jupyterlabpage.ts:716:17) at Proxy.goto (/home/runner/work/JupyterCAD/JupyterCAD/ui-tests/node_modules/@jupyterlab/galata/src/jupyterlabpage.ts:500:16) at /home/runner/work/JupyterCAD/JupyterCAD/ui-tests/tests/ui.spec.ts:58:9
const fullPath = `examples/${file}`;
await page.notebook.openByPath(fullPath);
await page.notebook.activate(fullPath);
await page.locator('div.jpcad-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.sidebar.close('left');
// await page.sidebar.close('right');
await page.sidebar.close('left');
await page.sidebar.close('right');
await page.waitForTimeout(1000);

const main = await page.waitForSelector('#jp-main-split-panel', { state: 'visible', timeout: 10000 });

console.log('hurrayyyy',main);

const main = await page.$('#jp-main-split-panel');
expect(errors).toBe(0);
if (main) {
expect(await main.screenshot()).toMatchSnapshot({
Expand Down

0 comments on commit 918d3e7

Please sign in to comment.