diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-08-23 15:15:35 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-08-23 15:15:35 +0200 |
| commit | 9f02ee2c09652abf1308bdfa4a3eec4e9ca9ac83 (patch) | |
| tree | b13198a79a0965f254c828adba3eb41dd5e9a5b4 /packages/meshbay-hub/tests/test_spa_ordering.py | |
| parent | 8dc11dc05a35a5d64ba4d2c892ccc01c7bfae3da (diff) | |
| download | meshbay-9f02ee2c09652abf1308bdfa4a3eec4e9ca9ac83.tar.gz | |
feat(hub): split the group UI into a pluggable "applications" architecture
GroupPage's 6620-line app.js carried Chat and Files wedged in directly, with
no way to add another group-level app without touching the shell itself. It
is now app.js (routing, non-group pages) plus nine focused files — apps.js
(the registry), chat-app.js, files-app.js, video-player.js, group-page.js
(the shell), group-settings.js, hub-client.js, icon.js and file-utils.js —
with docs/apps.md as the checklist for adding one (Videos/Music/Photos are
sketched there, not built).
Node side gained the matching enablement mechanism, mirroring
member_upload exactly: a roster setting, a signed apps_enabled op enforced
by _has_admin_authority, exposed in the handshake ack. Operators toggle
applications per group from Settings, which also gained a small reorder:
Invite, Pairing, Applications, Shared directories, Uploads, danger zone,
Your devices, Members.
Two bugs surfaced during the split, both missing an import across the new
file boundary and invisible to node --check or a module-load probe since
they only throw when the code path actually runs:
- group-page.js called onRefreshAuth on a stale-token handshake rejection,
but app.js never imported refreshAccessToken from hub-client.js — so a
brand new member (including a group's own creator) hit "Not a member of
this group" and the retry silently failed, throwing before it could
refresh the token.
- chat-app.js called getLocale() for message timestamps without importing
it from i18n.js. Opening Chat on a group with real messages threw mid-
render; uncaught, that appears to wedge Preact's render scheduler, so
every button on the page stopped responding until reload.
Caught the second class of bug with a proper no-undef audit across all
split files (a temporarily installed ESLint 9, since the system one is too
old to parse this codebase's syntax) rather than trusting grep. 827 tests
pass; 6 new ones cover the apps_enabled policy.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016SF6RKNBKg9qejmoMJ9ybA
Diffstat (limited to 'packages/meshbay-hub/tests/test_spa_ordering.py')
| -rw-r--r-- | packages/meshbay-hub/tests/test_spa_ordering.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/packages/meshbay-hub/tests/test_spa_ordering.py b/packages/meshbay-hub/tests/test_spa_ordering.py index dfc92f9..d00b9a0 100644 --- a/packages/meshbay-hub/tests/test_spa_ordering.py +++ b/packages/meshbay-hub/tests/test_spa_ordering.py @@ -113,14 +113,26 @@ def test_the_ack_still_verifies_the_announced_node_key(): # Users tab referencing `doInvite`, `members` and `adminId` — none of which are # defined there. +# The group-page refactor split what used to be one app.js into one file per +# "application" (chat-app.js, files-app.js, video-player.js) plus +# group-settings.js and the group shell itself, group-page.js. AdminPage and +# App() stayed in app.js. `_component` below is told which file to read a +# given top-level component from. APP = STATIC / "app.js" +COMPONENT_FILES = { + "GroupSettingsPanel": STATIC / "group-settings.js", + "GroupPage": STATIC / "group-page.js", + "ChatPanel": STATIC / "chat-app.js", + "FilesPanel": STATIC / "files-app.js", + "VideoPlayer": STATIC / "video-player.js", +} def _component(name: str) -> str: """The source of one top-level `function Name(...)`, up to the next one.""" - source = APP.read_text() + source = COMPONENT_FILES.get(name, APP).read_text() start = source.find(f"\nfunction {name}(") - assert start != -1, f"{name} is gone from app.js — update this test" + assert start != -1, f"{name} is gone — update this test" end = source.find("\nfunction ", start + 1) return source[start:end if end != -1 else len(source)] @@ -220,7 +232,7 @@ def test_no_caller_waits_for_one_chunk_at_a_time(): # two ends of that, since neither shows up in any Python test. def test_leaving_a_group_hands_the_transport_over_rather_than_closing_it(): - app = APP.read_text() + app = _component("GroupPage") cleanup = app[app.index(" return () => {\n cancelled = true;"):] cleanup = cleanup[:cleanup.index("\n }, [groupId")] assert "releaseWhenIdle" in cleanup, ( @@ -252,7 +264,7 @@ def test_a_multi_file_download_waits_for_each_picker(): meant the first opened a dialog and the rest were rejected — two files selected, one file downloaded. """ - app = APP.read_text() + app = STATIC.joinpath("files-app.js").read_text() # Anchored on the loop rather than on the markup around it: the toolbar # moved from a dropdown to icon buttons and took the old wrapper with it, # while the property under test — one picker at a time — did not change. @@ -269,7 +281,7 @@ def test_links_in_chat_are_built_as_elements_not_markup(): never HTML, and only for http(s) — otherwise javascript: would be one message away from running here. """ - app = APP.read_text() + app = STATIC.joinpath("chat-app.js").read_text() fn = app[app.index("function linkify("):] fn = fn[:fn.index("\nfunction ", 1)] assert "innerHTML" not in fn and "dangerouslySetInnerHTML" not in fn |