-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from jupytercad/ui-test
Add UI tests
- Loading branch information
Showing
11 changed files
with
4,482 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,3 +120,6 @@ dmypy.json | |
# Yarn cache | ||
.yarn/ | ||
.jupyter_ystore.db | ||
|
||
**/ui-tests/test-results/ | ||
**/ui-tests/playwright-report/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from jupyterlab.galata import configure_jupyter_server | ||
|
||
configure_jupyter_server(c) # noqa F821 | ||
c.LabApp.collaborative = True # noqa F821 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "jupytercad-openvsp-ui-tests", | ||
"version": "1.0.0", | ||
"description": "jupytercad-openvsp Integration Tests", | ||
"private": true, | ||
"scripts": { | ||
"start": "jupyter lab --config jupyter_server_test_config.py", | ||
"test": "npx playwright test", | ||
"test:update": "npx playwright test --update-snapshots", | ||
"test:debug": "PWDEBUG=1 npx playwright test" | ||
}, | ||
"devDependencies": { | ||
"@jupyterlab/galata": "^5.1.0", | ||
"@playwright/test": "^1.32.0", | ||
"@types/klaw-sync": "^6.0.1" | ||
}, | ||
"dependencies": { | ||
"klaw-sync": "^6.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Configuration for Playwright using default from @jupyterlab/galata | ||
*/ | ||
const baseConfig = require('@jupyterlab/galata/lib/playwright-config'); | ||
|
||
module.exports = { | ||
...baseConfig, | ||
webServer: { | ||
command: 'jlpm start', | ||
url: 'http://localhost:8888/lab', | ||
timeout: 120 * 1000, | ||
reuseExistingServer: false | ||
}, | ||
retries: 0, | ||
use: { | ||
...baseConfig.use, | ||
trace: 'off' | ||
}, | ||
expect: { | ||
toMatchSnapshot: { | ||
maxDiffPixelRatio: 0.02 | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { expect, test, galata } from '@jupyterlab/galata'; | ||
import path from 'path'; | ||
|
||
test.use({ autoGoto: false }); | ||
|
||
test.describe('UI Test', () => { | ||
const fileList = ['A320.vsp3']; | ||
|
||
test.describe('Extension activation test', () => { | ||
test('should emit an activation console message', async ({ | ||
page, | ||
request | ||
}) => { | ||
const logs: string[] = []; | ||
|
||
page.on('console', message => { | ||
logs.push(message.text()); | ||
}); | ||
|
||
await page.goto(); | ||
|
||
expect( | ||
logs.filter(s => s === 'jupytercad_openvsp:plugin is activated!') | ||
).toHaveLength(1); | ||
}); | ||
}); | ||
|
||
test.describe('File rendering test', () => { | ||
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 }); | ||
page.on('console', message => { | ||
if (message.type() === 'error') { | ||
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 = `examples/${file}`; | ||
await page.notebook.openByPath(fullPath); | ||
await page.notebook.activate(fullPath); | ||
await page.locator('div.jpcad-Spinner').waitFor({ state: 'hidden' }); | ||
|
||
await page | ||
.getByRole('tablist', { name: 'main sidebar' }) | ||
.getByRole('tab', { name: 'JupyterCad Control Panel' }) | ||
.click(); | ||
await page | ||
.getByRole('tablist', { name: 'alternate sidebar' }) | ||
.getByRole('tab', { name: 'JupyterCad Control Panel' }) | ||
.click(); | ||
await page.waitForTimeout(1000); | ||
const main = await page.$('#jp-main-split-panel'); | ||
expect(errors).toBe(0); | ||
if (main) { | ||
expect(await main.screenshot()).toMatchSnapshot({ | ||
name: `Render-${file}.png`, | ||
maxDiffPixelRatio: 0.01 | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.