From 78f8d987f2c59e1b2e640fdb88878313c11b8130 Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Wed, 21 Feb 2024 11:55:12 +0000 Subject: [PATCH] Add integration test and dependencies for Binder setup --- .github/workflows/build.yml | 2 +- .../workflows/update-integration-tests.yml | 2 +- binder/environment.yml | 5 +++-- binder/postBuild | 2 ++ pyproject.toml | 6 ++++++ src/index.ts | 2 +- ui-tests/tests/jupyterlab_nebari_mode.spec.ts | 20 +++++++++++++++++++ 7 files changed, 34 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f07e727..db33d8e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -109,7 +109,7 @@ jobs: - name: Install the extension run: | set -eux - python -m pip install "jupyterlab>=4.0.0,<5" jupyterlab_nebari_mode*.whl + python -m pip install "jupyterlab>=4.0.0,<5" jupyterlab_nebari_mode*.whl[integration-test] - name: Install dependencies working-directory: ui-tests diff --git a/.github/workflows/update-integration-tests.yml b/.github/workflows/update-integration-tests.yml index 7ea5a66..cddbfac 100644 --- a/.github/workflows/update-integration-tests.yml +++ b/.github/workflows/update-integration-tests.yml @@ -40,7 +40,7 @@ jobs: run: | set -eux jlpm - python -m pip install . + python -m pip install .[integration-test] - uses: jupyterlab/maintainer-tools/.github/actions/update-snapshots@v1 with: diff --git a/binder/environment.yml b/binder/environment.yml index 5b26c8a..89acfe3 100644 --- a/binder/environment.yml +++ b/binder/environment.yml @@ -17,5 +17,6 @@ dependencies: - nodejs >=18,<19 - pip - wheel - # additional packages for demos - # - ipywidgets + - pip: + - jupyter-server-proxy + - jupyter-vscode-proxy diff --git a/binder/postBuild b/binder/postBuild index 0b72431..4f51a82 100755 --- a/binder/postBuild +++ b/binder/postBuild @@ -42,6 +42,8 @@ _("jupyter", "server", "extension", "list") # initially list installed extensions to determine if there are any surprises _("jupyter", "labextension", "list") +_("mkdir", "-p", "$NB_PYTHON_PREFIX/share/jupyter/lab/settings/") +_("cp", "binder/overrides.json", "$NB_PYTHON_PREFIX/share/jupyter/lab/settings/") print("JupyterLab with jupyterlab_nebari_mode is ready to run with:\n") print("\tjupyter lab\n") diff --git a/pyproject.toml b/pyproject.toml index 65113fd..c2b17a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,12 @@ dependencies = [ ] dynamic = ["version", "description", "authors", "urls", "keywords"] +[project.optional-dependencies] +integration-test = [ + "jupyter-server-proxy", + "jupyter-vscode-proxy" +] + [tool.hatch.version] source = "nodejs" diff --git a/src/index.ts b/src/index.ts index c211920..99d8d34 100644 --- a/src/index.ts +++ b/src/index.ts @@ -110,7 +110,7 @@ const commandsPlugin: JupyterFrontEndPlugin = { window.location.href = url; } }, - isVisible: (args: IOpenProxyArgs) => { + isEnabled: (args: IOpenProxyArgs) => { const processs = findProcess(args.name); return !!processs; }, diff --git a/ui-tests/tests/jupyterlab_nebari_mode.spec.ts b/ui-tests/tests/jupyterlab_nebari_mode.spec.ts index 86520f5..d29f795 100644 --- a/ui-tests/tests/jupyterlab_nebari_mode.spec.ts +++ b/ui-tests/tests/jupyterlab_nebari_mode.spec.ts @@ -26,3 +26,23 @@ test('should swap Jupyter logo with clickable Nebari logo', async ({ await link.focus(); expect(await link.screenshot()).toMatchSnapshot('nebari-logo-focus.png'); }); + +test('should register custom commands', async ({ page }) => { + const openVScodeProxy = await page.evaluate(async () => { + const registry = window.jupyterapp.commands; + const id = 'nebari:open-proxy'; + const args = { name: 'vscode' }; + + return { + id, + label: registry.label(id, args), + isEnabled: registry.isEnabled(id, args) + }; + }); + + // Should set correct label for given command + expect(openVScodeProxy.label).toBe('Open VS Code'); + + // Should be enabled when `jupyter-vscode-proxy` is installed + expect(openVScodeProxy.isEnabled).toBe(true); +});