aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-25 11:46:17 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-25 11:46:17 +0200
commit2fcdd07d1e5d331ad02b723f1c45603a0989c264 (patch)
treef606f01f5492648824876efe4c8a431d9b3a59d6 /packages/meshbay-hub/tests
parentd427118bd91d67f1a041e5daf267aebcd34ca9d7 (diff)
downloadmeshbay-2fcdd07d1e5d331ad02b723f1c45603a0989c264.tar.gz
feat: add Photos group app
A new group application (docs/apps.md's plug-in mechanism), following the plan in docs/photos.md. Unlike Videos/Music: several photo roots per group instead of one (photo_roots is a set, one signed op replaces it whole), a single album-grid view with no third-party matching step, and per-photo info read from the file's own EXIF at index time — no metadata service, no credential, no outbound network call at all. Protocol (meshbay-common, MNP 0.10 -> 0.11, additive): `taken_at`/`camera` on IndexEntry; `photo_roots`/`photo_roots_ack`; `OP_PHOTO_ROOTS`. Node: roster.py stores photo_roots as a group_settings entry (JSON list, same shape as enabled_apps); ops.py/webrtc_server.py validate and sign the whole set in one op, same pattern as apps_enabled; a new PhotoEnricher (indexer/enrich_photo.py) runs Pillow in its own small bounded pool, separate from the video/audio pools, producing a resized thumbnail plus the two EXIF fields — never GPS, checked by a grep-based regression test. Client: photos-app.js — one album card per directory containing images, a per-album photo grid, and a lightbox with next/previous (keyboard and buttons), zoom in/out/fit/100% starting from the actual on-screen fit percentage, and a "zip this album" button reusing files-app.js's own zip mechanism (lifted into file-utils.js's downloadDirectory so both call the same implementation). group-settings.js gets an add/remove multi-root picker, distinct from Videos/Music's single-value one. Bugs found and fixed before this ever shipped, worth keeping the story of: - enrich_photo.py read width/height from the raw image *before* applying EXIF orientation correction, and read DateTimeOriginal off the plain 0th-IFD Exif object — a real camera stores it in the Exif sub-IFD, which Pillow only exposes via get_ifd(Exif). A flat, hand-built EXIF dict round-trips through Pillow either way, which is exactly what would have hidden both bugs; the regression test builds EXIF with piexif instead, matching what real hardware produces. - photos-app.js's album grouping stripped a trailing path segment from entry.path under the assumption it still carried a filename — it doesn't (files-app.js's own convention: e.path is already the containing directory), so every album collapsed one level into its parent. Found live against a real multi-folder library. - transport.js's ADMIN_OP_TYPES allowlist (already the fix for an identical bug on video_root/apps_enabled, see 4783d81) was missing photo_roots: its admin_challenge matched no pending request and was silently dropped, so saving a photo root just timed out after 30s with no error. - daemon.py pruned a thumbnail when its file left the index (root removed or reconfigured) but never forgot the content hash was "already attempted" — the same bytes reappearing under a renamed/relocated root (an operator's real workflow) were then permanently skipped, forever, with nothing to indicate why. Discarding the attempt alongside the cache entry on prune is what makes pruning actually reversible. - packages/meshbay-client's app:// protocol handler served every file with no Cache-Control header, so Chromium was free to serve a stale cached copy indefinitely — none of several `npm run sync-ui` + reload cycles during development actually picked up the new code until the renderer's disk cache was cleared by hand. Now sends Cache-Control: no-store. - the lightbox's zoomed image used flex centering (align-items/ justify-content: center) combined with overflow: auto — a well-known trap where the browser centers overflowing content by shifting it, and the leading half of that overflow (here, the top of a zoomed photo) sits outside what the scrollport can actually reach. Reported live as "unusable". Fixed by switching to top/left alignment once zoomed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TiZG4AuSnxHohQMpwTHTyL
Diffstat (limited to 'packages/meshbay-hub/tests')
-rw-r--r--packages/meshbay-hub/tests/test_downloads.py8
-rw-r--r--packages/meshbay-hub/tests/test_hook_ordering.py1
-rw-r--r--packages/meshbay-hub/tests/test_transport_contracts.py26
3 files changed, 32 insertions, 3 deletions
diff --git a/packages/meshbay-hub/tests/test_downloads.py b/packages/meshbay-hub/tests/test_downloads.py
index 80c3b05..32d3e11 100644
--- a/packages/meshbay-hub/tests/test_downloads.py
+++ b/packages/meshbay-hub/tests/test_downloads.py
@@ -145,9 +145,11 @@ def test_a_length_is_only_promised_when_it_is_known(tmp_path):
src = SW.read_text()
assert "if (entry.size > 0)" in src
- # The zip-directory download is Files' own, moved to files-app.js in the
- # group-page refactor.
- app = (STATIC / "files-app.js").read_text()
+ # The zip-directory download started in files-app.js (group-page refactor)
+ # and was lifted into file-utils.js's downloadDirectory (docs/photos.md
+ # §3) so photos-app.js's own "zip this album" button calls the same
+ # implementation rather than a second one.
+ app = (STATIC / "file-utils.js").read_text()
zip_call = app[app.index("const target = await _openDownloadTarget(suggested"):]
zip_call = zip_call[:zip_call.index(");") + 2]
assert zip_call.rstrip().endswith(", 0);"), (
diff --git a/packages/meshbay-hub/tests/test_hook_ordering.py b/packages/meshbay-hub/tests/test_hook_ordering.py
index 48a9376..2114b45 100644
--- a/packages/meshbay-hub/tests/test_hook_ordering.py
+++ b/packages/meshbay-hub/tests/test_hook_ordering.py
@@ -35,6 +35,7 @@ APP = STATIC / "app.js"
STATIC_FILES = [
"app.js", "group-page.js", "chat-app.js", "files-app.js",
"video-player.js", "video-app.js", "music-app.js", "music-player.js",
+ "photos-app.js",
"group-settings.js",
]
diff --git a/packages/meshbay-hub/tests/test_transport_contracts.py b/packages/meshbay-hub/tests/test_transport_contracts.py
index 98ebd66..6c178a6 100644
--- a/packages/meshbay-hub/tests/test_transport_contracts.py
+++ b/packages/meshbay-hub/tests/test_transport_contracts.py
@@ -30,6 +30,7 @@ GROUP_PAGE = STATIC / "group-page.js"
SPLIT_FILES = [APP, GROUP_PAGE, CHAT_APP, STATIC / "files-app.js",
STATIC / "video-player.js", STATIC / "video-app.js",
STATIC / "music-app.js", STATIC / "music-player.js",
+ STATIC / "photos-app.js",
STATIC / "group-settings.js"]
pytestmark = pytest.mark.skipif(
@@ -119,6 +120,31 @@ def test_the_view_only_follows_new_messages_when_already_at_the_bottom(chat):
"scrolling unconditionally fights someone reading back through history")
+def test_every_authorize_admin_op_call_is_registered_in_admin_op_types(transport):
+ """
+ Found live (docs/photos.md's photo_roots): `setPhotoRoots` called
+ `_authorizeAdminOp(msg, 'photo_roots', ...)` like every other admin op,
+ but `photo_roots` was never added to `ADMIN_OP_TYPES` — so its initial
+ request was never keyed `admin:photo_roots`, the node's `admin_challenge`
+ reply matched no pending request (_dispatch's own keyed block, which
+ `return`s unconditionally whether or not it found a match), and the
+ request sat until its 30 s timeout with no error and no admin prompt.
+ `ADMIN_OP_TYPES`'s own comment already narrates this exact bug once,
+ for `audio_root`/`apps_enabled` — this pins it so a third op cannot
+ reintroduce it silently.
+ """
+ set_body = transport[transport.index("const ADMIN_OP_TYPES = new Set(["):]
+ set_body = set_body[:set_body.index("]);")]
+ registered = set(re.findall(r"'([a-z_]+)'", set_body))
+
+ called = set(re.findall(r"_authorizeAdminOp\(\s*\w+,\s*'([a-z_]+)'", transport))
+ assert called, "the extraction pattern itself found nothing — check it against transport.js"
+ missing = called - registered
+ assert not missing, (
+ f"{sorted(missing)} call _authorizeAdminOp but are missing from ADMIN_OP_TYPES — "
+ "their admin_challenge will silently time out instead of ever reaching the user")
+
+
def test_the_bottom_is_reached_by_scrollTop_not_a_sentinel(chat):
"""scrollIntoView on a zero-height marker stops short of the true bottom.