From d78e1f58dc2174c50e06a8b9482e9b5c3017690b Mon Sep 17 00:00:00 2001 From: mouldybread <38598858+mouldybread@users.noreply.github.com> Date: Sun, 29 Nov 2026 02:21:16 +0800 Subject: [PATCH 1/7] docs: add repository layout plan and ignore build artifacts (#16) --- .gitignore | 2 ++ docs/REPOSITORY_LAYOUT.md | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 docs/REPOSITORY_LAYOUT.md diff --git a/.gitignore b/.gitignore index 2863609..f73829f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /tmp eventburp.sh +/simplenvr +__pycache__/ diff --git a/docs/REPOSITORY_LAYOUT.md b/docs/REPOSITORY_LAYOUT.md new file mode 100644 index 0000000..d246248 --- /dev/null +++ b/docs/REPOSITORY_LAYOUT.md @@ -0,0 +1,17 @@ +# Repository layout (issue #16) + +Status: migration in progress. This page is updated to the final tree and move +inventory in the last batch. + +## Target layout + +- `cmd/simplenvr/` - all Go sources and Go tests (`package main`, unchanged) +- `web/templates/`, `web/static/` - HTML templates and static assets +- `tests/frontend/`, `tests/runtime/`, `tests/ci/` - Node suites, runtime acceptance scripts, CI helpers and their unit tests +- `tests/fixtures/`, `tests/evidence/` - unchanged +- `docs/` - documentation, including `docs/compose/` for Compose examples +- `.github/` - workflows and scripts (stay in place) +- Root: `go.mod`, `go.sum`, `Dockerfile`, `README.md`, `LICENSE.md`, `DISCLAIMER.md` + +Application behavior, runtime paths (`/recordings`, `/certs`, `/app/templates`, +`/app/static`) and test assertions do not change. From 43f1645456023c2f3f27fc7a1efc38c5b1561a49 Mon Sep 17 00:00:00 2001 From: mouldybread <38598858+mouldybread@users.noreply.github.com> Date: Sun, 29 Nov 2026 02:28:36 +0800 Subject: [PATCH 2/7] docs: move Docker Compose example to docs/compose (#16) --- README.md | 25 +------------------------ docs/compose/compose.yaml | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 24 deletions(-) create mode 100644 docs/compose/compose.yaml diff --git a/README.md b/README.md index e2af9e8..acd10b3 100644 --- a/README.md +++ b/README.md @@ -6,30 +6,7 @@ SimpleNVR records RTSP cameras with FFmpeg. Use the web interface to manage came Use the image from GitHub Container Registry. The example defaults to `v0.2.2`, which includes built-in authentication and server-prepared exports. An image's release workflow must finish publishing before it can be pulled. -Save as `compose.yaml`: - -```yaml -services: - simplenvr: - image: ghcr.io/mouldybread/simplenvr:${SIMPLENVR_VERSION:-v0.2.2} - restart: unless-stopped - ports: - - "127.0.0.1:8443:443" - environment: - NVR_EXPORT_SCRATCH_DIR: /exports - volumes: - - type: bind - source: ./recordings - target: /recordings - bind: - create_host_path: false - - type: bind - source: ./exports - target: /exports - bind: - create_host_path: false - - ./certs:/certs -``` +The example Compose file is [docs/compose/compose.yaml](docs/compose/compose.yaml). Copy it into your install directory as `compose.yaml` before running the commands below, because its `./recordings`, `./exports` and `./certs` paths are relative to the Compose file. Optionally set `SIMPLENVR_VERSION` in `.env` to another published version that supports these features. Unlike the old example, this Compose file actually uses that setting. diff --git a/docs/compose/compose.yaml b/docs/compose/compose.yaml new file mode 100644 index 0000000..a9eb6a2 --- /dev/null +++ b/docs/compose/compose.yaml @@ -0,0 +1,20 @@ +services: + simplenvr: + image: ghcr.io/mouldybread/simplenvr:${SIMPLENVR_VERSION:-v0.2.2} + restart: unless-stopped + ports: + - "127.0.0.1:8443:443" + environment: + NVR_EXPORT_SCRATCH_DIR: /exports + volumes: + - type: bind + source: ./recordings + target: /recordings + bind: + create_host_path: false + - type: bind + source: ./exports + target: /exports + bind: + create_host_path: false + - ./certs:/certs From b7b1c961e7356e467124df9fff191782b8bcb613 Mon Sep 17 00:00:00 2001 From: mouldybread <38598858+mouldybread@users.noreply.github.com> Date: Sun, 29 Nov 2026 03:14:34 +0800 Subject: [PATCH 3/7] refactor: group tests into frontend and acceptance directories (#16) --- .github/workflows/prepared-export-browser.yml | 4 ++-- .github/workflows/prepared-export-go.yml | 4 ++-- .github/workflows/safety-ci.yml | 18 +++++++++--------- camera_removal_confirmation_frontend_test.go | 2 +- docs/PREPARED_EXPORT_VERIFICATION.md | 2 +- docs/REPOSITORY_LAYOUT.md | 3 ++- docs/STORAGE_DEPLOYMENT_BOUNDARIES.md | 2 +- .../AUDIT_EVIDENCE_ADDENDUM_2026-11-16.md | 2 +- ...EVENT_CORRESPONDENCE_EVIDENCE_ASSESSMENT.md | 2 +- docs/audit/EVENT_NVR_INGESTION_POLICY.md | 2 +- docs/audit/EXPORT_UI.md | 2 +- docs/audit/RUNTIME_BROWSER_ACCEPTANCE.md | 2 +- .../RUNTIME_EXPORT_BACKPRESSURE_ACCEPTANCE.md | 6 +++--- event_clear_confirmation_frontend_test.go | 2 +- export_mode_ui_test.go | 2 +- export_queue_details_frontend_test.go | 2 +- export_range_controls_frontend_test.go | 2 +- frontend_security_test.go | 6 +++--- legacy_download_test.go | 2 +- live_stream_names_frontend_test.go | 2 +- orphan_cleanup_reporting_frontend_test.go | 2 +- persistence_responses_frontend_test.go | 2 +- playback_continuation_frontend_test.go | 2 +- playback_controls_frontend_test.go | 4 ++-- playback_failures_frontend_test.go | 4 ++-- playback_lifecycle_frontend_test.go | 2 +- ...ding_deletion_confirmation_frontend_test.go | 2 +- session_expiry_frontend_test.go | 2 +- .../active-container-storage.sh | 2 +- .../{ => acceptance}/browser_ci_diagnostics.py | 0 .../{ => acceptance}/browser_network_ready.py | 0 .../browser_playback_control.py | 0 .../{ => acceptance}/browser_playback_edges.py | 0 .../browser_playback_transport.py | 0 tests/{ => acceptance}/capture-copy-media.py | 0 tests/{ => acceptance}/core-ci-evidence.sh | 4 ++-- tests/{ => acceptance}/core_ci_evidence.py | 0 .../correspondence_assessment.py | 0 .../prepared_export_protocol.py | 0 .../{ => acceptance}/qualify_ingestion_time.py | 2 +- .../runtime-browser-acceptance.py | 0 .../runtime-browser-acceptance.sh | 8 ++++---- .../runtime-browser-expanded.py | 0 .../runtime-export-acceptance.sh | 8 ++++---- .../runtime_export_acceptance.py | 0 .../runtime_export_diagnostics.py | 0 .../runtime_export_writer_observer.py | 0 .../test_browser_ci_diagnostics.py | 0 .../test_browser_network_ready.py | 0 .../test_browser_playback_control.py | 4 ++-- .../test_browser_playback_edges.py | 0 .../test_browser_playback_transport.py | 0 .../{ => acceptance}/test_core_ci_evidence.py | 2 +- .../test_correspondence_assessment.py | 0 .../test_prepared_export_protocol.py | 0 .../test_runtime_export_acceptance.py | 0 .../test_runtime_export_diagnostics.py | 2 +- .../test_runtime_export_observer_exit.py | 0 .../test_runtime_export_writer_observer.py | 0 .../camera-removal-confirmation.cjs | 0 tests/{ => frontend}/download-entrypoints.cjs | 0 .../event-clear-confirmation.cjs | 0 tests/{ => frontend}/event-navigation.cjs | 0 tests/{ => frontend}/event-rendering.cjs | 0 tests/{ => frontend}/export-mode-ui.cjs | 0 tests/{ => frontend}/export-queue-details.cjs | 0 tests/{ => frontend}/export-range-controls.cjs | 0 tests/{ => frontend}/export-ui-fixture.cjs | 2 +- tests/{ => frontend}/export-ui.cjs | 2 +- tests/{ => frontend}/live-stream-names.cjs | 0 .../orphan-cleanup-reporting.cjs | 0 tests/{ => frontend}/persistence-responses.cjs | 2 +- tests/{ => frontend}/playback-continuation.cjs | 0 tests/{ => frontend}/playback-controls.cjs | 0 tests/{ => frontend}/playback-failures.cjs | 0 tests/{ => frontend}/playback-lifecycle.cjs | 0 .../recording-deletion-confirmation.cjs | 0 tests/{ => frontend}/session-expiry.cjs | 0 .../{ => frontend}/timeline-camera-filter.cjs | 0 tests/{ => frontend}/timeline-canvas.cjs | 0 tests/{ => frontend}/timeline-geometry.cjs | 2 +- tests/{ => frontend}/toast-text.cjs | 0 timeline_camera_filter_frontend_test.go | 2 +- timeline_canvas_frontend_test.go | 2 +- timeline_geometry_frontend_test.go | 2 +- toast_text_frontend_test.go | 2 +- 86 files changed, 69 insertions(+), 68 deletions(-) rename tests/{ => acceptance}/active-container-storage.sh (98%) rename tests/{ => acceptance}/browser_ci_diagnostics.py (100%) rename tests/{ => acceptance}/browser_network_ready.py (100%) rename tests/{ => acceptance}/browser_playback_control.py (100%) rename tests/{ => acceptance}/browser_playback_edges.py (100%) rename tests/{ => acceptance}/browser_playback_transport.py (100%) rename tests/{ => acceptance}/capture-copy-media.py (100%) rename tests/{ => acceptance}/core-ci-evidence.sh (94%) rename tests/{ => acceptance}/core_ci_evidence.py (100%) rename tests/{ => acceptance}/correspondence_assessment.py (100%) rename tests/{ => acceptance}/prepared_export_protocol.py (100%) rename tests/{ => acceptance}/qualify_ingestion_time.py (98%) rename tests/{ => acceptance}/runtime-browser-acceptance.py (100%) rename tests/{ => acceptance}/runtime-browser-acceptance.sh (92%) rename tests/{ => acceptance}/runtime-browser-expanded.py (100%) rename tests/{ => acceptance}/runtime-export-acceptance.sh (92%) rename tests/{ => acceptance}/runtime_export_acceptance.py (100%) rename tests/{ => acceptance}/runtime_export_diagnostics.py (100%) rename tests/{ => acceptance}/runtime_export_writer_observer.py (100%) rename tests/{ => acceptance}/test_browser_ci_diagnostics.py (100%) rename tests/{ => acceptance}/test_browser_network_ready.py (100%) rename tests/{ => acceptance}/test_browser_playback_control.py (97%) rename tests/{ => acceptance}/test_browser_playback_edges.py (100%) rename tests/{ => acceptance}/test_browser_playback_transport.py (100%) rename tests/{ => acceptance}/test_core_ci_evidence.py (99%) rename tests/{ => acceptance}/test_correspondence_assessment.py (100%) rename tests/{ => acceptance}/test_prepared_export_protocol.py (100%) rename tests/{ => acceptance}/test_runtime_export_acceptance.py (100%) rename tests/{ => acceptance}/test_runtime_export_diagnostics.py (98%) rename tests/{ => acceptance}/test_runtime_export_observer_exit.py (100%) rename tests/{ => acceptance}/test_runtime_export_writer_observer.py (100%) rename tests/{ => frontend}/camera-removal-confirmation.cjs (100%) rename tests/{ => frontend}/download-entrypoints.cjs (100%) rename tests/{ => frontend}/event-clear-confirmation.cjs (100%) rename tests/{ => frontend}/event-navigation.cjs (100%) rename tests/{ => frontend}/event-rendering.cjs (100%) rename tests/{ => frontend}/export-mode-ui.cjs (100%) rename tests/{ => frontend}/export-queue-details.cjs (100%) rename tests/{ => frontend}/export-range-controls.cjs (100%) rename tests/{ => frontend}/export-ui-fixture.cjs (99%) rename tests/{ => frontend}/export-ui.cjs (99%) rename tests/{ => frontend}/live-stream-names.cjs (100%) rename tests/{ => frontend}/orphan-cleanup-reporting.cjs (100%) rename tests/{ => frontend}/persistence-responses.cjs (98%) rename tests/{ => frontend}/playback-continuation.cjs (100%) rename tests/{ => frontend}/playback-controls.cjs (100%) rename tests/{ => frontend}/playback-failures.cjs (100%) rename tests/{ => frontend}/playback-lifecycle.cjs (100%) rename tests/{ => frontend}/recording-deletion-confirmation.cjs (100%) rename tests/{ => frontend}/session-expiry.cjs (100%) rename tests/{ => frontend}/timeline-camera-filter.cjs (100%) rename tests/{ => frontend}/timeline-canvas.cjs (100%) rename tests/{ => frontend}/timeline-geometry.cjs (97%) rename tests/{ => frontend}/toast-text.cjs (100%) diff --git a/.github/workflows/prepared-export-browser.yml b/.github/workflows/prepared-export-browser.yml index e765d70..1ff87ad 100644 --- a/.github/workflows/prepared-export-browser.yml +++ b/.github/workflows/prepared-export-browser.yml @@ -43,8 +43,8 @@ jobs: - name: Protocol regressions and real HTTPS/browser acceptance run: | . "$RUNNER_TEMP/export-browser-venv/bin/activate" - python -m unittest discover -s tests -p 'test_prepared_export_protocol.py' -v - GITHUB_SHA="$CHECKPOINT_SHA" bash tests/runtime-browser-acceptance.sh simplenvr-export-test "$RUNNER_TEMP/prepared-export-browser" + python -m unittest discover -s tests/acceptance -p 'test_prepared_export_protocol.py' -v + GITHUB_SHA="$CHECKPOINT_SHA" bash tests/acceptance/runtime-browser-acceptance.sh simplenvr-export-test "$RUNNER_TEMP/prepared-export-browser" - name: Retain media, network, browser and container evidence if: always() uses: actions/upload-artifact@v4 diff --git a/.github/workflows/prepared-export-go.yml b/.github/workflows/prepared-export-go.yml index 5514a0c..d32ea1d 100644 --- a/.github/workflows/prepared-export-go.yml +++ b/.github/workflows/prepared-export-go.yml @@ -39,7 +39,7 @@ jobs: - run: bash .github/scripts/ci-media-apt.sh update - run: bash .github/scripts/ci-media-apt.sh install ffmpeg - name: Prepared protocol regression tests - run: python3 -m unittest discover -s tests -p 'test_prepared_export_protocol.py' -v + run: python3 -m unittest discover -s tests/acceptance -p 'test_prepared_export_protocol.py' -v - name: Verify dependencies and build the exact checkout run: | go mod download @@ -47,7 +47,7 @@ jobs: git diff --exit-code -- go.mod go.sum go build ./... - name: Full race-enabled Go suite including Node and native media tests - run: GITHUB_SHA="$CHECKPOINT_SHA" bash tests/core-ci-evidence.sh "$RUNNER_TEMP/prepared-export-go" + run: GITHUB_SHA="$CHECKPOINT_SHA" bash tests/acceptance/core-ci-evidence.sh "$RUNNER_TEMP/prepared-export-go" - name: Static analysis if: always() run: go vet ./... diff --git a/.github/workflows/safety-ci.yml b/.github/workflows/safety-ci.yml index ae0f2a2..a58e495 100644 --- a/.github/workflows/safety-ci.yml +++ b/.github/workflows/safety-ci.yml @@ -31,8 +31,8 @@ jobs: persist-credentials: false - name: Browser CI diagnostic helper regression tests run: | - python3 -m unittest discover -s tests -p 'test_browser_ci_diagnostics.py' -v - python3 -m unittest discover -s tests -p 'test_browser_network_ready.py' -v + python3 -m unittest discover -s tests/acceptance -p 'test_browser_ci_diagnostics.py' -v + python3 -m unittest discover -s tests/acceptance -p 'test_browser_network_ready.py' -v - uses: actions/setup-go@v5 with: go-version: '1.26.x' @@ -51,10 +51,10 @@ jobs: - name: Build run: go build ./... - name: Core evidence assessor regression tests - run: python3 -m unittest discover -s tests -p 'test_core_ci_evidence.py' -v + run: python3 -m unittest discover -s tests/acceptance -p 'test_core_ci_evidence.py' -v - name: Race-enabled tests including media and shutdown lifecycle shell: bash - run: GITHUB_SHA="$CHECKPOINT_SHA" bash tests/core-ci-evidence.sh "$RUNNER_TEMP/simplenvr-core-evidence" + run: GITHUB_SHA="$CHECKPOINT_SHA" bash tests/acceptance/core-ci-evidence.sh "$RUNNER_TEMP/simplenvr-core-evidence" - name: Retain core test execution evidence even on failure if: always() uses: actions/upload-artifact@v4 @@ -100,7 +100,7 @@ jobs: run: docker build -t simplenvr-safety-test . - name: Active runtime-container recording, SIGTERM and restart intent shell: bash - run: GITHUB_SHA="$CHECKPOINT_SHA" bash tests/active-container-storage.sh simplenvr-safety-test + run: GITHUB_SHA="$CHECKPOINT_SHA" bash tests/acceptance/active-container-storage.sh simplenvr-safety-test - name: Runtime container SIGTERM smoke test shell: bash run: | @@ -126,7 +126,7 @@ jobs: - name: Runtime export backpressure, disconnect, SIGTERM and restart timeout-minutes: 6 shell: bash - run: GITHUB_SHA="$CHECKPOINT_SHA" bash tests/runtime-export-acceptance.sh simplenvr-safety-test "$RUNNER_TEMP/simplenvr-export-evidence" + run: GITHUB_SHA="$CHECKPOINT_SHA" bash tests/acceptance/runtime-export-acceptance.sh simplenvr-safety-test "$RUNNER_TEMP/simplenvr-export-evidence" - name: Retain runtime-export evidence even on failure if: always() uses: actions/upload-artifact@v4 @@ -173,7 +173,7 @@ jobs: run: | set -euo pipefail . "$RUNNER_TEMP/simplenvr-browser-venv/bin/activate" - GITHUB_SHA="$CHECKPOINT_SHA" bash tests/runtime-browser-acceptance.sh simplenvr-safety-test "$RUNNER_TEMP/simplenvr-browser-evidence" + GITHUB_SHA="$CHECKPOINT_SHA" bash tests/acceptance/runtime-browser-acceptance.sh simplenvr-safety-test "$RUNNER_TEMP/simplenvr-browser-evidence" - name: Retain runtime-browser acceptance evidence if: always() uses: actions/upload-artifact@v4 @@ -238,13 +238,13 @@ jobs: git diff --exit-code -- go.mod go.sum - name: Evidence assessment regression tests if: always() - run: python3 -m unittest discover -s tests -p 'test_correspondence_assessment.py' -v + run: python3 -m unittest discover -s tests/acceptance -p 'test_correspondence_assessment.py' -v - name: Assess full adapter and native prebuffer evidence if: always() shell: bash run: | set -euo pipefail - python3 tests/correspondence_assessment.py "$RUNNER_TEMP/correspondence-resources" \ + python3 tests/acceptance/correspondence_assessment.py "$RUNNER_TEMP/correspondence-resources" \ --expected-head "$CHECKPOINT_SHA" \ --output "$RUNNER_TEMP/correspondence-resources/assessment.json" \ --summary "$RUNNER_TEMP/correspondence-resources/assessment.md" diff --git a/camera_removal_confirmation_frontend_test.go b/camera_removal_confirmation_frontend_test.go index 2dbc383..224da38 100644 --- a/camera_removal_confirmation_frontend_test.go +++ b/camera_removal_confirmation_frontend_test.go @@ -3,5 +3,5 @@ package main import "testing" func TestFrontendCameraRemovalConfirmation(t *testing.T) { - runFrontendRegression(t, "tests/camera-removal-confirmation.cjs", "UTC") + runFrontendRegression(t, "tests/frontend/camera-removal-confirmation.cjs", "UTC") } diff --git a/docs/PREPARED_EXPORT_VERIFICATION.md b/docs/PREPARED_EXPORT_VERIFICATION.md index 1c83f5a..6ecee31 100644 --- a/docs/PREPARED_EXPORT_VERIFICATION.md +++ b/docs/PREPARED_EXPORT_VERIFICATION.md @@ -41,4 +41,4 @@ Passing synthetic acceptance is not production-camera, full-resolution, multi-Gi The live browser fixture has a single camera, so queuing several cameras from the UI in one request and the 8-camera client limit are covered by the Node UI tests, not by live Chrome. The server's capacity limit is exercised live through the API, with several jobs for the same camera. -The older routed-response harness `tests/browser-export-acceptance.py` has been removed. It targeted the retired direct-download flow and was not run by any workflow. The live-runtime entrypoint is `tests/runtime-browser-acceptance.py`, invoked through the expanded playback runner. +The older routed-response harness `tests/browser-export-acceptance.py` has been removed. It targeted the retired direct-download flow and was not run by any workflow. The live-runtime entrypoint is `tests/acceptance/runtime-browser-acceptance.py`, invoked through the expanded playback runner. diff --git a/docs/REPOSITORY_LAYOUT.md b/docs/REPOSITORY_LAYOUT.md index d246248..a59aab6 100644 --- a/docs/REPOSITORY_LAYOUT.md +++ b/docs/REPOSITORY_LAYOUT.md @@ -7,7 +7,8 @@ inventory in the last batch. - `cmd/simplenvr/` - all Go sources and Go tests (`package main`, unchanged) - `web/templates/`, `web/static/` - HTML templates and static assets -- `tests/frontend/`, `tests/runtime/`, `tests/ci/` - Node suites, runtime acceptance scripts, CI helpers and their unit tests +- `tests/frontend/` - Node (`*.cjs`) frontend suites +- `tests/acceptance/` - Python helpers and their unit tests, and the shell acceptance scripts - `tests/fixtures/`, `tests/evidence/` - unchanged - `docs/` - documentation, including `docs/compose/` for Compose examples - `.github/` - workflows and scripts (stay in place) diff --git a/docs/STORAGE_DEPLOYMENT_BOUNDARIES.md b/docs/STORAGE_DEPLOYMENT_BOUNDARIES.md index dbe0210..37ca74c 100644 --- a/docs/STORAGE_DEPLOYMENT_BOUNDARIES.md +++ b/docs/STORAGE_DEPLOYMENT_BOUNDARIES.md @@ -41,7 +41,7 @@ It creates only a uniquely named synthetic scratch directory, then removes that ## Active runtime-container CI fixture -The added CI step builds on the unchanged runtime Dockerfile and runs tests/active-container-storage.sh against that exact CI-built image. It requires active continuous and event-buffer FFmpeg processes, continuous output bytes and at least two prebuffer segments before SIGTERM. It checks clean container exit, persisted restart intent for both cameras, a new nonempty published partial per stop, transient-buffer cleanup and byte-identical synthetic retained event inputs/checkpoints. It repeats start/stop in the same container to exercise persisted restart intent. +The added CI step builds on the unchanged runtime Dockerfile and runs tests/acceptance/active-container-storage.sh against that exact CI-built image. It requires active continuous and event-buffer FFmpeg processes, continuous output bytes and at least two prebuffer segments before SIGTERM. It checks clean container exit, persisted restart intent for both cameras, a new nonempty published partial per stop, transient-buffer cleanup and byte-identical synthetic retained event inputs/checkpoints. It repeats start/stop in the same container to exercise persisted restart intent. The fixture uses the real application, Alpine runtime and real FFmpeg, a read-only root, writable recordings/certs/tmp mounts, dropped capabilities except NET_BIND_SERVICE, no-new-privileges and no networking. A wrapper replaces RTSP input with a paced looping synthetic file. It does not validate Dahua RTSP disconnect/reconnect, queued event capture/assembly in the runtime image, authenticated export traffic, genuine browser behavior, physical storage or production mount-loss handling. It checks published partial presence, not complete footage. Synthetic fixture directories are removed by the test; production evidence is never touched. Existing empty-camera SIGTERM smoke and all prior media/storage tests remain enabled. diff --git a/docs/audit/AUDIT_EVIDENCE_ADDENDUM_2026-11-16.md b/docs/audit/AUDIT_EVIDENCE_ADDENDUM_2026-11-16.md index 2b17534..a2a3cad 100644 --- a/docs/audit/AUDIT_EVIDENCE_ADDENDUM_2026-11-16.md +++ b/docs/audit/AUDIT_EVIDENCE_ADDENDUM_2026-11-16.md @@ -37,7 +37,7 @@ CSRF proof, cross-tab idempotency, or deletion permission. ## Failed runtime-export campaign at 926dd03 The user-provided output identifies the command as -`bash tests/runtime-export-acceptance.sh simplenvr-safety-test "$RUNNER_TEMP/simplenvr-export-evidence"`. +`bash tests/acceptance/runtime-export-acceptance.sh simplenvr-safety-test "$RUNNER_TEMP/simplenvr-export-evidence"`. | Campaign case | Reported state | | --- | --- | diff --git a/docs/audit/EVENT_CORRESPONDENCE_EVIDENCE_ASSESSMENT.md b/docs/audit/EVENT_CORRESPONDENCE_EVIDENCE_ASSESSMENT.md index 7539aa6..71ab5a1 100644 --- a/docs/audit/EVENT_CORRESPONDENCE_EVIDENCE_ASSESSMENT.md +++ b/docs/audit/EVENT_CORRESPONDENCE_EVIDENCE_ASSESSMENT.md @@ -17,7 +17,7 @@ tail-latency claims. Background lifetime CPU is separate; zero kernel block operations do not prove zero logical reads. No host threshold is invented. Usage: -python3 tests/correspondence_assessment.py EXTRACTED_ARTIFACT_DIRECTORY \ +python3 tests/acceptance/correspondence_assessment.py EXTRACTED_ARTIFACT_DIRECTORY \ --expected-head FULL_COMMIT_SHA --output assessment.json --summary assessment.md The workflow runs regression tests and assessment after resource collection, diff --git a/docs/audit/EVENT_NVR_INGESTION_POLICY.md b/docs/audit/EVENT_NVR_INGESTION_POLICY.md index 5d3e924..9e2027f 100644 --- a/docs/audit/EVENT_NVR_INGESTION_POLICY.md +++ b/docs/audit/EVENT_NVR_INGESTION_POLICY.md @@ -51,7 +51,7 @@ or deployment is included. Run manually with stock ffmpeg/ffprobe and libx264/AAC available: - python3 tests/qualify_ingestion_time.py ingestion-qualification.json + python3 tests/acceptance/qualify_ingestion_time.py ingestion-qualification.json This developer tool generates three seconds of H.264 B-frames and AAC and sends it over loopback UDP/MPEG-TS with deliberately non-UTC source timestamps. It compares diff --git a/docs/audit/EXPORT_UI.md b/docs/audit/EXPORT_UI.md index cb0737c..0801b5f 100644 --- a/docs/audit/EXPORT_UI.md +++ b/docs/audit/EXPORT_UI.md @@ -24,4 +24,4 @@ Server reason codes (output_limit, estimate_exceeded, deadline_exceeded, empty_o ## Tests and limits -Node tests (tests/export-ui.cjs, tests/export-mode-ui.cjs, tests/export-range-controls.cjs, tests/export-queue-details.cjs, tests/download-entrypoints.cjs) exercise the real module with a stub DOM, the real timeline geometry helper and stubbed fetch/streams. They are not browser tests. tests/runtime-browser-acceptance.py drives the panel in Chrome against a container in CI, including the queue list and its download link, Clear all, the range handles with a real mouse and keyboard, and the server's capacity limit. Browser download restrictions, filesystem failures and media completeness of saved files remain unverified. Real-browser/authenticated export integration, storage-failure validation and final whole-branch review remain required under AUDIT_ACCEPTANCE.md. +Node tests (tests/frontend/export-ui.cjs, tests/frontend/export-mode-ui.cjs, tests/frontend/export-range-controls.cjs, tests/frontend/export-queue-details.cjs, tests/frontend/download-entrypoints.cjs) exercise the real module with a stub DOM, the real timeline geometry helper and stubbed fetch/streams. They are not browser tests. tests/acceptance/runtime-browser-acceptance.py drives the panel in Chrome against a container in CI, including the queue list and its download link, Clear all, the range handles with a real mouse and keyboard, and the server's capacity limit. Browser download restrictions, filesystem failures and media completeness of saved files remain unverified. Real-browser/authenticated export integration, storage-failure validation and final whole-branch review remain required under AUDIT_ACCEPTANCE.md. diff --git a/docs/audit/RUNTIME_BROWSER_ACCEPTANCE.md b/docs/audit/RUNTIME_BROWSER_ACCEPTANCE.md index badc0b3..ce9c2e8 100644 --- a/docs/audit/RUNTIME_BROWSER_ACCEPTANCE.md +++ b/docs/audit/RUNTIME_BROWSER_ACCEPTANCE.md @@ -34,7 +34,7 @@ CI uploads the commit/image/browser report, saved synthetic whole-copy and trim For an explicit local run with Docker, the image, Python Playwright/Chromium and host FFmpeg installed: - bash tests/runtime-browser-acceptance.sh IMAGE EVIDENCE_DIRECTORY + bash tests/acceptance/runtime-browser-acceptance.sh IMAGE EVIDENCE_DIRECTORY The driver generates and cleans its own application state. It does not run against an arbitrary existing production server. It requires sudo for synthetic container-owned state cleanup. Do not point its fixture storage at deployment evidence. diff --git a/docs/audit/RUNTIME_EXPORT_BACKPRESSURE_ACCEPTANCE.md b/docs/audit/RUNTIME_EXPORT_BACKPRESSURE_ACCEPTANCE.md index a149c9d..e633452 100644 --- a/docs/audit/RUNTIME_EXPORT_BACKPRESSURE_ACCEPTANCE.md +++ b/docs/audit/RUNTIME_EXPORT_BACKPRESSURE_ACCEPTANCE.md @@ -7,11 +7,11 @@ defect is claimed and no production implementation is changed. ## Integrated batch -- tests/runtime-export-acceptance.sh owns an isolated synthetic state directory, +- tests/acceptance/runtime-export-acceptance.sh owns an isolated synthetic state directory, fixture generator, password initializer and hardened runtime container. -- tests/runtime_export_acceptance.py exercises authenticated real HTTPS exports, +- tests/acceptance/runtime_export_acceptance.py exercises authenticated real HTTPS exports, bounded ownership observations, disconnect, SIGTERM, persistence and restart. -- tests/test_runtime_export_acceptance.py contains 22 tooling regression methods. +- tests/acceptance/test_runtime_export_acceptance.py contains 22 tooling regression methods. - .github/workflows/safety-ci.yml runs the campaign as a mandatory core step after the existing recording/restart and SIGTERM smoke checks, then retains evidence with always(). The existing aggregate requires core. Both isolated Chrome diff --git a/event_clear_confirmation_frontend_test.go b/event_clear_confirmation_frontend_test.go index 3debbf5..f6ad6bd 100644 --- a/event_clear_confirmation_frontend_test.go +++ b/event_clear_confirmation_frontend_test.go @@ -3,5 +3,5 @@ package main import "testing" func TestFrontendEventClearConfirmation(t *testing.T) { - runFrontendRegression(t, "tests/event-clear-confirmation.cjs", "UTC") + runFrontendRegression(t, "tests/frontend/event-clear-confirmation.cjs", "UTC") } diff --git a/export_mode_ui_test.go b/export_mode_ui_test.go index e5117cd..f961a6a 100644 --- a/export_mode_ui_test.go +++ b/export_mode_ui_test.go @@ -4,6 +4,6 @@ import "testing" func TestPreparedExportModeUI(t *testing.T) { for _,zone:=range []string{"UTC","America/Chicago"} { - t.Run(zone,func(t *testing.T){runFrontendRegression(t,"tests/export-mode-ui.cjs",zone)}) + t.Run(zone,func(t *testing.T){runFrontendRegression(t,"tests/frontend/export-mode-ui.cjs",zone)}) } } diff --git a/export_queue_details_frontend_test.go b/export_queue_details_frontend_test.go index 59839a4..abbda5d 100644 --- a/export_queue_details_frontend_test.go +++ b/export_queue_details_frontend_test.go @@ -4,6 +4,6 @@ import "testing" func TestPreparedExportQueueDetailsUI(t *testing.T) { for _,zone:=range []string{"UTC","America/Chicago"} { - t.Run(zone,func(t *testing.T){runFrontendRegression(t,"tests/export-queue-details.cjs",zone)}) + t.Run(zone,func(t *testing.T){runFrontendRegression(t,"tests/frontend/export-queue-details.cjs",zone)}) } } diff --git a/export_range_controls_frontend_test.go b/export_range_controls_frontend_test.go index 4a535c7..4372262 100644 --- a/export_range_controls_frontend_test.go +++ b/export_range_controls_frontend_test.go @@ -4,6 +4,6 @@ import "testing" func TestExportRangeControlsFrontend(t *testing.T) { for _,zone:=range []string{"UTC","America/Chicago"} { - t.Run(zone,func(t *testing.T){runFrontendRegression(t,"tests/export-range-controls.cjs",zone)}) + t.Run(zone,func(t *testing.T){runFrontendRegression(t,"tests/frontend/export-range-controls.cjs",zone)}) } } diff --git a/frontend_security_test.go b/frontend_security_test.go index 9041aeb..862eb54 100644 --- a/frontend_security_test.go +++ b/frontend_security_test.go @@ -22,10 +22,10 @@ func runFrontendRegression(t *testing.T,script,zone string) { if err!=nil {t.Fatalf("frontend regressions failed (%s, %s): %v\n%s",script,zone,err,output)} } -func TestFrontendEventRendering(t *testing.T) {runFrontendRegression(t,"tests/event-rendering.cjs","UTC")} -func TestFrontendExportUI(t *testing.T) {runFrontendRegression(t,"tests/export-ui.cjs","UTC")} +func TestFrontendEventRendering(t *testing.T) {runFrontendRegression(t,"tests/frontend/event-rendering.cjs","UTC")} +func TestFrontendExportUI(t *testing.T) {runFrontendRegression(t,"tests/frontend/export-ui.cjs","UTC")} func TestFrontendEventNavigation(t *testing.T) { for _,zone:=range []string{"UTC","Asia/Hong_Kong","America/Chicago"} { - t.Run(zone,func(t *testing.T){runFrontendRegression(t,"tests/event-navigation.cjs",zone)}) + t.Run(zone,func(t *testing.T){runFrontendRegression(t,"tests/frontend/event-navigation.cjs",zone)}) } } diff --git a/legacy_download_test.go b/legacy_download_test.go index 21c6aea..8b3cc59 100644 --- a/legacy_download_test.go +++ b/legacy_download_test.go @@ -29,4 +29,4 @@ func TestNoLegacyDownloadCallsInAssets(t *testing.T) { if !bytes.Contains(page,[]byte(`onclick="startExportDownloads()"`)) {t.Fatal("monitored export entry point is not wired to the page")} } -func TestFrontendDownloadEntryPoints(t *testing.T) {runFrontendRegression(t,"tests/download-entrypoints.cjs","UTC")} +func TestFrontendDownloadEntryPoints(t *testing.T) {runFrontendRegression(t,"tests/frontend/download-entrypoints.cjs","UTC")} diff --git a/live_stream_names_frontend_test.go b/live_stream_names_frontend_test.go index 7aefbbf..c67298b 100644 --- a/live_stream_names_frontend_test.go +++ b/live_stream_names_frontend_test.go @@ -3,5 +3,5 @@ package main import "testing" func TestFrontendLiveStreamNames(t *testing.T) { - runFrontendRegression(t, "tests/live-stream-names.cjs", "UTC") + runFrontendRegression(t, "tests/frontend/live-stream-names.cjs", "UTC") } diff --git a/orphan_cleanup_reporting_frontend_test.go b/orphan_cleanup_reporting_frontend_test.go index 08c925a..be3ce15 100644 --- a/orphan_cleanup_reporting_frontend_test.go +++ b/orphan_cleanup_reporting_frontend_test.go @@ -3,5 +3,5 @@ package main import "testing" func TestFrontendOrphanCleanupReporting(t *testing.T) { - runFrontendRegression(t, "tests/orphan-cleanup-reporting.cjs", "UTC") + runFrontendRegression(t, "tests/frontend/orphan-cleanup-reporting.cjs", "UTC") } diff --git a/persistence_responses_frontend_test.go b/persistence_responses_frontend_test.go index b9e91d8..2507c36 100644 --- a/persistence_responses_frontend_test.go +++ b/persistence_responses_frontend_test.go @@ -3,5 +3,5 @@ package main import "testing" func TestFrontendPersistenceResponses(t *testing.T) { - runFrontendRegression(t, "tests/persistence-responses.cjs", "UTC") + runFrontendRegression(t, "tests/frontend/persistence-responses.cjs", "UTC") } diff --git a/playback_continuation_frontend_test.go b/playback_continuation_frontend_test.go index 7556711..8f2567e 100644 --- a/playback_continuation_frontend_test.go +++ b/playback_continuation_frontend_test.go @@ -5,7 +5,7 @@ import "testing" func TestFrontendPlaybackContinuation(t *testing.T) { for _, zone := range []string{"UTC", "Asia/Hong_Kong", "America/Chicago"} { t.Run(zone, func(t *testing.T) { - runFrontendRegression(t, "tests/playback-continuation.cjs", zone) + runFrontendRegression(t, "tests/frontend/playback-continuation.cjs", zone) }) } } diff --git a/playback_controls_frontend_test.go b/playback_controls_frontend_test.go index 6e21d25..b1e2344 100644 --- a/playback_controls_frontend_test.go +++ b/playback_controls_frontend_test.go @@ -3,6 +3,6 @@ package main import "testing" func TestFrontendPlaybackControls(t *testing.T) { - runFrontendRegression(t, "tests/playback-controls.cjs", "UTC") - runFrontendRegression(t, "tests/playback-controls.cjs", "America/Chicago") + runFrontendRegression(t, "tests/frontend/playback-controls.cjs", "UTC") + runFrontendRegression(t, "tests/frontend/playback-controls.cjs", "America/Chicago") } diff --git a/playback_failures_frontend_test.go b/playback_failures_frontend_test.go index 74be9f0..01d9a20 100644 --- a/playback_failures_frontend_test.go +++ b/playback_failures_frontend_test.go @@ -3,6 +3,6 @@ package main import "testing" func TestFrontendPlaybackFailures(t *testing.T) { - runFrontendRegression(t, "tests/playback-failures.cjs", "UTC") - runFrontendRegression(t, "tests/playback-failures.cjs", "America/Chicago") + runFrontendRegression(t, "tests/frontend/playback-failures.cjs", "UTC") + runFrontendRegression(t, "tests/frontend/playback-failures.cjs", "America/Chicago") } diff --git a/playback_lifecycle_frontend_test.go b/playback_lifecycle_frontend_test.go index 4ae4b9c..f914025 100644 --- a/playback_lifecycle_frontend_test.go +++ b/playback_lifecycle_frontend_test.go @@ -3,5 +3,5 @@ package main import "testing" func TestFrontendPlaybackLifecycle(t *testing.T) { - runFrontendRegression(t, "tests/playback-lifecycle.cjs", "UTC") + runFrontendRegression(t, "tests/frontend/playback-lifecycle.cjs", "UTC") } diff --git a/recording_deletion_confirmation_frontend_test.go b/recording_deletion_confirmation_frontend_test.go index d8ee2a9..e942e92 100644 --- a/recording_deletion_confirmation_frontend_test.go +++ b/recording_deletion_confirmation_frontend_test.go @@ -3,5 +3,5 @@ package main import "testing" func TestFrontendRecordingDeletionConfirmation(t *testing.T) { - runFrontendRegression(t, "tests/recording-deletion-confirmation.cjs", "UTC") + runFrontendRegression(t, "tests/frontend/recording-deletion-confirmation.cjs", "UTC") } diff --git a/session_expiry_frontend_test.go b/session_expiry_frontend_test.go index ecdbe3c..09d70fd 100644 --- a/session_expiry_frontend_test.go +++ b/session_expiry_frontend_test.go @@ -3,5 +3,5 @@ package main import "testing" func TestFrontendSessionExpiry(t *testing.T) { - runFrontendRegression(t, "tests/session-expiry.cjs", "UTC") + runFrontendRegression(t, "tests/frontend/session-expiry.cjs", "UTC") } diff --git a/tests/active-container-storage.sh b/tests/acceptance/active-container-storage.sh similarity index 98% rename from tests/active-container-storage.sh rename to tests/acceptance/active-container-storage.sh index 0de96fe..0a97c99 100644 --- a/tests/active-container-storage.sh +++ b/tests/acceptance/active-container-storage.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -euo pipefail -image=${1:?usage: bash tests/active-container-storage.sh IMAGE} +image=${1:?usage: bash tests/acceptance/active-container-storage.sh IMAGE} work=$(mktemp -d "${RUNNER_TEMP:-/tmp}/simplenvr-active-container.XXXXXX") state=$work/state fixture=$work/fixture diff --git a/tests/browser_ci_diagnostics.py b/tests/acceptance/browser_ci_diagnostics.py similarity index 100% rename from tests/browser_ci_diagnostics.py rename to tests/acceptance/browser_ci_diagnostics.py diff --git a/tests/browser_network_ready.py b/tests/acceptance/browser_network_ready.py similarity index 100% rename from tests/browser_network_ready.py rename to tests/acceptance/browser_network_ready.py diff --git a/tests/browser_playback_control.py b/tests/acceptance/browser_playback_control.py similarity index 100% rename from tests/browser_playback_control.py rename to tests/acceptance/browser_playback_control.py diff --git a/tests/browser_playback_edges.py b/tests/acceptance/browser_playback_edges.py similarity index 100% rename from tests/browser_playback_edges.py rename to tests/acceptance/browser_playback_edges.py diff --git a/tests/browser_playback_transport.py b/tests/acceptance/browser_playback_transport.py similarity index 100% rename from tests/browser_playback_transport.py rename to tests/acceptance/browser_playback_transport.py diff --git a/tests/capture-copy-media.py b/tests/acceptance/capture-copy-media.py similarity index 100% rename from tests/capture-copy-media.py rename to tests/acceptance/capture-copy-media.py diff --git a/tests/core-ci-evidence.sh b/tests/acceptance/core-ci-evidence.sh similarity index 94% rename from tests/core-ci-evidence.sh rename to tests/acceptance/core-ci-evidence.sh index d2599c9..3f675a6 100644 --- a/tests/core-ci-evidence.sh +++ b/tests/acceptance/core-ci-evidence.sh @@ -8,7 +8,7 @@ expected_head=${GITHUB_SHA:?GitHub head required} package=$(go list .) media="$evidence/bframe-media" mkdir -p "$media/bin" -helper=$(pwd)/tests/capture-copy-media.py +helper=$(pwd)/tests/acceptance/capture-copy-media.py for tool in ffmpeg ffprobe; do printf '#!/bin/sh\nexec python3 "$SIMPLENVR_CAPTURE_HELPER" %s "$@"\n' "$tool" > "$media/bin/$tool" chmod 700 "$media/bin/$tool" @@ -47,7 +47,7 @@ with open(path,'w') as f: 'runtime_qualified':False,'cleanup_authorized':False},f,indent=2) f.write('\n') PY -python3 tests/core_ci_evidence.py "$evidence" --expected-head "$expected_head" +python3 tests/acceptance/core_ci_evidence.py "$evidence" --expected-head "$expected_head" test "$test_exit" -eq 0 test "$tee_exit" -eq 0 test "${focused_statuses[0]}" -eq 0 diff --git a/tests/core_ci_evidence.py b/tests/acceptance/core_ci_evidence.py similarity index 100% rename from tests/core_ci_evidence.py rename to tests/acceptance/core_ci_evidence.py diff --git a/tests/correspondence_assessment.py b/tests/acceptance/correspondence_assessment.py similarity index 100% rename from tests/correspondence_assessment.py rename to tests/acceptance/correspondence_assessment.py diff --git a/tests/prepared_export_protocol.py b/tests/acceptance/prepared_export_protocol.py similarity index 100% rename from tests/prepared_export_protocol.py rename to tests/acceptance/prepared_export_protocol.py diff --git a/tests/qualify_ingestion_time.py b/tests/acceptance/qualify_ingestion_time.py similarity index 98% rename from tests/qualify_ingestion_time.py rename to tests/acceptance/qualify_ingestion_time.py index 95e8b10..cc47575 100644 --- a/tests/qualify_ingestion_time.py +++ b/tests/acceptance/qualify_ingestion_time.py @@ -2,7 +2,7 @@ """Offline qualification of a CANDIDATE, not production ingestion-time support. Requires stock ffmpeg/ffprobe, libx264 and AAC. Uses generated media, temporary -files and loopback UDP only. Run: python3 tests/qualify_ingestion_time.py report.json +files and loopback UDP only. Run: python3 tests/acceptance/qualify_ingestion_time.py report.json Exit 0 means this limited fixture passed, 1 means candidate unqualified, 2 means infrastructure/fixture failure. None of these outcomes certifies RTSP or coverage. """ diff --git a/tests/runtime-browser-acceptance.py b/tests/acceptance/runtime-browser-acceptance.py similarity index 100% rename from tests/runtime-browser-acceptance.py rename to tests/acceptance/runtime-browser-acceptance.py diff --git a/tests/runtime-browser-acceptance.sh b/tests/acceptance/runtime-browser-acceptance.sh similarity index 92% rename from tests/runtime-browser-acceptance.sh rename to tests/acceptance/runtime-browser-acceptance.sh index d530cd7..b976b1d 100644 --- a/tests/runtime-browser-acceptance.sh +++ b/tests/acceptance/runtime-browser-acceptance.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -euo pipefail -image=${1:?usage: bash tests/runtime-browser-acceptance.sh IMAGE EVIDENCE_DIR} +image=${1:?usage: bash tests/acceptance/runtime-browser-acceptance.sh IMAGE EVIDENCE_DIR} evidence=${2:?evidence directory required} work=$(mktemp -d "${RUNNER_TEMP:-/tmp}/simplenvr-runtime-browser.XXXXXX") state=$work/state @@ -16,7 +16,7 @@ cleanup() { sudo rm -rf -- "$work" } trap cleanup EXIT -timeout --kill-after=2 20 python3 -m unittest discover -s tests -p 'test_browser_playback*.py' -v \ +timeout --kill-after=2 20 python3 -m unittest discover -s tests/acceptance -p 'test_browser_playback*.py' -v \ 2>&1 | tee "$evidence/playback-edge-unit-tests.log" # Deterministic non-reordered video exercises the supported subsection-copy path. # The Go suite separately retains reordered-video refusal and accurate rendering. @@ -74,9 +74,9 @@ port=$(docker inspect -f '{{(index (index .NetworkSettings.Ports "443/tcp") 0).H image_id=$(docker image inspect -f '{{.Id}}' "$image") host_ifindex=$(docker exec "$name" cat /sys/class/net/eth0/iflink) [[ "$host_ifindex" =~ ^[1-9][0-9]*$ ]] -timeout --kill-after=10 340 python3 tests/browser_network_ready.py \ +timeout --kill-after=10 340 python3 tests/acceptance/browser_network_ready.py \ --ifindex "$host_ifindex" --evidence "$evidence" -- \ - python3 tests/runtime-browser-expanded.py \ + python3 tests/acceptance/runtime-browser-expanded.py \ --origin "https://127.0.0.1:$port" --container "$name" \ --commit "${GITHUB_SHA:-$(git rev-parse HEAD)}" --image-id "$image_id" --evidence "$evidence" docker stop --timeout 75 "$name" >/dev/null diff --git a/tests/runtime-browser-expanded.py b/tests/acceptance/runtime-browser-expanded.py similarity index 100% rename from tests/runtime-browser-expanded.py rename to tests/acceptance/runtime-browser-expanded.py diff --git a/tests/runtime-export-acceptance.sh b/tests/acceptance/runtime-export-acceptance.sh similarity index 92% rename from tests/runtime-export-acceptance.sh rename to tests/acceptance/runtime-export-acceptance.sh index 210ea5c..c721349 100644 --- a/tests/runtime-export-acceptance.sh +++ b/tests/acceptance/runtime-export-acceptance.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -euo pipefail -image=${1:?usage: bash tests/runtime-export-acceptance.sh IMAGE EVIDENCE_DIR} +image=${1:?usage: bash tests/acceptance/runtime-export-acceptance.sh IMAGE EVIDENCE_DIR} evidence=${2:?evidence directory required} work=$(mktemp -d "${RUNNER_TEMP:-/tmp}/simplenvr-runtime-export.XXXXXX") state=$work/state @@ -12,7 +12,7 @@ cleanup() { status=$? cleanup_failed=0 # Keep safe failure facts visible before disposable fixture teardown. - timeout --kill-after=2 5 python3 tests/runtime_export_diagnostics.py \ + timeout --kill-after=2 5 python3 tests/acceptance/runtime_export_diagnostics.py \ "$evidence/runtime-export-report.json" | tee "$evidence/runtime-export-console-summary.json" || cleanup_failed=1 # No raw auth/proc/network captures. Keep a bounded completion-marker count # even when the campaign fails before it can finish its JSON report. @@ -37,7 +37,7 @@ PY exit "$status" } trap cleanup EXIT -timeout --kill-after=2 20 python3 -m unittest discover -s tests -p 'test_runtime_export*.py' -v \ +timeout --kill-after=2 20 python3 -m unittest discover -s tests/acceptance -p 'test_runtime_export*.py' -v \ 2>&1 | tee "$evidence/runtime-export-tooling-tests.log" # Deliberately complex, bounded, video-only input. Generate with the exact # runtime image, before applying the pacing shim to application exports. @@ -77,7 +77,7 @@ docker run -d --name "$name" --label simplenvr.safety.fixture=runtime-export \ --mount "type=bind,src=$state,dst=/recordings" \ --mount "type=bind,src=$bin,dst=/fixture-bin,readonly" "$image" >/dev/null image_id=$(docker image inspect -f '{{.Id}}' "$image") -timeout --kill-after=10 240 python3 tests/runtime_export_acceptance.py \ +timeout --kill-after=10 240 python3 tests/acceptance/runtime_export_acceptance.py \ --container "$name" --state "$state" --evidence "$evidence" \ --commit "${GITHUB_SHA:-$(git rev-parse HEAD)}" --image-id "$image_id" test "$(docker inspect -f '{{.State.Running}}' "$name")" = false diff --git a/tests/runtime_export_acceptance.py b/tests/acceptance/runtime_export_acceptance.py similarity index 100% rename from tests/runtime_export_acceptance.py rename to tests/acceptance/runtime_export_acceptance.py diff --git a/tests/runtime_export_diagnostics.py b/tests/acceptance/runtime_export_diagnostics.py similarity index 100% rename from tests/runtime_export_diagnostics.py rename to tests/acceptance/runtime_export_diagnostics.py diff --git a/tests/runtime_export_writer_observer.py b/tests/acceptance/runtime_export_writer_observer.py similarity index 100% rename from tests/runtime_export_writer_observer.py rename to tests/acceptance/runtime_export_writer_observer.py diff --git a/tests/test_browser_ci_diagnostics.py b/tests/acceptance/test_browser_ci_diagnostics.py similarity index 100% rename from tests/test_browser_ci_diagnostics.py rename to tests/acceptance/test_browser_ci_diagnostics.py diff --git a/tests/test_browser_network_ready.py b/tests/acceptance/test_browser_network_ready.py similarity index 100% rename from tests/test_browser_network_ready.py rename to tests/acceptance/test_browser_network_ready.py diff --git a/tests/test_browser_playback_control.py b/tests/acceptance/test_browser_playback_control.py similarity index 97% rename from tests/test_browser_playback_control.py rename to tests/acceptance/test_browser_playback_control.py index 35bf8d0..c0985c4 100644 --- a/tests/test_browser_playback_control.py +++ b/tests/acceptance/test_browser_playback_control.py @@ -10,7 +10,7 @@ from browser_playback_control import template_contract, mark_failed_stages -ROOT = Path(__file__).resolve().parent.parent +ROOT = Path(__file__).resolve().parent.parent.parent class MarkupTests(unittest.TestCase): @@ -45,7 +45,7 @@ def test_failure_marks_only_running_stages(self): class AggregateTests(unittest.IsolatedAsyncioTestCase): def module(self): - spec=importlib.util.spec_from_file_location('browser_expanded_contract',ROOT/'tests/runtime-browser-expanded.py') + spec=importlib.util.spec_from_file_location('browser_expanded_contract',ROOT/'tests/acceptance/runtime-browser-expanded.py') module=importlib.util.module_from_spec(spec);spec.loader.exec_module(module) return module diff --git a/tests/test_browser_playback_edges.py b/tests/acceptance/test_browser_playback_edges.py similarity index 100% rename from tests/test_browser_playback_edges.py rename to tests/acceptance/test_browser_playback_edges.py diff --git a/tests/test_browser_playback_transport.py b/tests/acceptance/test_browser_playback_transport.py similarity index 100% rename from tests/test_browser_playback_transport.py rename to tests/acceptance/test_browser_playback_transport.py diff --git a/tests/test_core_ci_evidence.py b/tests/acceptance/test_core_ci_evidence.py similarity index 99% rename from tests/test_core_ci_evidence.py rename to tests/acceptance/test_core_ci_evidence.py index 6995d12..fcdf496 100644 --- a/tests/test_core_ci_evidence.py +++ b/tests/acceptance/test_core_ci_evidence.py @@ -159,7 +159,7 @@ def test_wrapper_preserves_exit_failure_and_head_mismatch(self): for name,body in programs.items(): path=bindir/name;path.write_text(body);path.chmod(0o700) wrapper=Path(m.__file__).with_name('core-ci-evidence.sh') - checkout=wrapper.parent.parent + checkout=wrapper.parent.parent.parent for mode in ('pass','test_failure','stale_head','tee_failure'): with self.subTest(mode=mode): evidence=self.root/('evidence-'+mode) diff --git a/tests/test_correspondence_assessment.py b/tests/acceptance/test_correspondence_assessment.py similarity index 100% rename from tests/test_correspondence_assessment.py rename to tests/acceptance/test_correspondence_assessment.py diff --git a/tests/test_prepared_export_protocol.py b/tests/acceptance/test_prepared_export_protocol.py similarity index 100% rename from tests/test_prepared_export_protocol.py rename to tests/acceptance/test_prepared_export_protocol.py diff --git a/tests/test_runtime_export_acceptance.py b/tests/acceptance/test_runtime_export_acceptance.py similarity index 100% rename from tests/test_runtime_export_acceptance.py rename to tests/acceptance/test_runtime_export_acceptance.py diff --git a/tests/test_runtime_export_diagnostics.py b/tests/acceptance/test_runtime_export_diagnostics.py similarity index 98% rename from tests/test_runtime_export_diagnostics.py rename to tests/acceptance/test_runtime_export_diagnostics.py index 2b7af20..fa6d73c 100644 --- a/tests/test_runtime_export_diagnostics.py +++ b/tests/acceptance/test_runtime_export_diagnostics.py @@ -109,7 +109,7 @@ def test_exact_exit_trap_preserves_failure_and_cleanup_accounting(self): for name in ("docker","sudo"):(binary/name).chmod(0o700) env=dict(os.environ,PATH=str(binary)+os.pathsep+os.environ["PATH"],DIAGNOSTIC_TEST_RM_FAIL="1" if fail else "0") script='set -euo pipefail\nevidence=$1\nwork=$2\nname=simplenvr-runtime-export-123\n'+cleanup+'trap cleanup EXIT\nexit "$3"\n' - result=subprocess.run(["bash","-c",script,"test",str(evidence),str(root),str(code)],cwd=path.parent.parent,env=env,capture_output=True,text=True,timeout=5) + result=subprocess.run(["bash","-c",script,"test",str(evidence),str(root),str(code)],cwd=path.parent.parent.parent,env=env,capture_output=True,text=True,timeout=5) self.assertEqual(result.returncode,1 if fail else code) self.assertIn('"diagnostic_only": true',result.stdout) self.assertEqual((evidence/"runtime-export-report.json").read_text(),raw) diff --git a/tests/test_runtime_export_observer_exit.py b/tests/acceptance/test_runtime_export_observer_exit.py similarity index 100% rename from tests/test_runtime_export_observer_exit.py rename to tests/acceptance/test_runtime_export_observer_exit.py diff --git a/tests/test_runtime_export_writer_observer.py b/tests/acceptance/test_runtime_export_writer_observer.py similarity index 100% rename from tests/test_runtime_export_writer_observer.py rename to tests/acceptance/test_runtime_export_writer_observer.py diff --git a/tests/camera-removal-confirmation.cjs b/tests/frontend/camera-removal-confirmation.cjs similarity index 100% rename from tests/camera-removal-confirmation.cjs rename to tests/frontend/camera-removal-confirmation.cjs diff --git a/tests/download-entrypoints.cjs b/tests/frontend/download-entrypoints.cjs similarity index 100% rename from tests/download-entrypoints.cjs rename to tests/frontend/download-entrypoints.cjs diff --git a/tests/event-clear-confirmation.cjs b/tests/frontend/event-clear-confirmation.cjs similarity index 100% rename from tests/event-clear-confirmation.cjs rename to tests/frontend/event-clear-confirmation.cjs diff --git a/tests/event-navigation.cjs b/tests/frontend/event-navigation.cjs similarity index 100% rename from tests/event-navigation.cjs rename to tests/frontend/event-navigation.cjs diff --git a/tests/event-rendering.cjs b/tests/frontend/event-rendering.cjs similarity index 100% rename from tests/event-rendering.cjs rename to tests/frontend/event-rendering.cjs diff --git a/tests/export-mode-ui.cjs b/tests/frontend/export-mode-ui.cjs similarity index 100% rename from tests/export-mode-ui.cjs rename to tests/frontend/export-mode-ui.cjs diff --git a/tests/export-queue-details.cjs b/tests/frontend/export-queue-details.cjs similarity index 100% rename from tests/export-queue-details.cjs rename to tests/frontend/export-queue-details.cjs diff --git a/tests/export-range-controls.cjs b/tests/frontend/export-range-controls.cjs similarity index 100% rename from tests/export-range-controls.cjs rename to tests/frontend/export-range-controls.cjs diff --git a/tests/export-ui-fixture.cjs b/tests/frontend/export-ui-fixture.cjs similarity index 99% rename from tests/export-ui-fixture.cjs rename to tests/frontend/export-ui-fixture.cjs index d7f7472..e042917 100644 --- a/tests/export-ui-fixture.cjs +++ b/tests/frontend/export-ui-fixture.cjs @@ -3,7 +3,7 @@ // DOMContentLoaded callbacks, and models the pointer and keyboard APIs used by handles. // HTML sinks and inline handlers throw so any HTML injection path fails the tests. const fs = require('node:fs'), vm = require('node:vm'), path = require('node:path'); -const root = path.join(__dirname, '..'); +const root = path.join(__dirname, '..', '..'); const source = fs.readFileSync(path.join(root, 'static/js/export-ui.js'), 'utf8'); const geometrySource = fs.readFileSync(path.join(root, 'static/js/timeline-geometry.js'), 'utf8'); const VIEW_START = Date.parse('2026-11-21T00:00:00Z'), VIEW_END = Date.parse('2026-11-22T00:00:00Z'); diff --git a/tests/export-ui.cjs b/tests/frontend/export-ui.cjs similarity index 99% rename from tests/export-ui.cjs rename to tests/frontend/export-ui.cjs index 8e22ec8..4e6a8a2 100644 --- a/tests/export-ui.cjs +++ b/tests/frontend/export-ui.cjs @@ -1,7 +1,7 @@ const assert = require('node:assert/strict'); const fs = require('node:fs'), path = require('node:path'); const {environment, letterId, view, response} = require('./export-ui-fixture.cjs'); -const source = fs.readFileSync(path.join(__dirname, '../static/js/export-ui.js'), 'utf8'); +const source = fs.readFileSync(path.join(__dirname, '../../static/js/export-ui.js'), 'utf8'); // Static security policy: no video buffering, no HTML sinks, no legacy approval flow. for (const banned of ['new Blob(', 'createObjectURL', '.blob()', 'arrayBuffer(', 'innerHTML', 'outerHTML', 'insertAdjacentHTML', 'document.write', diff --git a/tests/live-stream-names.cjs b/tests/frontend/live-stream-names.cjs similarity index 100% rename from tests/live-stream-names.cjs rename to tests/frontend/live-stream-names.cjs diff --git a/tests/orphan-cleanup-reporting.cjs b/tests/frontend/orphan-cleanup-reporting.cjs similarity index 100% rename from tests/orphan-cleanup-reporting.cjs rename to tests/frontend/orphan-cleanup-reporting.cjs diff --git a/tests/persistence-responses.cjs b/tests/frontend/persistence-responses.cjs similarity index 98% rename from tests/persistence-responses.cjs rename to tests/frontend/persistence-responses.cjs index 4ed779a..aa5947b 100644 --- a/tests/persistence-responses.cjs +++ b/tests/frontend/persistence-responses.cjs @@ -5,7 +5,7 @@ const vm = require('node:vm'); const sources = ['cameras.js', 'modals.js'].map(name => ({ name, - text: fs.readFileSync(path.join(__dirname, '..', 'static', 'js', name), 'utf8') + text: fs.readFileSync(path.join(__dirname, '..', '..', 'static', 'js', name), 'utf8') })); const html = '
Updated camera list
'; const intentMessage = 'Recording enabled; footage capture is not yet verified.'; diff --git a/tests/playback-continuation.cjs b/tests/frontend/playback-continuation.cjs similarity index 100% rename from tests/playback-continuation.cjs rename to tests/frontend/playback-continuation.cjs diff --git a/tests/playback-controls.cjs b/tests/frontend/playback-controls.cjs similarity index 100% rename from tests/playback-controls.cjs rename to tests/frontend/playback-controls.cjs diff --git a/tests/playback-failures.cjs b/tests/frontend/playback-failures.cjs similarity index 100% rename from tests/playback-failures.cjs rename to tests/frontend/playback-failures.cjs diff --git a/tests/playback-lifecycle.cjs b/tests/frontend/playback-lifecycle.cjs similarity index 100% rename from tests/playback-lifecycle.cjs rename to tests/frontend/playback-lifecycle.cjs diff --git a/tests/recording-deletion-confirmation.cjs b/tests/frontend/recording-deletion-confirmation.cjs similarity index 100% rename from tests/recording-deletion-confirmation.cjs rename to tests/frontend/recording-deletion-confirmation.cjs diff --git a/tests/session-expiry.cjs b/tests/frontend/session-expiry.cjs similarity index 100% rename from tests/session-expiry.cjs rename to tests/frontend/session-expiry.cjs diff --git a/tests/timeline-camera-filter.cjs b/tests/frontend/timeline-camera-filter.cjs similarity index 100% rename from tests/timeline-camera-filter.cjs rename to tests/frontend/timeline-camera-filter.cjs diff --git a/tests/timeline-canvas.cjs b/tests/frontend/timeline-canvas.cjs similarity index 100% rename from tests/timeline-canvas.cjs rename to tests/frontend/timeline-canvas.cjs diff --git a/tests/timeline-geometry.cjs b/tests/frontend/timeline-geometry.cjs similarity index 97% rename from tests/timeline-geometry.cjs rename to tests/frontend/timeline-geometry.cjs index b123b24..b9a35e1 100644 --- a/tests/timeline-geometry.cjs +++ b/tests/frontend/timeline-geometry.cjs @@ -1,6 +1,6 @@ 'use strict'; const assert = require('node:assert/strict'); -const g = require('../static/js/timeline-geometry.js'); +const g = require('../../static/js/timeline-geometry.js'); const expected = {'UTC':[24,24], 'Asia/Hong_Kong':[24,24], 'America/Chicago':[23,25]}; assert.ok(expected[process.env.TZ], 'configured test timezone required'); for (const [i, month] of [2,10].entries()) { diff --git a/tests/toast-text.cjs b/tests/frontend/toast-text.cjs similarity index 100% rename from tests/toast-text.cjs rename to tests/frontend/toast-text.cjs diff --git a/timeline_camera_filter_frontend_test.go b/timeline_camera_filter_frontend_test.go index 0e9c57d..d699a4e 100644 --- a/timeline_camera_filter_frontend_test.go +++ b/timeline_camera_filter_frontend_test.go @@ -3,5 +3,5 @@ package main import "testing" func TestFrontendTimelineCameraFilter(t *testing.T) { - runFrontendRegression(t, "tests/timeline-camera-filter.cjs", "UTC") + runFrontendRegression(t, "tests/frontend/timeline-camera-filter.cjs", "UTC") } diff --git a/timeline_canvas_frontend_test.go b/timeline_canvas_frontend_test.go index 3bd8cc9..03ac785 100644 --- a/timeline_canvas_frontend_test.go +++ b/timeline_canvas_frontend_test.go @@ -5,7 +5,7 @@ import "testing" func TestFrontendTimelineCanvas(t *testing.T) { for _, zone := range []string{"UTC", "Asia/Hong_Kong", "America/Chicago"} { t.Run(zone, func(t *testing.T) { - runFrontendRegression(t, "tests/timeline-canvas.cjs", zone) + runFrontendRegression(t, "tests/frontend/timeline-canvas.cjs", zone) }) } } diff --git a/timeline_geometry_frontend_test.go b/timeline_geometry_frontend_test.go index fbb0713..1912218 100644 --- a/timeline_geometry_frontend_test.go +++ b/timeline_geometry_frontend_test.go @@ -5,7 +5,7 @@ import "testing" func TestFrontendTimelineGeometry(t *testing.T) { for _, zone := range []string{"UTC", "Asia/Hong_Kong", "America/Chicago"} { t.Run(zone, func(t *testing.T) { - runFrontendRegression(t, "tests/timeline-geometry.cjs", zone) + runFrontendRegression(t, "tests/frontend/timeline-geometry.cjs", zone) }) } } diff --git a/toast_text_frontend_test.go b/toast_text_frontend_test.go index c82d309..086e38d 100644 --- a/toast_text_frontend_test.go +++ b/toast_text_frontend_test.go @@ -3,5 +3,5 @@ package main import "testing" func TestFrontendToastText(t *testing.T) { - runFrontendRegression(t, "tests/toast-text.cjs", "UTC") + runFrontendRegression(t, "tests/frontend/toast-text.cjs", "UTC") } From cd3298f7dd066b027910bd7c4f2678495f40f173 Mon Sep 17 00:00:00 2001 From: mouldybread <38598858+mouldybread@users.noreply.github.com> Date: Sun, 29 Nov 2026 03:45:02 +0800 Subject: [PATCH 4/7] refactor: move templates and static assets under web/ (#16) --- Dockerfile | 4 ++-- auth_session_renewal_test.go | 2 +- camera_removal_empty_state_test.go | 2 +- continuous_recording_health_test.go | 2 +- docs/RECORDING_LAYOUT.md | 2 +- legacy_download_test.go | 6 +++--- main.go | 4 ++-- recording_intent_status_test.go | 4 ++-- tests/acceptance/test_browser_playback_control.py | 2 +- tests/frontend/camera-removal-confirmation.cjs | 4 ++-- tests/frontend/download-entrypoints.cjs | 4 ++-- tests/frontend/event-clear-confirmation.cjs | 4 ++-- tests/frontend/event-navigation.cjs | 2 +- tests/frontend/event-rendering.cjs | 2 +- tests/frontend/export-ui-fixture.cjs | 8 ++++---- tests/frontend/export-ui.cjs | 2 +- tests/frontend/live-stream-names.cjs | 4 ++-- tests/frontend/orphan-cleanup-reporting.cjs | 2 +- tests/frontend/persistence-responses.cjs | 2 +- tests/frontend/playback-continuation.cjs | 4 ++-- tests/frontend/playback-controls.cjs | 2 +- tests/frontend/playback-failures.cjs | 4 ++-- tests/frontend/playback-lifecycle.cjs | 4 ++-- tests/frontend/recording-deletion-confirmation.cjs | 4 ++-- tests/frontend/session-expiry.cjs | 4 ++-- tests/frontend/timeline-camera-filter.cjs | 6 +++--- tests/frontend/timeline-canvas.cjs | 4 ++-- tests/frontend/timeline-geometry.cjs | 2 +- tests/frontend/toast-text.cjs | 4 ++-- {static => web/static}/app.js | 0 {static => web/static}/js/cameras.js | 0 {static => web/static}/js/core.js | 0 {static => web/static}/js/events.js | 0 {static => web/static}/js/export-ui.js | 0 {static => web/static}/js/modals.js | 0 {static => web/static}/js/playback-camera-date.js | 0 {static => web/static}/js/playback-canvas.js | 0 {static => web/static}/js/playback-seek-session.js | 0 {static => web/static}/js/playback-state.js | 0 {static => web/static}/js/playback-timeline-load.js | 0 {static => web/static}/js/playback-video-controls.js | 0 {static => web/static}/js/recordings.js | 0 {static => web/static}/js/session-settings.js | 0 {static => web/static}/js/timeline-camera-filter.js | 0 {static => web/static}/js/timeline-geometry.js | 0 {static => web/static}/js/toast.js | 0 {static => web/static}/style.css | 0 {templates => web/templates}/cameras.html | 0 {templates => web/templates}/index.html | 0 49 files changed, 50 insertions(+), 50 deletions(-) rename {static => web/static}/app.js (100%) rename {static => web/static}/js/cameras.js (100%) rename {static => web/static}/js/core.js (100%) rename {static => web/static}/js/events.js (100%) rename {static => web/static}/js/export-ui.js (100%) rename {static => web/static}/js/modals.js (100%) rename {static => web/static}/js/playback-camera-date.js (100%) rename {static => web/static}/js/playback-canvas.js (100%) rename {static => web/static}/js/playback-seek-session.js (100%) rename {static => web/static}/js/playback-state.js (100%) rename {static => web/static}/js/playback-timeline-load.js (100%) rename {static => web/static}/js/playback-video-controls.js (100%) rename {static => web/static}/js/recordings.js (100%) rename {static => web/static}/js/session-settings.js (100%) rename {static => web/static}/js/timeline-camera-filter.js (100%) rename {static => web/static}/js/timeline-geometry.js (100%) rename {static => web/static}/js/toast.js (100%) rename {static => web/static}/style.css (100%) rename {templates => web/templates}/cameras.html (100%) rename {templates => web/templates}/index.html (100%) diff --git a/Dockerfile b/Dockerfile index ab6bd9a..c74b991 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,8 +11,8 @@ FROM alpine:3.24.4@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0 RUN apk add --no-cache ffmpeg ca-certificates && ffmpeg -hide_banner -encoders 2>/dev/null | grep -q '[[:space:]]libx264[[:space:]]' WORKDIR /app COPY --from=builder /app/simplenvr /app/simplenvr -COPY --from=builder /app/templates /app/templates -COPY --from=builder /app/static /app/static +COPY --from=builder /app/web/templates /app/web/templates +COPY --from=builder /app/web/static /app/web/static EXPOSE 443 STOPSIGNAL SIGTERM ENTRYPOINT ["/app/simplenvr"] diff --git a/auth_session_renewal_test.go b/auth_session_renewal_test.go index 217d3ed..0bb2ace 100644 --- a/auth_session_renewal_test.go +++ b/auth_session_renewal_test.go @@ -21,7 +21,7 @@ type dashboardRoute struct { path string } -// Requests the dashboard issues, taken from static/js/*.js and the routes +// Requests the dashboard issues, taken from web/static/js/*.js and the routes // registered in main.go. /auth/session is covered by the probe tests. var dashboardRoutes = []dashboardRoute{ {"index", "GET", "/"}, diff --git a/camera_removal_empty_state_test.go b/camera_removal_empty_state_test.go index 6e5073e..82e256a 100644 --- a/camera_removal_empty_state_test.go +++ b/camera_removal_empty_state_test.go @@ -16,7 +16,7 @@ import ( // nonredirected HTTP 200 text/html fragment with no document-level tags, so the // served empty state must satisfy that contract rather than look ambiguous. func TestCameraListEmptyStateSatisfiesRemovalResponseContract(t *testing.T) { - parsed, err := template.ParseGlob("templates/*.html") + parsed, err := template.ParseGlob("web/templates/*.html") if err != nil { t.Fatal(err) } diff --git a/continuous_recording_health_test.go b/continuous_recording_health_test.go index 697f46d..b3024cf 100644 --- a/continuous_recording_health_test.go +++ b/continuous_recording_health_test.go @@ -57,7 +57,7 @@ func TestContinuousUpstreamFailureAndCameraResponse(t *testing.T) { defer func(){nvr=oldNVR;templates=oldTemplates}() nvr=&NVR{cameras:map[string]*Camera{cam.ID:cam,other.ID:other},cameraOrder:[]string{cam.ID,other.ID}} var parseErr error - templates,parseErr=template.ParseFiles("templates/cameras.html") + templates,parseErr=template.ParseFiles("web/templates/cameras.html") if parseErr!=nil {t.Fatal(parseErr)} w:=httptest.NewRecorder();camerasHandler(w,httptest.NewRequest("GET","https://nvr.test/api/cameras",nil)) if w.Code!=200 || strings.Count(w.Body.String(),`class="camera-recording-error"`)!=1 || !strings.Contains(w.Body.String(),"DESCRIBE 404") {t.Fatalf("%d %s",w.Code,w.Body.String())} diff --git a/docs/RECORDING_LAYOUT.md b/docs/RECORDING_LAYOUT.md index 80ac9f8..d1c7a90 100644 --- a/docs/RECORDING_LAYOUT.md +++ b/docs/RECORDING_LAYOUT.md @@ -27,7 +27,7 @@ Duplicates are deduplicated, an unknown ID returns 404, and an empty ID returns 400. Omitting `camera_id` scans all registered cameras. The playback page sends one `camera_id` for each camera selected for playback and makes no request when none is selected, so a problem in one camera's files does not affect another camera's view. -It does this from `static/js/timeline-camera-filter.js`, a small script that wraps +It does this from `web/static/js/timeline-camera-filter.js`, a small script that wraps the page's timeline request, because `playback.js` itself is unchanged. A recording overlaps the window exactly when `start < windowEnd` and diff --git a/legacy_download_test.go b/legacy_download_test.go index 8b3cc59..5974e13 100644 --- a/legacy_download_test.go +++ b/legacy_download_test.go @@ -11,7 +11,7 @@ import ( func TestNoLegacyDownloadCallsInAssets(t *testing.T) { legacy:=regexp.MustCompile(`\bfunction\s+startDownload\b|\bstartDownload\s*\(|=\s*startDownload\b|\b(?:window|globalThis)\s*(?:\.\s*startDownload\b|\[\s*['"]startDownload['"]\s*\])`) - for _,root:=range []string{"static","templates"} { + for _,root:=range []string{"web/static","web/templates"} { err:=filepath.WalkDir(root,func(path string,entry fs.DirEntry,walkErr error) error { if walkErr!=nil {return walkErr} if entry.IsDir() {return nil} @@ -23,9 +23,9 @@ func TestNoLegacyDownloadCallsInAssets(t *testing.T) { }) if err!=nil {t.Fatal(err)} } - playback,err:=func()([]byte,error){var all []byte;for _,p:=range []string{"static/js/playback-state.js","static/js/playback-camera-date.js","static/js/playback-timeline-load.js","static/js/playback-canvas.js","static/js/playback-seek-session.js","static/js/playback-video-controls.js"}{b,e:=os.ReadFile(p);if e!=nil{return nil,e};all=append(all,b...)};return all,nil}();if err!=nil {t.Fatal(err)} + playback,err:=func()([]byte,error){var all []byte;for _,p:=range []string{"web/static/js/playback-state.js","web/static/js/playback-camera-date.js","web/static/js/playback-timeline-load.js","web/static/js/playback-canvas.js","web/static/js/playback-seek-session.js","web/static/js/playback-video-controls.js"}{b,e:=os.ReadFile(p);if e!=nil{return nil,e};all=append(all,b...)};return all,nil}();if err!=nil {t.Fatal(err)} if bytes.Contains(playback,[]byte("/api/download")) {t.Fatal("playback module must not retain a direct export-request path")} - page,err:=os.ReadFile("templates/index.html");if err!=nil {t.Fatal(err)} + page,err:=os.ReadFile("web/templates/index.html");if err!=nil {t.Fatal(err)} if !bytes.Contains(page,[]byte(`onclick="startExportDownloads()"`)) {t.Fatal("monitored export entry point is not wired to the page")} } diff --git a/main.go b/main.go index c2353b0..ae1b76b 100644 --- a/main.go +++ b/main.go @@ -103,7 +103,7 @@ func main() { // Saving new session settings asks for the same graceful shutdown as SIGTERM; // the container's restart policy then starts the process again. auth.restart=stopSignals - templates,err=template.ParseGlob("templates/*.html");if err!=nil {log.Fatal("Failed to load templates: ",err)} + templates,err=template.ParseGlob("web/templates/*.html");if err!=nil {log.Fatal("Failed to load templates: ",err)} if err=nvr.load();err!=nil {log.Fatal("Refusing startup with invalid camera configuration: ",err)} log.Printf("Loaded %d cameras from disk",len(nvr.cameras)) recoverBeforeStartup(appCtx,nvr) @@ -138,7 +138,7 @@ func main() { http.HandleFunc("/api/events/clear-all",clearAllEventsHandler) http.HandleFunc("/api/events/clear-camera",clearCameraEventsHandler) http.HandleFunc("/api/recordings/cleanup-orphaned",cleanupOrphanedRecordingsHandler) - http.Handle("/static/",http.StripPrefix("/static/",http.FileServer(http.Dir("static")))) + http.Handle("/static/",http.StripPrefix("/static/",http.FileServer(http.Dir("web/static")))) http.HandleFunc("/",indexHandler) gate:=newShutdownGate(themedLoginPage(auth.Handler(exports.Handler(http.DefaultServeMux)))) gate.startBackgroundJob(exports.runLifecycle) diff --git a/recording_intent_status_test.go b/recording_intent_status_test.go index 36dffa4..47caf57 100644 --- a/recording_intent_status_test.go +++ b/recording_intent_status_test.go @@ -8,7 +8,7 @@ import ( ) func TestCameraTemplateRecordingStatus(t *testing.T) { - tmpl,err:=template.ParseFiles("templates/cameras.html") + tmpl,err:=template.ParseFiles("web/templates/cameras.html") if err!=nil {t.Fatal(err)} failure:=continuousRecordingNotice{Code:"upstream_rtsp_unavailable",Message:"Could not open upstream stream",Detail:"DESCRIBE 404",PublicationMessage:"Check recording storage",Retrying:true} notRetrying:=failure;notRetrying.Retrying=false @@ -59,7 +59,7 @@ func TestCameraTemplateRecordingStatus(t *testing.T) { } func TestCameraTemplateRecordingRecoveryAndEscaping(t *testing.T) { - tmpl,err:=template.ParseFiles("templates/cameras.html");if err!=nil {t.Fatal(err)} + tmpl,err:=template.ParseFiles("web/templates/cameras.html");if err!=nil {t.Fatal(err)} view:=map[string]interface{}{ "ID":"test","Name":"Test camera","RTSPUrl":"","RecordDir":"/recordings/test","DiskUsage":"0 B", "IsRecording":true,"RecordingMode":ModeContinuous,"ModeDisplay":"Continuous","RetentionDisplay":7, diff --git a/tests/acceptance/test_browser_playback_control.py b/tests/acceptance/test_browser_playback_control.py index c0985c4..ed3d746 100644 --- a/tests/acceptance/test_browser_playback_control.py +++ b/tests/acceptance/test_browser_playback_control.py @@ -15,7 +15,7 @@ class MarkupTests(unittest.TestCase): def test_actual_template_has_operable_control(self): - self.assertTrue(template_contract((ROOT / "templates/index.html").read_text())) + self.assertTrue(template_contract((ROOT / "web/templates/index.html").read_text())) def test_bad_markup_is_rejected(self): button = '' diff --git a/tests/frontend/camera-removal-confirmation.cjs b/tests/frontend/camera-removal-confirmation.cjs index 78412d2..cfa86d9 100644 --- a/tests/frontend/camera-removal-confirmation.cjs +++ b/tests/frontend/camera-removal-confirmation.cjs @@ -2,7 +2,7 @@ const assert = require('node:assert/strict'); const fs = require('node:fs'); const vm = require('node:vm'); const { test } = require('node:test'); -const source = fs.readFileSync('static/js/cameras.js', 'utf8'); +const source = fs.readFileSync('web/static/js/cameras.js', 'utf8'); const fragment = '
Current camera list
'; function element(role, options) { const classes = new Set(); let html = ''; @@ -41,7 +41,7 @@ function harness(options = {}) { return promise; } }); - vm.runInContext(source,c,{filename:'static/js/cameras.js'}); c.setupDeleteCamerasModal(); + vm.runInContext(source,c,{filename:'web/static/js/cameras.js'}); c.setupDeleteCamerasModal(); const state=code => vm.runInContext(code,c); return {c,nodes,timers,calls,notices,state,get refreshes() { return refreshes; }, advance(ms) { now+=ms; },flush(delay) { for (const [id,t] of [...timers]) if(t.delay===delay) { timers.delete(id);t.fn(); } }, diff --git a/tests/frontend/download-entrypoints.cjs b/tests/frontend/download-entrypoints.cjs index 0ed2ccb..8bff52d 100644 --- a/tests/frontend/download-entrypoints.cjs +++ b/tests/frontend/download-entrypoints.cjs @@ -2,13 +2,13 @@ const assert=require('node:assert/strict'); const fs=require('node:fs'); const vm=require('node:vm'); const context=vm.createContext({console,document:{readyState:'loading',addEventListener(){},getElementById(){return null;}},window:{addEventListener(){}}}); -vm.runInContext(['static/js/playback-state.js','static/js/playback-camera-date.js','static/js/playback-timeline-load.js','static/js/playback-canvas.js','static/js/playback-seek-session.js','static/js/playback-video-controls.js'].map(f=>fs.readFileSync(f,'utf8')).join(''),context,{filename:'static/js/playback.js'}); +vm.runInContext(['web/static/js/playback-state.js','web/static/js/playback-camera-date.js','web/static/js/playback-timeline-load.js','web/static/js/playback-canvas.js','web/static/js/playback-seek-session.js','web/static/js/playback-video-controls.js'].map(f=>fs.readFileSync(f,'utf8')).join(''),context,{filename:'web/static/js/playback.js'}); assert.equal(vm.runInContext('typeof startDownload',context),'undefined'); assert.equal(Object.prototype.hasOwnProperty.call(context,'startDownload'),false); // The old export modal and its separate camera checklist are gone; export uses the playback selection. for (const legacy of ['openDownloadModal','closeDownloadModal','toggleDownloadCamera','renderDownloadCameraSelection','expandDownloadTimeEarlier','expandDownloadTimeLater']) assert.equal(vm.runInContext(`typeof ${legacy}`,context),'undefined',legacy); -vm.runInContext(fs.readFileSync('static/js/export-ui.js','utf8'),context,{filename:'static/js/export-ui.js'}); +vm.runInContext(fs.readFileSync('web/static/js/export-ui.js','utf8'),context,{filename:'web/static/js/export-ui.js'}); assert.equal(vm.runInContext('typeof startDownload',context),'undefined'); assert.equal(vm.runInContext('typeof startExportDownloads',context),'function'); for (const entry of ['cancelExportDownloads','openExportPanel','closeExportPanel','refreshExportQueue','clearExportQueue','renderExportRangeOverlay','refreshExportCameraGuidance']) diff --git a/tests/frontend/event-clear-confirmation.cjs b/tests/frontend/event-clear-confirmation.cjs index 0418e77..d059a55 100644 --- a/tests/frontend/event-clear-confirmation.cjs +++ b/tests/frontend/event-clear-confirmation.cjs @@ -2,7 +2,7 @@ const assert = require('node:assert/strict'); const fs = require('node:fs'); const vm = require('node:vm'); const { test } = require('node:test'); -const source = fs.readFileSync('static/js/modals.js', 'utf8'); +const source = fs.readFileSync('web/static/js/modals.js', 'utf8'); const cleared = {success:true,count:3}; function element() { const classes=new Set(); @@ -31,7 +31,7 @@ function harness(options={}) { if(options.syncThrow) throw new Error('');return promise; } }); - vm.runInContext(source,c,{filename:'static/js/modals.js'});ready.forEach(fn=>fn()); + vm.runInContext(source,c,{filename:'web/static/js/modals.js'});ready.forEach(fn=>fn()); const state=code=>vm.runInContext(code,c); return {c,nodes,timers,calls,notices,state,get refreshes() { return refreshes; }, advance(ms) { now+=ms; },flush(delay) { for(const [id,t] of [...timers]) if(t.delay===delay) {timers.delete(id);t.fn();} }, diff --git a/tests/frontend/event-navigation.cjs b/tests/frontend/event-navigation.cjs index ea3dc96..8dc25ce 100644 --- a/tests/frontend/event-navigation.cjs +++ b/tests/frontend/event-navigation.cjs @@ -5,7 +5,7 @@ const timers = new Map(), requests = [], errors = [], seeks = []; let nextTimer = 0; const picker = {value:''}; const context = vm.createContext({console,AbortController,document:{readyState:'loading',addEventListener(){},getElementById:id=>id==='timeline-date-picker'?picker:null},window:{},localStorage:{getItem(){return null;},setItem(){}},showError:message=>errors.push(message),setTimeout(fn,delay){const id=++nextTimer;timers.set(id,{fn,delay});return id;},clearTimeout(id){timers.delete(id);},fetch(url,options){return new Promise((resolve,reject)=>requests.push({url,options,resolve,reject}));}}); -for (const file of ['static/js/events.js','static/js/playback-state.js','static/js/playback-camera-date.js','static/js/playback-timeline-load.js','static/js/playback-canvas.js','static/js/playback-seek-session.js','static/js/playback-video-controls.js']) vm.runInContext(fs.readFileSync(file,'utf8'),context,{filename:file}); +for (const file of ['web/static/js/events.js','web/static/js/playback-state.js','web/static/js/playback-camera-date.js','web/static/js/playback-timeline-load.js','web/static/js/playback-canvas.js','web/static/js/playback-seek-session.js','web/static/js/playback-video-controls.js']) vm.runInContext(fs.readFileSync(file,'utf8'),context,{filename:file}); vm.runInContext(`allCameras=[{id:'front',name:'Front Door'},{id:'back',name:'Back Door'}]; selectedCameras=['back'];`,context); context.renderCameraSelector=()=>{}; context.renderTimeline=()=>{}; context.updateVideoGrid=()=>{}; context.performSeek=time=>seeks.push(time.getTime()); diff --git a/tests/frontend/event-rendering.cjs b/tests/frontend/event-rendering.cjs index 6de28d6..b3ac3ea 100644 --- a/tests/frontend/event-rendering.cjs +++ b/tests/frontend/event-rendering.cjs @@ -21,7 +21,7 @@ class Element { const list = new Element('div'); const body = new Element('body'); const context = vm.createContext({console,document:{readyState:'loading',body,addEventListener(){},createElement:tag => new Element(tag),getElementById:id => id === 'events-list' ? list : null},window:{}}); -for (const file of ['static/js/events.js','static/js/playback-state.js','static/js/playback-camera-date.js','static/js/playback-timeline-load.js','static/js/playback-canvas.js','static/js/playback-seek-session.js','static/js/playback-video-controls.js']) vm.runInContext(fs.readFileSync(file,'utf8'),context,{filename:file}); +for (const file of ['web/static/js/events.js','web/static/js/playback-state.js','web/static/js/playback-camera-date.js','web/static/js/playback-timeline-load.js','web/static/js/playback-canvas.js','web/static/js/playback-seek-session.js','web/static/js/playback-video-controls.js']) vm.runInContext(fs.readFileSync(file,'utf8'),context,{filename:file}); const payload = `& ' \\ `; const camera = `front');globalThis.pwned=3;// ${payload}`; const timestamp = `');globalThis.pwned=4;//`; diff --git a/tests/frontend/export-ui-fixture.cjs b/tests/frontend/export-ui-fixture.cjs index e042917..1a82576 100644 --- a/tests/frontend/export-ui-fixture.cjs +++ b/tests/frontend/export-ui-fixture.cjs @@ -4,8 +4,8 @@ // HTML sinks and inline handlers throw so any HTML injection path fails the tests. const fs = require('node:fs'), vm = require('node:vm'), path = require('node:path'); const root = path.join(__dirname, '..', '..'); -const source = fs.readFileSync(path.join(root, 'static/js/export-ui.js'), 'utf8'); -const geometrySource = fs.readFileSync(path.join(root, 'static/js/timeline-geometry.js'), 'utf8'); +const source = fs.readFileSync(path.join(root, 'web/static/js/export-ui.js'), 'utf8'); +const geometrySource = fs.readFileSync(path.join(root, 'web/static/js/timeline-geometry.js'), 'utf8'); const VIEW_START = Date.parse('2026-11-21T00:00:00Z'), VIEW_END = Date.parse('2026-11-22T00:00:00Z'); function environment(fetcher, ids = ['front'], options = {}) { @@ -60,12 +60,12 @@ function environment(fetcher, ids = ['front'], options = {}) { fetch(url, options) { requests.push({url, options}); return fetcher(url, options); }, showSuccess(m) { notices.push(['success', m]); }, showError(m) { notices.push(['error', m]); }, }); - vm.runInContext(geometrySource, context, {filename: 'static/js/timeline-geometry.js'}); + vm.runInContext(geometrySource, context, {filename: 'web/static/js/timeline-geometry.js'}); const cameras = options.cameras || ids.map((id, i) => ({id, name: `Camera ${i + 1}`})); vm.runInContext(`let downloadStartTime=new Date('2026-11-21T00:00:00Z'),downloadEndTime=new Date('2026-11-21T00:01:00Z'),currentTimePosition=Date.parse('2026-11-21T12:00:00Z'),selectedCameras=${JSON.stringify(ids)},allCameras=${JSON.stringify(cameras)}; function timelineViewport(){return {start:${VIEW_START},end:${VIEW_END}};}`, context); if (vm.runInContext('typeof TimelineGeometry', context) !== 'object') throw Error('timeline-geometry.js did not load'); - vm.runInContext(source, context, {filename: 'static/js/export-ui.js'}); + vm.runInContext(source, context, {filename: 'web/static/js/export-ui.js'}); ready.forEach(fn => fn()); const run = code => vm.runInContext(code, context); const flush = async () => { for (let i = 0; i < 12; i++) await new Promise(r => setImmediate(r)); }; diff --git a/tests/frontend/export-ui.cjs b/tests/frontend/export-ui.cjs index 4e6a8a2..ed64d83 100644 --- a/tests/frontend/export-ui.cjs +++ b/tests/frontend/export-ui.cjs @@ -1,7 +1,7 @@ const assert = require('node:assert/strict'); const fs = require('node:fs'), path = require('node:path'); const {environment, letterId, view, response} = require('./export-ui-fixture.cjs'); -const source = fs.readFileSync(path.join(__dirname, '../../static/js/export-ui.js'), 'utf8'); +const source = fs.readFileSync(path.join(__dirname, '../../web/static/js/export-ui.js'), 'utf8'); // Static security policy: no video buffering, no HTML sinks, no legacy approval flow. for (const banned of ['new Blob(', 'createObjectURL', '.blob()', 'arrayBuffer(', 'innerHTML', 'outerHTML', 'insertAdjacentHTML', 'document.write', diff --git a/tests/frontend/live-stream-names.cjs b/tests/frontend/live-stream-names.cjs index bbf2ae8..5a76894 100644 --- a/tests/frontend/live-stream-names.cjs +++ b/tests/frontend/live-stream-names.cjs @@ -2,7 +2,7 @@ const assert = require('node:assert/strict'); const fs = require('node:fs'); const vm = require('node:vm'); const { test } = require('node:test'); -const source = fs.readFileSync('static/js/modals.js', 'utf8'); +const source = fs.readFileSync('web/static/js/modals.js', 'utf8'); const origin = 'https://nvr.invalid:9443'; const videoHTML = ''; function harness(onDemand=false) { @@ -29,7 +29,7 @@ function harness(onDemand=false) { window:{},showError:message=>errors.push(message),console, fetch() {throw new Error('Live-name tests must not contact a server');} }); - vm.runInContext(source,context,{filename:'static/js/modals.js'}); + vm.runInContext(source,context,{filename:'web/static/js/modals.js'}); return {context,nodes,errors,assignments,get creations() {return creations;},get rewrites() {return rewrites;}, state:code=>vm.runInContext(code,context)}; } diff --git a/tests/frontend/orphan-cleanup-reporting.cjs b/tests/frontend/orphan-cleanup-reporting.cjs index 8e728a2..98de142 100644 --- a/tests/frontend/orphan-cleanup-reporting.cjs +++ b/tests/frontend/orphan-cleanup-reporting.cjs @@ -2,7 +2,7 @@ const assert = require('node:assert/strict'); const fs = require('node:fs'); const vm = require('node:vm'); const { test } = require('node:test'); -const source = fs.readFileSync('static/js/cameras.js', 'utf8'); +const source = fs.readFileSync('web/static/js/cameras.js', 'utf8'); const valid = {success:true,count:2,size_mb:1.25,skipped_recovery_dirs:0,failures:0,interrupted:false,limit_reached:false}; function element() { diff --git a/tests/frontend/persistence-responses.cjs b/tests/frontend/persistence-responses.cjs index aa5947b..13cb7b2 100644 --- a/tests/frontend/persistence-responses.cjs +++ b/tests/frontend/persistence-responses.cjs @@ -5,7 +5,7 @@ const vm = require('node:vm'); const sources = ['cameras.js', 'modals.js'].map(name => ({ name, - text: fs.readFileSync(path.join(__dirname, '..', '..', 'static', 'js', name), 'utf8') + text: fs.readFileSync(path.join(__dirname, '..', '..', 'web', 'static', 'js', name), 'utf8') })); const html = '
Updated camera list
'; const intentMessage = 'Recording enabled; footage capture is not yet verified.'; diff --git a/tests/frontend/playback-continuation.cjs b/tests/frontend/playback-continuation.cjs index 2c19feb..2a015df 100644 --- a/tests/frontend/playback-continuation.cjs +++ b/tests/frontend/playback-continuation.cjs @@ -9,11 +9,11 @@ class Video { set src(value){this.assignments.push(value);this.ended=false;} removeAttribute(){}pause(){}play(){this.plays++;return Promise.resolve();} } -const source=['static/js/playback-state.js','static/js/playback-camera-date.js','static/js/playback-timeline-load.js','static/js/playback-canvas.js','static/js/playback-seek-session.js','static/js/playback-video-controls.js'].map(f=>fs.readFileSync(f,'utf8')).join(''); +const source=['web/static/js/playback-state.js','web/static/js/playback-camera-date.js','web/static/js/playback-timeline-load.js','web/static/js/playback-canvas.js','web/static/js/playback-seek-session.js','web/static/js/playback-video-controls.js'].map(f=>fs.readFileSync(f,'utf8')).join(''); function harness(extra=[]){ const timers=new Map(),errors=[];let id=0;const video=new Video(); const c=vm.createContext({console,testVideo:video,document:{readyState:'loading',addEventListener(){},getElementById(){return null;}},showError:message=>errors.push(message),setTimeout(fn,delay){const key=++id;timers.set(key,{fn,delay});return key;},clearTimeout(key){timers.delete(key);}}); - vm.runInContext(source,c,{filename:'static/js/playback.js'});const run=code=>vm.runInContext(code,c); + vm.runInContext(source,c,{filename:'web/static/js/playback.js'});const run=code=>vm.runInContext(code,c); run(`currentDate=new Date(2026,10,10);allCameras=[{id:'a',name:'A'}];selectedCameras=['a'];videoPlayers=[testVideo];`); const start=new Date(2026,10,10,12).getTime(),segment=(a,b,path)=>({camera_id:'a',start_time:new Date(start+a*1000).toISOString(),end_time:new Date(start+b*1000).toISOString(),file_path:path}); c.segments=[segment(0,60,'/first.mp4'),...extra.map(item=>segment(...item))];run('timelineSegments=segments'); diff --git a/tests/frontend/playback-controls.cjs b/tests/frontend/playback-controls.cjs index f05584a..d34dd31 100644 --- a/tests/frontend/playback-controls.cjs +++ b/tests/frontend/playback-controls.cjs @@ -1,6 +1,6 @@ 'use strict'; const assert=require('node:assert/strict'),fs=require('node:fs'),vm=require('node:vm'); -const source=['static/js/playback-state.js','static/js/playback-camera-date.js','static/js/playback-timeline-load.js','static/js/playback-canvas.js','static/js/playback-seek-session.js','static/js/playback-video-controls.js'].map(f=>fs.readFileSync(f,'utf8')).join(''); +const source=['web/static/js/playback-state.js','web/static/js/playback-camera-date.js','web/static/js/playback-timeline-load.js','web/static/js/playback-canvas.js','web/static/js/playback-seek-session.js','web/static/js/playback-video-controls.js'].map(f=>fs.readFileSync(f,'utf8')).join(''); class Video { constructor(){this.listeners=new Map();this.style={};this.message={style:{}};this.parentElement={querySelector:()=>this.message};this.duration=60;this.currentTime=0;this.ended=false;this.plays=0;this.pauses=0;this.nextPlay=null;this.assignments=[];} addEventListener(name,fn){if(!this.listeners.has(name))this.listeners.set(name,new Set());this.listeners.get(name).add(fn);} diff --git a/tests/frontend/playback-failures.cjs b/tests/frontend/playback-failures.cjs index 8eb345f..debbcb8 100644 --- a/tests/frontend/playback-failures.cjs +++ b/tests/frontend/playback-failures.cjs @@ -1,6 +1,6 @@ 'use strict'; const assert=require('node:assert/strict'),fs=require('node:fs'),vm=require('node:vm'); -const source=['static/js/playback-state.js','static/js/playback-camera-date.js','static/js/playback-timeline-load.js','static/js/playback-canvas.js','static/js/playback-seek-session.js','static/js/playback-video-controls.js'].map(f=>fs.readFileSync(f,'utf8')).join(''); +const source=['web/static/js/playback-state.js','web/static/js/playback-camera-date.js','web/static/js/playback-timeline-load.js','web/static/js/playback-canvas.js','web/static/js/playback-seek-session.js','web/static/js/playback-video-controls.js'].map(f=>fs.readFileSync(f,'utf8')).join(''); class Video { constructor(){this.listeners=new Map();this.style={};this.message={style:{}};this.parentElement={querySelector:()=>this.message};this.duration=60;this.currentTime=0;this.ended=false;this.assignments=[];this.plays=0;this.pauses=0;this.nextPlay=null;} addEventListener(name,fn){if(!this.listeners.has(name))this.listeners.set(name,new Set());this.listeners.get(name).add(fn);} @@ -14,7 +14,7 @@ class Video { function harness(extra=[[60,120,'/second.mp4']]){ const timers=new Map(),errors=[];let id=0;const video=new Video(); const c=vm.createContext({console,testVideo:video,document:{readyState:'loading',addEventListener(){},getElementById(){return null;}},showError:message=>errors.push(message),setTimeout(fn,delay){const key=++id;timers.set(key,{fn,delay});return key;},clearTimeout(key){timers.delete(key);}}); - vm.runInContext(source,c,{filename:'static/js/playback.js'});const run=code=>vm.runInContext(code,c); + vm.runInContext(source,c,{filename:'web/static/js/playback.js'});const run=code=>vm.runInContext(code,c); run(`currentDate=new Date(2026,10,10);allCameras=[{id:'a',name:'A'}];selectedCameras=['a'];videoPlayers=[testVideo];`); const start=new Date(2026,10,10,12).getTime(); const segment=(a,b,path)=>({camera_id:'a',start_time:new Date(start+a*1000).toISOString(),end_time:new Date(start+b*1000).toISOString(),file_path:path}); diff --git a/tests/frontend/playback-lifecycle.cjs b/tests/frontend/playback-lifecycle.cjs index dd57ed8..564128d 100644 --- a/tests/frontend/playback-lifecycle.cjs +++ b/tests/frontend/playback-lifecycle.cjs @@ -1,6 +1,6 @@ 'use strict'; const assert=require('node:assert/strict'),fs=require('node:fs'),vm=require('node:vm'); -const source=['static/js/playback-state.js','static/js/playback-camera-date.js','static/js/playback-timeline-load.js','static/js/playback-canvas.js','static/js/playback-seek-session.js','static/js/playback-video-controls.js'].map(f=>fs.readFileSync(f,'utf8')).join(''); +const source=['web/static/js/playback-state.js','web/static/js/playback-camera-date.js','web/static/js/playback-timeline-load.js','web/static/js/playback-canvas.js','web/static/js/playback-seek-session.js','web/static/js/playback-video-controls.js'].map(f=>fs.readFileSync(f,'utf8')).join(''); class Video { constructor(){this.listeners=new Map();this.assignments=[];this.style={};this.message={style:{}};this.duration=60;this.currentTime=0;this.playCount=0;this.pauseCount=0;this.parentElement={querySelector:()=>this.message};} addEventListener(name,fn){if(!this.listeners.has(name))this.listeners.set(name,new Set());this.listeners.get(name).add(fn);} @@ -15,7 +15,7 @@ class Video { function harness(){ const timers=new Map();let next=0; const c=vm.createContext({console,document:{readyState:'loading',addEventListener(){},getElementById(){return null;}},setTimeout(fn,delay){const id=++next;timers.set(id,{fn,delay});return id;},clearTimeout(id){timers.delete(id);}}); - vm.runInContext(source,c,{filename:'static/js/playback.js'}); + vm.runInContext(source,c,{filename:'web/static/js/playback.js'}); const run=code=>vm.runInContext(code,c); const video=new Video();c.testVideo=video; run(`allCameras=[{id:'a',name:'A'}];selectedCameras=['a'];videoPlayers=[testVideo];timelineSegments=[{camera_id:'a',start_time:'2026-11-10T12:00:00Z',end_time:'2026-11-10T12:01:00Z',file_path:'/first.mp4'}];`); diff --git a/tests/frontend/recording-deletion-confirmation.cjs b/tests/frontend/recording-deletion-confirmation.cjs index cb6e647..290fc2b 100644 --- a/tests/frontend/recording-deletion-confirmation.cjs +++ b/tests/frontend/recording-deletion-confirmation.cjs @@ -2,7 +2,7 @@ const assert = require('node:assert/strict'); const fs = require('node:fs'); const vm = require('node:vm'); const { test } = require('node:test'); -const source = fs.readFileSync('static/js/recordings.js', 'utf8'); +const source = fs.readFileSync('web/static/js/recordings.js', 'utf8'); const complete = {success:true,deleted:2,size_mb:1.25,failures:0}; function element() { const classes = new Set(); @@ -31,7 +31,7 @@ function harness(options = {}) { return promise; } }); - vm.runInContext(source,c,{filename:'static/js/recordings.js'}); ready.forEach(fn => fn()); + vm.runInContext(source,c,{filename:'web/static/js/recordings.js'}); ready.forEach(fn => fn()); const run = code => vm.runInContext(code,c); return {c,nodes,timers,calls,notices,run,get refreshes() { return refreshes; }, advance(ms) { now += ms; }, diff --git a/tests/frontend/session-expiry.cjs b/tests/frontend/session-expiry.cjs index b50d8ad..90b530c 100644 --- a/tests/frontend/session-expiry.cjs +++ b/tests/frontend/session-expiry.cjs @@ -2,7 +2,7 @@ const assert = require('node:assert/strict'); const fs = require('node:fs'); const vm = require('node:vm'); const { test } = require('node:test'); -const source = fs.readFileSync('static/js/core.js', 'utf8'); +const source = fs.readFileSync('web/static/js/core.js', 'utf8'); const ORIGIN = 'https://nvr.test'; const settle = () => new Promise(resolve => setImmediate(resolve)); const response = (status, path) => ({ status, url: new URL(path, ORIGIN + '/').href }); @@ -28,7 +28,7 @@ function harness({ visibility = 'visible', responder = path => response(204, pat getElementById: () => null }; const context = vm.createContext({ window, document, URL, AbortSignal, console, setTimeout: () => 0 }); - vm.runInContext(source, context, { filename: 'static/js/core.js' }); + vm.runInContext(source, context, { filename: 'web/static/js/core.js' }); return { window, document, calls, replaced, intervals, state, bodyListeners, interval: () => intervals[0].fn(), diff --git a/tests/frontend/timeline-camera-filter.cjs b/tests/frontend/timeline-camera-filter.cjs index 6c0e8d5..0ea53af 100644 --- a/tests/frontend/timeline-camera-filter.cjs +++ b/tests/frontend/timeline-camera-filter.cjs @@ -1,12 +1,12 @@ 'use strict'; -// Regression tests for static/js/timeline-camera-filter.js: the camera_id filter on timeline +// Regression tests for web/static/js/timeline-camera-filter.js: the camera_id filter on timeline // requests and the warning shown when the server leaves unreadable recordings out. const assert = require('node:assert/strict'); const fs = require('node:fs'); const vm = require('node:vm'); const { test } = require('node:test'); -const source = fs.readFileSync('static/js/timeline-camera-filter.js', 'utf8'); +const source = fs.readFileSync('web/static/js/timeline-camera-filter.js', 'utf8'); const ORIGIN = 'https://nvr.test'; const TIMELINE = '/api/timeline/recordings'; const QUERY = 'start_time=2026-11-10T00%3A00%3A00.000Z&end_time=2026-11-11T00%3A00%3A00.000Z'; @@ -36,7 +36,7 @@ function harness({ selected, warn = true } = {}) { if (warn) sandbox.showWarning = (message, duration) => { warnings.push({ message, duration }); }; const context = vm.createContext(sandbox); if (selected) vm.runInContext('var selectedCameras = ' + JSON.stringify(selected) + ';', context); - vm.runInContext(source, context, { filename: 'static/js/timeline-camera-filter.js' }); + vm.runInContext(source, context, { filename: 'web/static/js/timeline-camera-filter.js' }); return { context, calls, warnings, consoleWarnings, fetch: (input, init) => context.window.fetch(input, init), diff --git a/tests/frontend/timeline-canvas.cjs b/tests/frontend/timeline-canvas.cjs index 66733d4..d8e785a 100644 --- a/tests/frontend/timeline-canvas.cjs +++ b/tests/frontend/timeline-canvas.cjs @@ -14,7 +14,7 @@ const ctx={fillRect(...a){rectangles.push(a);},fillText(s){labels.push(s);},meas const rect={left:10,top:20,width:500,height:170}; const canvas={offsetWidth:1000,width:1000,height:85,style:{},getContext(){return ctx;},getBoundingClientRect(){return rect;},addEventListener(k,fn){listeners[k]=fn;}}; const context=vm.createContext({console,document:{readyState:'loading',body,createElement:tag=>new Element(tag),addEventListener(){},getElementById:id=>id==='timeline-canvas'?canvas:null},window:{},setTimeout(fn,delay){const id=++timerID;timers.set(id,{fn,delay});return id;},clearTimeout(id){timers.delete(id);}}); -for(const file of ['static/js/events.js','static/js/timeline-geometry.js','static/js/playback-state.js','static/js/playback-camera-date.js','static/js/playback-timeline-load.js','static/js/playback-canvas.js','static/js/playback-seek-session.js','static/js/playback-video-controls.js']) vm.runInContext(fs.readFileSync(file,'utf8'),context,{filename:file}); +for(const file of ['web/static/js/events.js','web/static/js/timeline-geometry.js','web/static/js/playback-state.js','web/static/js/playback-camera-date.js','web/static/js/playback-timeline-load.js','web/static/js/playback-canvas.js','web/static/js/playback-seek-session.js','web/static/js/playback-video-controls.js']) vm.runInContext(fs.readFileSync(file,'utf8'),context,{filename:file}); const run=code=>vm.runInContext(code,context);context.performSeek=time=>seeks.push(time.getTime()); function flush(){for(const [id,timer] of [...timers])if(timer.delay===100){timers.delete(id);timer.fn();}} function click(f,y=80){listeners.click({clientX:rect.left+f*rect.width,clientY:rect.top+y*rect.height/canvas.height});flush();} @@ -53,6 +53,6 @@ hover(event);assert.equal(body.children.length,1,'repeat hover replaces the prev listeners.mousemove({clientX:rect.left,clientY:rect.top+rect.height});assert.equal(canvas.style.cursor,'default');assert.equal(body.children.length,0); hover(event);assert.equal(body.children.length,1);listeners.mouseleave();assert.equal(body.children.length,0);assert.equal(run('eventTooltip'),null); rect.width=0;const count=seeks.length;click(0.5);assert.equal(seeks.length,count); -const page=fs.readFileSync('templates/index.html','utf8'),scripts=[...page.matchAll(/