Skip to content

test(e2e): add a Playwright smoke test for the Registers page - #7

Merged
adamsrnmsu merged 1 commit into
sandialabs:mainfrom
adamsrnmsu:test-e2e-playwright
Nov 19, 2026
Merged

adamsrnmsu merged 1 commit into
sandialabs:mainfrom
adamsrnmsu:test-e2e-playwright

Conversation

@adamsrnmsu

Copy link
Copy Markdown
Collaborator

Description

Adds the first Playwright end-to-end test, driving the real Registers page in Chromium. It seeds a small deterministic set of Malcolm-shaped modbus_detailed documents (two IP pairs, three registers, two alternating states) into a unique Elasticsearch index, loads it with "Load Data", opens an IP pair, ticks two registers and asserts the chart draws with no failed requests or error toasts. A second test opens the State tab and asserts /registers/state/state/ succeeds and "Register State Over Time" renders.

  • tests/e2e/ uses pytest-playwright (added to the dev extra) with pytest-django's live_server. constraints.txt only pins runtime dependencies (no pytest or other dev packages), so it is unchanged.
  • Tests are marked e2e and deselected by default (addopts = -m 'not e2e'), so the existing pytest job and make test-python need no browser. Run them with pytest -m e2e tests/e2e (needs Elasticsearch, make setup, and python -m playwright install chromium).
  • New e2e job in ci.yml (python:3.13 container, Elasticsearch service, make setup, Chromium); failure screenshots are uploaded as an artifact.

The State check depends on #6: on main the State request returns 400 ("Cannot create writable memory view from read-only memoryview"). test_state_tab is marked xfail(strict=True) so this PR does not land with a red CI. When #6 merges, the test XPASSes, strict turns that into a failure, and the marker (and its comment) is deleted. The chart test is unaffected.

Related Issues/PRs

#6 (fixes the State tab 400), #3

Type of Change

  • Bugfix (fix)
  • Feature (feat)
  • Documentation (docs)
  • Refactor (refactor)
  • Chore (CI, build, dependencies, etc.) (chore)
  • Other (please describe): Test and CI (test): end-to-end browser test plus a CI job to run it

Checklist

  • This PR conforms to the process detailed in the Contributing Guide.
  • I have included no proprietary/sensitive information in my code or the PR.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • I have tested my code (describe below).

Testing

Local, Elasticsearch 8.19.5 in Docker, Chromium via Playwright, pytest -m e2e tests/e2e:

  • main: test_registers_chart passes; test_state_tab xfails. With --runxfail it fails with 400 Cannot create writable memory view from read-only memoryview.
  • main + fix(registers): give hdbscan a writable array so the State tab works #6 (commit 63984f8 cherry-picked, not part of this PR): both tests pass (test_state_tab reports XPASS(strict), the expected prompt to drop the marker).
  • Default pytest run deselects the e2e tests.
  • Workflow checked with actionlint (clean apart from the shellcheck SC2102 note that the existing pip install -e .[all,dev] lines also trigger) and zizmor. The new job's actions are pinned by SHA. The CI job itself has not run yet; this PR's checks are its first run.

Additional Notes

The test sets SESSION_COOKIE_SECURE/CSRF_COOKIE_SECURE to False for the plain-http live server (otherwise the session holding the loaded register data is dropped) and DJANGO_ALLOW_ASYNC_UNSAFE because Playwright's sync API runs an event loop in the test thread.

🤖 Generated with Claude Code

@Ethane98

Copy link
Copy Markdown
Collaborator

Pending re-running tests after #6 is merged in.

@Ethane98

Copy link
Copy Markdown
Collaborator

@adamsrnmsu #6 has been merged in, can you pull into this branch and verify tests/deconflict if necessary? I'm good to merge it after that.

Drive the real web UI in Chromium: seed Malcolm-shaped Modbus documents
(two IP pairs, three registers, two alternating states) into a unique
Elasticsearch index, load it on /registers/, open an IP pair, tick two
registers and check the chart draws, then check the State tab.

- tests/e2e/ uses pytest-playwright with pytest-django's live_server; the
  fixture deletes its index afterwards.
- e2e tests carry an `e2e` marker and are deselected by default
  (addopts = -m 'not e2e'), so the existing pytest job needs no browser.
  Run them with `pytest -m e2e tests/e2e`.
- New `e2e` CI job (python:3.13 container + Elasticsearch service) installs
  Chromium and uploads failure screenshots as an artifact.
- test_state_tab checks that the State tab loads and draws its chart, which
  works since sandialabs#6 gave hdbscan a writable array.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adamsrnmsu

Copy link
Copy Markdown
Collaborator Author

Pulled in #6 by rebasing on main. There were no conflicts. With #6 in, test_state_tab passes, so I removed its xfail marker. CI is green on a9987da, and the e2e job passes both tests (test_registers_chart and test_state_tab).

@adamsrnmsu
adamsrnmsu merged commit 3352872 into sandialabs:main Nov 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants