Skip to content

Commit

Permalink
Add UI test config
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed May 10, 2024
1 parent d2fbf79 commit 85e1ad6
Show file tree
Hide file tree
Showing 5 changed files with 4,391 additions and 2 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,78 @@ jobs:
jupyter labextension list 2>&1 | grep -ie "@jupytercad/jupytercad-openvsp.*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
- uses: actions/download-artifact@v4
with:
name: extension-artifacts

- name: Install the extension
shell: bash -l {0}
run: |
set -eux
pip install "jupyterlab>=4.0.0,<5" "jupytercad>=2.0.0a7" jupytercad_openvsp*.whl
- name: Install OpenVSP
shell: bash -l {0}
run: |
set -eux
wget https://openvsp.org/download.php?file=zips/current/linux/OpenVSP-3.38.0-Ubuntu-22.04_amd64.deb -O ovsp.deb
ar x ovsp.deb && tar -xf data.tar.gz
python -m pip install ./opt/OpenVSP/python/utilities ./opt/OpenVSP/python/degen_geom ./opt/OpenVSP/python/openvsp_config ./opt/OpenVSP/python/openvsp
- 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
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-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"
}
}
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 85e1ad6

Please sign in to comment.