Skip to content

Commit

Permalink
Update jupytercad (#3)
Browse files Browse the repository at this point in the history
* Add fc examples

* Add ui tests

* Add CI script
  • Loading branch information
trungleduc authored Jan 2, 2024
1 parent 1c49288 commit 1997672
Show file tree
Hide file tree
Showing 35 changed files with 4,814 additions and 48 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,73 @@ jobs:
jupyter labextension list 2>&1 | grep -ie "@jupytercad/jupytercad-freecad.*OK"
python -m jupyterlab.browser_check --no-browser-test
integration-tests:
name: Integration tests
needs: build
runs-on: ubuntu-latest

env:
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/pw-browsers

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: '1.5.5-0'
environment-name: cad
create-args: >-
python=3.10
jupyterlab=4
freecad=0.21.2
- name: Download extension package
uses: actions/download-artifact@v3
with:
name: extension-artifacts

- name: Install the extension
shell: bash -l {0}
run: |
set -eux
pip install "jupyterlab>=4.0.0,<5" "jupytercad>=1.0.0a3" jupytercad_freecad*.whl
- name: Install dependencies
shell: bash -l {0}
working-directory: ui-tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: jlpm install

- name: Set up browser cache
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/pw-browsers
key: ${{ runner.os }}-${{ hashFiles('ui-tests/yarn.lock') }}

- name: Install browser
shell: bash -l {0}
run: npx playwright install chromium
working-directory: ui-tests

- name: Execute integration tests
shell: bash -l {0}
working-directory: ui-tests
run: |
npx playwright test
- name: Upload Playwright Test report
if: always()
uses: actions/upload-artifact@v3
with:
name: jupytercad-playwright-tests
path: |
ui-tests/test-results
ui-tests/playwright-report
check_links:
name: Check Links
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,7 @@ dmypy.json

# Yarn cache
.yarn/

**/ui-tests/test-results/
**/ui-tests/playwright-report/
**/*/.jupyter_ystore.db
Binary file added examples/ArchDetail.FCStd
Binary file not shown.
Binary file added examples/common.FCStd
Binary file not shown.
Binary file added examples/cut.FCStd
Binary file not shown.
Binary file added examples/example1.FCStd
Binary file not shown.
Binary file added examples/example2.FCStd
Binary file not shown.
Binary file added examples/example3.FCStd
Binary file not shown.
Binary file added examples/example4.FCStd
Binary file not shown.
Binary file added examples/example5.FCStd
Binary file not shown.
Binary file added examples/example6.FCStd
Binary file not shown.
Binary file added examples/example_2D.FCStd
Binary file not shown.
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
"dependencies": {
"@jupyter/collaboration": "^1.0.0",
"@jupyter/docprovider": "^1.0.0",
"@jupytercad/base": "^1.0.0-alpha.1",
"@jupytercad/jupytercad-core": "^1.0.0-alpha.1",
"@jupytercad/schema": "^1.0.0-alpha.1",
"@jupytercad/base": "^1.0.0-alpha.3",
"@jupytercad/jupytercad-core": "^1.0.0-alpha.3",
"@jupytercad/schema": "^1.0.0-alpha.3",
"@jupyterlab/application": "^4.0.0"
},
"devDependencies": {
Expand Down Expand Up @@ -122,6 +122,8 @@
"node_modules",
"dist",
"coverage",
"ui-tests",
"**/build/",
"**/*.d.ts"
],
"eslintConfig": {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ classifiers = [
dependencies = [
"jupyter_ydoc>=1.1.0,<2",
"y-py>=0.6.0,<0.7",
"jupytercad_core>=1.0.0a1,<2",
"jupytercad_core>=1.0.0a3,<2",
]
dynamic = ["version", "description", "authors", "urls", "keywords"]

Expand Down
12 changes: 9 additions & 3 deletions src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
IAnnotationModel,
IJCadWorkerRegistry,
JupyterCadDoc,
IJCadWorkerRegistryToken
IJCadWorkerRegistryToken,
IJCadExternalCommandRegistry,
IJCadExternalCommandRegistryToken
} from '@jupytercad/schema';
import {
JupyterFrontEnd,
Expand Down Expand Up @@ -35,7 +37,8 @@ const activate = async (
themeManager: IThemeManager,
annotationModel: IAnnotationModel,
drive: ICollaborativeDrive,
workerRegistry: IJCadWorkerRegistry
workerRegistry: IJCadWorkerRegistry,
externalCommandRegistry: IJCadExternalCommandRegistry
): Promise<void> => {
const fcCheck = await requestAPI<{ installed: boolean }>(
'jupytercad_freecad/backend-check',
Expand Down Expand Up @@ -64,6 +67,7 @@ const activate = async (
tracker,
commands: app.commands,
workerRegistry,
externalCommandRegistry,
backendCheck
});

Expand Down Expand Up @@ -104,6 +108,7 @@ const activate = async (
app.shell.activateById('jupytercad::leftControlPanel');
app.shell.activateById('jupytercad::rightControlPanel');
});
console.log('jupytercad:fcplugin is activated!');
};

export const fcplugin: JupyterFrontEndPlugin<void> = {
Expand All @@ -113,7 +118,8 @@ export const fcplugin: JupyterFrontEndPlugin<void> = {
IThemeManager,
IAnnotationToken,
ICollaborativeDrive,
IJCadWorkerRegistryToken
IJCadWorkerRegistryToken,
IJCadExternalCommandRegistryToken
],
autoStart: true,
activate
Expand Down
13 changes: 13 additions & 0 deletions ui-tests/jupyter_server_test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Server configuration for integration tests.
!! Never use this configuration in production because it
opens the server to the world and provide access to JupyterLab
JavaScript objects through the global window variable.
"""

from jupyterlab.galata import configure_jupyter_server

configure_jupyter_server(c) # noqa F821
c.LabApp.collaborative = True # noqa F821
# Uncomment to set server log level to debug level
# c.ServerApp.log_level = "DEBUG"
20 changes: 20 additions & 0 deletions ui-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "jupytercad-freecad-ui-tests",
"version": "1.0.0",
"description": "jupytercad-freecad 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.0.8",
"@playwright/test": "^1.32.0",
"@types/klaw-sync": "^6.0.1"
},
"dependencies": {
"klaw-sync": "^6.0.0"
}
}
24 changes: 24 additions & 0 deletions ui-tests/playwright.config.js
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
}
}
};
Loading

0 comments on commit 1997672

Please sign in to comment.