Skip to content

Commit 11425ca

Browse files
Merge branch 'dev' into feat/migrate-basic-e2e-to-playwright
2 parents 7d000b4 + 39371f7 commit 11425ca

58 files changed

Lines changed: 2463 additions & 464 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/context/backend.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
## Coding Rules
1515

1616
- Follow PEP 8, format with `black py` (v23.1.0), 80-char lines
17-
- Python >= 3.8 compatibility
17+
- Python >= 3.12 compatibility
1818
- Use `@pytorch_wrap` on all `Visdom` methods
1919
- Use `warn_once()` for deprecation warnings
2020

.agents/context/testing.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
# Testing Instructions
22

3-
Cypress 9 for E2E and visual regression. No Python unit tests — validation is via demo scripts and Cypress.
3+
Two layers: **pytest** for Python unit tests (pure functions, server utils, window/env lifecycle) and **Cypress 9** for E2E and visual regression. Demo scripts remain useful for manual/visual validation.
44

5-
## Run Tests
5+
## Run Python Tests (pytest)
6+
7+
```bash
8+
pip install -r test-requirements.txt # includes pytest, pytest-cov
9+
pytest # runs the tracked suite under py/tests/
10+
pytest -m "not server" # skip tests that need a live server (CI default)
11+
```
12+
13+
Config lives in `pyproject.toml` (`[tool.pytest.ini_options]`): discovery is scoped to
14+
`py/tests/` and `pythonpath = ["py"]` makes `import visdom` work without an editable install.
15+
Experimental `test_*.py` scripts in the repo root (and `test/`) are intentionally out of scope.
16+
17+
## Run E2E / Visual Tests (Cypress)
618

719
```bash
820
visdom -port 8098 -env_path /tmp # Always start fresh server first
@@ -24,9 +36,19 @@ Always use port `8098` and `-env_path /tmp` for isolation.
2436

2537
`basic.js` (connection), `pane.js` (CRUD), `text.js`, `image.js`, `properties.js`, `modal.js`, `misc.js`, `screenshots.init.js` (baseline), `screenshots.js` (comparison).
2638

39+
## Writing Python Tests
40+
41+
- Place in `py/tests/`, name files `test_*.py`, classes `Test*` (unittest `TestCase` or plain
42+
pytest functions both work — pytest auto-discovers unittest).
43+
- Keep them hermetic (no running server). A test that genuinely needs a live server must be
44+
marked `@pytest.mark.server` so CI can deselect it.
45+
- Start with simple hermetic tests (e.g., `test_smoke.py`) and add focused unit tests for
46+
server/window/env lifecycle code as coverage grows.
47+
2748
## CI
2849

29-
- Python 3.8, 3.9, 3.10 matrix, both WebSocket and polling modes
50+
- `python-tests.yml` runs `pytest -m "not server"` on a Python version matrix for every pull
51+
request (and on pushes to master/dev)
3052
- Visual regression compares PR screenshots against base branch
3153
- `update-js-build-files.yml` auto-compiles JS on master
3254
- `pypi.yml` publishes to PyPI when VERSION changes

.github/actions/prepare/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ inputs:
1212
python-version:
1313
description: 'Python version to use'
1414
required: false
15-
default: '3.10'
15+
default: '3.12'
1616

1717
runs:
1818
using: "composite"
@@ -43,7 +43,7 @@ runs:
4343

4444

4545
# now cache pip
46-
- uses: actions/cache@v3
46+
- uses: actions/cache@v4
4747
id: cache-pip
4848
with:
4949
path: ~/.cache/pip
@@ -57,7 +57,7 @@ runs:
5757
pip3 install -e .
5858
5959
# now compile the new version
60-
- uses: actions/cache@v3
60+
- uses: actions/cache@v4
6161
id: cache-npm
6262
with:
6363
path: |

.github/workflows/deploy-docs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
run:
2626
working-directory: ./website
2727
steps:
28-
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
29-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
28+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
29+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
3030
with:
3131
node-version: 24
3232
cache: npm
@@ -39,7 +39,7 @@ jobs:
3939
run: npm run build
4040

4141
- name: Upload artifact
42-
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa
42+
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9
4343
with:
4444
path: website/build
4545

@@ -52,4 +52,4 @@ jobs:
5252
steps:
5353
- name: Deploy to GitHub Pages
5454
id: deployment
55-
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e
55+
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128

.github/workflows/process-changes.yml

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: "Checkout Repository"
14-
uses: actions/checkout@v7
14+
uses: actions/checkout@v7.0.0
1515
- name: "Install Node"
16-
uses: actions/setup-node@v6
16+
uses: actions/setup-node@v6.4.0
1717
with:
1818
node-version: '24'
1919
- name: "Install Dependencies"
@@ -25,7 +25,7 @@ jobs:
2525
name: "Python Linter Check"
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v7
28+
- uses: actions/checkout@v7.0.0
2929
- uses: psf/black@26.5.1
3030
with:
3131
src: "./py"
@@ -41,7 +41,7 @@ jobs:
4141
jsfileschanged: ${{ steps.checkout.outputs.jsfileschanged }}
4242
steps:
4343
- name: "Checkout Repository"
44-
uses: actions/checkout@v7
44+
uses: actions/checkout@v7.0.0
4545
- uses: ./.github/actions/prepare
4646
with:
4747
loadprbuild: false
@@ -78,7 +78,7 @@ jobs:
7878
steps:
7979

8080
- name: "Checkout Repository"
81-
uses: actions/checkout@v7
81+
uses: actions/checkout@v7.0.0
8282

8383
- name: "Save current Head-Ref as PR-branch"
8484
shell: bash
@@ -109,6 +109,7 @@ jobs:
109109
browser: chrome
110110
start: visdom -port 8098 -env_path /tmp
111111
wait-on: 'http://localhost:8098'
112+
env: CYPRESS_CHROME_ARGS="--disable-gpu --disable-dev-shm-usage --no-sandbox --disable-setuid-sandbox"
112113
spec: cypress/integration/*.init.js
113114

114115
- uses: actions/upload-artifact@v7
@@ -123,7 +124,7 @@ jobs:
123124
needs: visual-regression-test-init
124125
steps:
125126
- name: "Checkout Repository"
126-
uses: actions/checkout@v7
127+
uses: actions/checkout@v7.0.0
127128
- uses: ./.github/actions/prepare
128129

129130
- uses: actions/download-artifact@v8
@@ -138,6 +139,7 @@ jobs:
138139
browser: chrome
139140
start: visdom -port 8098 -env_path /tmp
140141
wait-on: 'http://localhost:8098'
142+
env: CYPRESS_CHROME_ARGS="--disable-gpu --disable-dev-shm-usage --no-sandbox --disable-setuid-sandbox"
141143
spec: cypress/integration/screenshots.js
142144

143145
- uses: actions/upload-artifact@v7
@@ -152,10 +154,10 @@ jobs:
152154
needs: install-and-build
153155
strategy:
154156
matrix:
155-
python: ['3.10', '3.11', '3.12']
157+
python: ['3.12', '3.13']
156158
steps:
157159
- name: "Checkout Repository"
158-
uses: actions/checkout@v7
160+
uses: actions/checkout@v7.0.0
159161
- uses: ./.github/actions/prepare
160162
with:
161163
python-version: ${{ matrix.python }}
@@ -167,6 +169,7 @@ jobs:
167169
browser: chrome
168170
start: visdom -port 8098 -env_path /tmp
169171
wait-on: 'http://localhost:8098'
172+
env: CYPRESS_CHROME_ARGS="--disable-gpu --disable-dev-shm-usage --no-sandbox --disable-setuid-sandbox"
170173
config: excludeSpecPattern=**/screenshots.*
171174

172175
- uses: actions/upload-artifact@v7
@@ -181,7 +184,7 @@ jobs:
181184
needs: install-and-build
182185
steps:
183186
- name: 'Checkout Repository'
184-
uses: actions/checkout@v7
187+
uses: actions/checkout@v7.0.0
185188
- uses: ./.github/actions/prepare
186189

187190
- name: Cypress test
@@ -191,10 +194,35 @@ jobs:
191194
browser: chrome
192195
start: visdom -port 8098 -env_path /tmp -use_frontend_client_polling
193196
wait-on: 'http://localhost:8098'
197+
env: CYPRESS_CHROME_ARGS="--disable-gpu --disable-dev-shm-usage --no-sandbox --disable-setuid-sandbox"
194198
config: excludeSpecPattern=**/screenshots.*
195199

196200
- uses: actions/upload-artifact@v7
197201
if: failure()
198202
with:
199203
name: cypress-screenshots-functional-polling
200204
path: cypress/screenshots
205+
206+
playwright-test:
207+
name: "Playwright Functional Test"
208+
runs-on: ubuntu-latest
209+
needs: install-and-build
210+
steps:
211+
- name: "Checkout Repository"
212+
uses: actions/checkout@v7.0.0
213+
- uses: ./.github/actions/prepare
214+
215+
- name: Install Playwright Chromium
216+
run: npx playwright install --with-deps chromium
217+
218+
219+
220+
- name: Run Playwright tests
221+
run: npm run test:pw
222+
223+
- name: Upload Playwright Report
224+
uses: actions/upload-artifact@v7
225+
if: failure()
226+
with:
227+
name: playwright-report
228+
path: playwright/playwright-report/

.github/workflows/pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
name: "Deploy to PyPI"
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v7
17+
uses: actions/checkout@v7.0.0
1818
- name: Get git-tags
1919
run: |
2020
git fetch --prune --unshallow --tags

.github/workflows/python-tests.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Python Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- dev
9+
10+
jobs:
11+
pytest:
12+
name: "pytest (Python ${{ matrix.python-version }})"
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python-version: ["3.12", "3.13"]
18+
steps:
19+
- name: Checkout Repository
20+
uses: actions/checkout@v7.0.0
21+
- name: Set up Python
22+
uses: actions/setup-python@v6
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Install package and test dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
python -m pip install -e .
29+
python -m pip install -r test-requirements.txt
30+
- name: Run pytest
31+
run: pytest -m "not server"

.github/workflows/update-js-build-files.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
runs-on: ubuntu-latest
1818
name: "Update Static JS-Files"
1919
steps:
20-
- uses: actions/checkout@v7
20+
- uses: actions/checkout@v7.0.0
2121
# > if the push needs to trigger other workflows, use a repo scoped Personal Acces Token
2222
# see: https://stackoverflow.com/questions/57921401/push-to-origin-from-github-action/58393457#58393457
2323
# with:
2424
# token: ${{ secrets.PAT }}
25-
- uses: actions/setup-node@v6
25+
- uses: actions/setup-node@v6.4.0
2626
with:
2727
node-version: '24'
2828
- run: ELECTRON_SKIP_BINARY_DOWNLOAD=1 npm install

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,10 @@ website/.docusaurus
3030
venv
3131
test-bin
3232
bin
33+
34+
playwright/playwright-report/
35+
playwright/test-results/
36+
playwright/tmp/
37+
playwright-report/
38+
test-results/
39+
tmp/

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry=https://registry.npmjs.org/

0 commit comments

Comments
 (0)