Skip to content

Commit 2d670ca

Browse files
committed
Add smoke test (playwright) for built demo image
1 parent 3e73286 commit 2d670ca

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

.github/workflows/build.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,26 @@ jobs:
244244
tags: ${{ join(fromJson(steps.singleusertags.outputs.tags)) }}
245245
cache-from: ${{ env.CACHE_FROM }}
246246
cache-to: ${{ env.CACHE_TO }}
247+
248+
- name: Setup Python
249+
uses: actions/setup-python@v5
250+
with:
251+
python-version: "3.13"
252+
cache: pip
253+
cache-dependency-path: tests/dev-requirements.txt
254+
255+
- name: Install test dependencies
256+
run: |
257+
python -mpip install -r tests/dev-requirements.txt
258+
python -mplaywright install chromium
259+
260+
- name: Test demo image
261+
run: |
262+
DEMO_IMAGE=${{ fromJson(steps.demotags.outputs.tags)[0] }}
263+
docker run -d --name hub -p8000:8000 "$DEMO_IMAGE"
264+
sleep 5
265+
python -mpytest
266+
267+
- name: Get logs, including on failure
268+
if: always()
269+
run: docker logs hub

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ repos:
2020
hooks:
2121
- id: prettier
2222

23+
# autoformat and lint Python code
24+
- repo: https://github.com/astral-sh/ruff-pre-commit
25+
rev: v0.9.4
26+
hooks:
27+
- id: ruff
28+
args: ["--select=I", "--fix", "--show-fixes"]
29+
- id: ruff-format
30+
2331
# Static security analysis of GitHub actions https://github.com/woodruffw/zizmor
2432
- repo: https://github.com/woodruffw/zizmor-pre-commit
2533
rev: v1.5.1

tests/dev-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest-playwright>=0.7.0

tests/test_demo.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# To run these tests with firefox:
2+
# python -mpytest --browser=firefox
3+
# To investigate tests run this headed, and with a delay between actions
4+
# python -mpytest --browser=firefox --slowmo 2000 --headed
5+
6+
from playwright.sync_api import Page, expect
7+
8+
9+
def test_simple(page: Page) -> None:
10+
page.goto("http://localhost:8000")
11+
# Login page
12+
expect(page.get_by_role("button", name="Sign in")).to_be_visible()
13+
page.get_by_role("textbox", name="Username:").fill("demo")
14+
page.get_by_role("textbox", name="Password:").fill("demo")
15+
page.get_by_role("button", name="Sign in").click()
16+
# JupyterLab
17+
page.wait_for_url("http://localhost:8000/user/demo/lab")

0 commit comments

Comments
 (0)