Skip to content

Commit

Permalink
set up ui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Dec 19, 2024
1 parent f409c47 commit 5393d01
Show file tree
Hide file tree
Showing 5 changed files with 4,601 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
sudo rm -rf $(which node)
cp ./jupyter_suggestions_core/dist/jupyter_suggestions*.whl .
cp ./jupyter_suggestions_rtc/dist/jupyter_suggestions*.whl .
pip install "jupyterlab>=4.0.0,<5" jupyter_suggestions*.whl
Expand All @@ -91,6 +92,71 @@ jobs:
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1

integration-tests:
name: Integration tests
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
backend: ['local', 'rtc']

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

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
architecture: 'x64'
- uses: actions/download-artifact@v4
with:
name: extension-artifacts
- name: Install base package
run: |
set -eux
cp ./jupyter_suggestions_core/dist/jupyter_suggestions_core*.whl .
pip install "jupyterlab>=4.0.0,<5" jupyter_suggestions_core*.whl
- name: Install rtc package
if: matrix.backend == 'rtc'
run: |
set -eux
cp ./jupyter_suggestions_rtc/dist/jupyter_suggestions_rtc*.whl .
pip install jupyter_suggestions_rtc*.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@v4
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
id: upload-galata-artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: jupyter-suggestions-playwright-tests
path: |
ui-tests/test-results
ui-tests/playwright-report
build-lite:
name: Build JupyterLite
needs: build
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"
16 changes: 16 additions & 0 deletions ui-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "jupyter-suggestions-ui-tests",
"version": "1.0.0",
"description": "Jupyter suggestions Integration Tests",
"private": true,
"scripts": {
"start": "jupyter lab --config jupyter_server_test_config.py",
"test": "npx playwright test --workers 1",
"test:update": "npx playwright test --update-snapshots",
"test:debug": "PWDEBUG=1 npx playwright test --workers 1"
},
"devDependencies": {
"@jupyterlab/galata": "^5.2.5",
"@playwright/test": "^1.32.0"
}
}
25 changes: 25 additions & 0 deletions ui-tests/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* 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: 1,
use: {
...baseConfig.use,
trace: 'off',

},
expect: {
toMatchSnapshot: {
maxDiffPixelRatio: 0.002,
},
},
};
Loading

0 comments on commit 5393d01

Please sign in to comment.