Skip to content

Commit

Permalink
Update UI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Apr 12, 2024
1 parent 29214b0 commit ec22d1f
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 9 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: master
pull_request:
branches: "*"
branches: '*'

jobs:
build:
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ['3.8', '3.9', '3.10']

steps:
- name: Checkout
Expand Down Expand Up @@ -99,7 +99,10 @@ jobs:
name: Integration tests
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
build-backend: ['local', 'binderhub']
env:
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/pw-browsers

Expand Down Expand Up @@ -139,10 +142,10 @@ jobs:
run: npx playwright install chromium
working-directory: ui-tests

- name: Execute integration tests
- name: Execute integration tests with ${{ matrix.build-backend }} build backend
working-directory: ui-tests
run: |
npx playwright test
npx playwright test:${{ matrix.build-backend }}
- name: Upload Playwright Test report
if: always()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
apply_config(tljh_config, c)

tljh_custom_jupyterhub_config(c)
tljh_repo2docker_config = HERE / "tljh_repo2docker_config.py"

tljh_repo2docker_config = HERE / "tljh_repo2docker_binderhub.py"

c.JupyterHub.authenticator_class = DummyAuthenticator

Expand Down
77 changes: 77 additions & 0 deletions ui-tests/jupyterhub_config_local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
"""
This file is only used for local development
and overrides some of the default values from the plugin.
"""

from jupyterhub.auth import DummyAuthenticator
from tljh.configurer import apply_config, load_config
from tljh_repo2docker import tljh_custom_jupyterhub_config, TLJH_R2D_ADMIN_SCOPE
import sys

tljh_config = load_config()

apply_config(tljh_config, c)

tljh_custom_jupyterhub_config(c)


c.JupyterHub.authenticator_class = DummyAuthenticator

c.JupyterHub.allow_named_servers = True
c.JupyterHub.ip = "0.0.0.0"

c.JupyterHub.services.extend(
[
{
"name": "tljh_repo2docker",
"url": "http://127.0.0.1:6789",
"command": [
sys.executable,
"-m",
"tljh_repo2docker",
"--ip",
"127.0.0.1",
"--port",
"6789",
"--machine_profiles",
'{"label": "Small", "cpu": 2, "memory": 2}',
"--machine_profiles",
'{"label": "Medium", "cpu": 4, "memory": 4}',
"--machine_profiles",
'{"label": "Large", "cpu": 8, "memory": 8}',
],
"oauth_no_confirm": True,
"oauth_client_allowed_scopes": [
TLJH_R2D_ADMIN_SCOPE,
],
}
]
)

c.JupyterHub.custom_scopes = {
TLJH_R2D_ADMIN_SCOPE: {
"description": "Admin access to myservice",
},
}

c.JupyterHub.load_roles = [
{
"description": "Role for tljh_repo2docker service",
"name": "tljh-repo2docker-service",
"scopes": ["read:users", "read:roles:users", "admin:servers"],
"services": ["tljh_repo2docker"],
},
{
"name": "tljh-repo2docker-service-admin",
"users": ["alice"],
"scopes": [TLJH_R2D_ADMIN_SCOPE],
},
{
"name": "user",
"scopes": [
"self",
# access to the env page
"access:services!service=tljh_repo2docker",
],
},
]
3 changes: 2 additions & 1 deletion ui-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "tljh_repo2docker UI Tests",
"private": true,
"scripts": {
"test": "npx playwright test --workers 1",
"test:local": "CONFIG_FILE=local npx playwright test --workers 1",
"test:bindehub": "CONFIG_FILE=binderhub npx playwright test --workers 1",
"test:update": "npx playwright test --update-snapshots",
"test:debug": "PWDEBUG=1 npx playwright test --workers 1"
},
Expand Down
7 changes: 6 additions & 1 deletion ui-tests/playwright.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const snapshotDir = `${process.env.CONFIG_FILE}_snapshots`;

const configFile = `jupyterhub_config_${process.env.CONFIG_FILE}.py`;

module.exports = {
timeout: 600000,
reporter: [[process.env.CI ? 'dot' : 'list'], ['html']],
Expand All @@ -12,8 +16,9 @@ module.exports = {
maxDiffPixelRatio: 0.001
}
},
snapshotPathTemplate: `{testDir}/${snapshotDir}/{testFileName}/{arg}{ext}`,
webServer: {
command: 'python -m jupyterhub -f ./jupyterhub_config.py',
command: `python -m jupyterhub -f ./${configFile}`,
url: 'http://localhost:8000',
timeout: 120 * 1000,
reuseExistingServer: true
Expand Down
File renamed without changes.

0 comments on commit ec22d1f

Please sign in to comment.