diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e9b1ef7..c5e4626 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: push: branches: master pull_request: - branches: "*" + branches: '*' jobs: build: @@ -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 @@ -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 @@ -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() diff --git a/ui-tests/jupyterhub_config.py b/ui-tests/jupyterhub_config_binderhub.py similarity index 97% rename from ui-tests/jupyterhub_config.py rename to ui-tests/jupyterhub_config_binderhub.py index 6a07e9f..9b223b6 100644 --- a/ui-tests/jupyterhub_config.py +++ b/ui-tests/jupyterhub_config_binderhub.py @@ -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 diff --git a/ui-tests/jupyterhub_config_local.py b/ui-tests/jupyterhub_config_local.py new file mode 100644 index 0000000..05be037 --- /dev/null +++ b/ui-tests/jupyterhub_config_local.py @@ -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", + ], + }, +] diff --git a/ui-tests/tests/ui.test.ts-snapshots/admin-linux.png b/ui-tests/local_snapshots/ui.test.ts/admin-linux.png similarity index 100% rename from ui-tests/tests/ui.test.ts-snapshots/admin-linux.png rename to ui-tests/local_snapshots/ui.test.ts/admin-linux.png diff --git a/ui-tests/tests/ui.test.ts-snapshots/environment-console-linux.png b/ui-tests/local_snapshots/ui.test.ts/environment-console-linux.png similarity index 100% rename from ui-tests/tests/ui.test.ts-snapshots/environment-console-linux.png rename to ui-tests/local_snapshots/ui.test.ts/environment-console-linux.png diff --git a/ui-tests/tests/ui.test.ts-snapshots/environment-dialog-linux.png b/ui-tests/local_snapshots/ui.test.ts/environment-dialog-linux.png similarity index 100% rename from ui-tests/tests/ui.test.ts-snapshots/environment-dialog-linux.png rename to ui-tests/local_snapshots/ui.test.ts/environment-dialog-linux.png diff --git a/ui-tests/tests/ui.test.ts-snapshots/environment-list-linux.png b/ui-tests/local_snapshots/ui.test.ts/environment-list-linux.png similarity index 100% rename from ui-tests/tests/ui.test.ts-snapshots/environment-list-linux.png rename to ui-tests/local_snapshots/ui.test.ts/environment-list-linux.png diff --git a/ui-tests/tests/ui.test.ts-snapshots/environment-remove-confirm-linux.png b/ui-tests/local_snapshots/ui.test.ts/environment-remove-confirm-linux.png similarity index 100% rename from ui-tests/tests/ui.test.ts-snapshots/environment-remove-confirm-linux.png rename to ui-tests/local_snapshots/ui.test.ts/environment-remove-confirm-linux.png diff --git a/ui-tests/tests/ui.test.ts-snapshots/environment-removed-linux.png b/ui-tests/local_snapshots/ui.test.ts/environment-removed-linux.png similarity index 100% rename from ui-tests/tests/ui.test.ts-snapshots/environment-removed-linux.png rename to ui-tests/local_snapshots/ui.test.ts/environment-removed-linux.png diff --git a/ui-tests/tests/ui.test.ts-snapshots/environments-page-linux.png b/ui-tests/local_snapshots/ui.test.ts/environments-page-linux.png similarity index 100% rename from ui-tests/tests/ui.test.ts-snapshots/environments-page-linux.png rename to ui-tests/local_snapshots/ui.test.ts/environments-page-linux.png diff --git a/ui-tests/tests/ui.test.ts-snapshots/login-page-linux.png b/ui-tests/local_snapshots/ui.test.ts/login-page-linux.png similarity index 100% rename from ui-tests/tests/ui.test.ts-snapshots/login-page-linux.png rename to ui-tests/local_snapshots/ui.test.ts/login-page-linux.png diff --git a/ui-tests/tests/ui.test.ts-snapshots/running-servers-linux.png b/ui-tests/local_snapshots/ui.test.ts/running-servers-linux.png similarity index 100% rename from ui-tests/tests/ui.test.ts-snapshots/running-servers-linux.png rename to ui-tests/local_snapshots/ui.test.ts/running-servers-linux.png diff --git a/ui-tests/tests/ui.test.ts-snapshots/server-remove-confirm-linux.png b/ui-tests/local_snapshots/ui.test.ts/server-remove-confirm-linux.png similarity index 100% rename from ui-tests/tests/ui.test.ts-snapshots/server-remove-confirm-linux.png rename to ui-tests/local_snapshots/ui.test.ts/server-remove-confirm-linux.png diff --git a/ui-tests/tests/ui.test.ts-snapshots/server-removed-linux.png b/ui-tests/local_snapshots/ui.test.ts/server-removed-linux.png similarity index 100% rename from ui-tests/tests/ui.test.ts-snapshots/server-removed-linux.png rename to ui-tests/local_snapshots/ui.test.ts/server-removed-linux.png diff --git a/ui-tests/tests/ui.test.ts-snapshots/servers-dialog-linux.png b/ui-tests/local_snapshots/ui.test.ts/servers-dialog-linux.png similarity index 100% rename from ui-tests/tests/ui.test.ts-snapshots/servers-dialog-linux.png rename to ui-tests/local_snapshots/ui.test.ts/servers-dialog-linux.png diff --git a/ui-tests/tests/ui.test.ts-snapshots/servers-page-linux.png b/ui-tests/local_snapshots/ui.test.ts/servers-page-linux.png similarity index 100% rename from ui-tests/tests/ui.test.ts-snapshots/servers-page-linux.png rename to ui-tests/local_snapshots/ui.test.ts/servers-page-linux.png diff --git a/ui-tests/tests/ui.test.ts-snapshots/user-linux.png b/ui-tests/local_snapshots/ui.test.ts/user-linux.png similarity index 100% rename from ui-tests/tests/ui.test.ts-snapshots/user-linux.png rename to ui-tests/local_snapshots/ui.test.ts/user-linux.png diff --git a/ui-tests/package.json b/ui-tests/package.json index ed8db4c..c5ba5a9 100644 --- a/ui-tests/package.json +++ b/ui-tests/package.json @@ -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" }, diff --git a/ui-tests/playwright.config.js b/ui-tests/playwright.config.js index f229aa7..2b4e0bd 100644 --- a/ui-tests/playwright.config.js +++ b/ui-tests/playwright.config.js @@ -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']], @@ -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 diff --git a/ui-tests/tljh_repo2docker_config.py b/ui-tests/tljh_repo2docker_binderhub.py similarity index 100% rename from ui-tests/tljh_repo2docker_config.py rename to ui-tests/tljh_repo2docker_binderhub.py