diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 03925960..cbe53fb4 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -66,7 +66,7 @@ jobs: echo "::group::Install netcat, a test dependency" docker exec --user root $container_id bash -c ' apt update - apt install -y netcat + apt install -y netcat-openbsd ' echo "::endgroup::" @@ -95,6 +95,7 @@ jobs: export CONTAINER_ID=$container_id export JUPYTER_HOST=http://localhost:8888 export JUPYTER_TOKEN=secret + export VNCSERVER=${{ matrix.vncserver }} python -mpytest -vs diff --git a/README.md b/README.md index bcde574a..74e3ec2d 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ This is based on https://github.com/ryanlovett/nbnovnc. When this extension is launched it will run a Linux desktop on the Jupyter single-user server, and proxy it to your browser using VNC via Jupyter. +![Screenshot of jupyter-remote-desktop-proxy XFCE desktop](https://raw.githubusercontent.com/jupyterhub/jupyter-remote-desktop-proxy/main/tests/reference/desktop.png) + ## VNC Server This extension requires a [VNC Server](https://en.wikipedia.org/wiki/Virtual_Network_Computing) diff --git a/tests/reference/desktop-turbovnc.png b/tests/reference/desktop-turbovnc.png new file mode 100644 index 00000000..8fbbae68 Binary files /dev/null and b/tests/reference/desktop-turbovnc.png differ diff --git a/tests/reference/desktop.png b/tests/reference/desktop.png index 007d8282..6d06a152 100644 Binary files a/tests/reference/desktop.png and b/tests/reference/desktop.png differ diff --git a/tests/test_browser.py b/tests/test_browser.py index 7d4b3038..8ca052f6 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -12,15 +12,21 @@ CONTAINER_ID = getenv("CONTAINER_ID", "test") JUPYTER_HOST = getenv("JUPYTER_HOST", "http://localhost:8888") JUPYTER_TOKEN = getenv("JUPYTER_TOKEN", "secret") +VNCSERVER = getenv("VNCSERVER") -def compare_screenshot(test_image, threshold=2): +def compare_screenshot(test_image): # Compare images by calculating the mean absolute difference # Images must be the same size # threshold: Average difference per pixel, this depends on the image type # e.g. for 24 bit images (8 bit RGB pixels) threshold=1 means a maximum # difference of 1 bit per pixel per channel reference = Image.open(HERE / "reference" / "desktop.png") + threshold = 2 + if VNCSERVER == "turbovnc": + reference = Image.open(HERE / "reference" / "desktop-turbovnc.png") + # The TurboVNC screenshot varies a lot more than TigerVNC + threshold = 6 test = Image.open(test_image) # Absolute difference @@ -53,7 +59,7 @@ def test_desktop(browser): page1.wait_for_timeout(5000) # Use a non temporary folder so we can check it manually if necessary screenshot = Path("screenshots") / "desktop.png" - page1.locator("canvas").screenshot(path=screenshot) + page1.locator("body").screenshot(path=screenshot) # Open clipboard, enter random text, close clipboard clipboard_text = str(uuid4())