aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests/test_chat_send.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/tests/test_chat_send.py')
-rw-r--r--packages/meshbay-hub/tests/test_chat_send.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/packages/meshbay-hub/tests/test_chat_send.py b/packages/meshbay-hub/tests/test_chat_send.py
index d442383..c1a7f6f 100644
--- a/packages/meshbay-hub/tests/test_chat_send.py
+++ b/packages/meshbay-hub/tests/test_chat_send.py
@@ -42,6 +42,7 @@ import pytest
HARNESS = Path(__file__).parent / "harness" / "chat_send_probe.py"
STATIC = Path(__file__).resolve().parents[1] / "src" / "meshbay_hub" / "static"
+GROUP_PAGE = STATIC / "group-page.js"
pytestmark = pytest.mark.skipif(
shutil.which("google-chrome") is None or not (STATIC / "chat-app.js").exists(),
@@ -215,6 +216,53 @@ def test_sending_works_again_after_a_reconnect(probe):
"the text came back into the composer, so the send failed")
+def test_the_reconnect_scenario_drives_the_shipped_path(probe):
+ """The scenario has to be worth what it claims.
+
+ It would be easy to write one that sets `devicePk` itself at both ends and
+ proves only that the composer follows a variable. These three lines say the
+ clear came out of the real `connect()`, that the restore came out of the
+ real `_announceDevice`, and that the re-identification actually went over
+ the wire as a `device_hello`.
+ """
+ data, _ = probe
+ log = data["log"]
+ assert any("connect() stopped at signaling" in line for line in log), (
+ "the scenario never ran the real connect(), so it did not test the "
+ "reconnect path at all")
+ assert any("sent device_hello" == line for line in log), (
+ "no device_hello reached the stand-in node -- the identity was not "
+ "re-announced, it was assigned")
+ assert any("_announceDevice settled on the device key" in line for line in log), (
+ "_announceDevice did not settle on the key it signed with")
+
+
+def test_the_page_tells_the_composer_when_the_identity_moves():
+ """The one seam the probe stands in for.
+
+ `Host` in the harness plays group-page.js, so a green probe proves that
+ ChatPanel and the transport agree — not that the page joins them. These are
+ the lines that do, and the order matters: the callback has to be wired
+ before `connect()`, because `connect()` is where `device_hello` runs, and a
+ callback set after it misses the first answer and starts the composer shut.
+ """
+ src = GROUP_PAGE.read_text(encoding="utf-8")
+ # The assignment, not a mention of it. Matching the bare name passed with
+ # the wiring deleted, on the strength of a comment that named it.
+ assert "transport.onDeviceIdentity = " in src, (
+ "nothing tells the page that the device identity moved, so the "
+ "composer has no event to open back up on -- the freeze this file's "
+ "reconnect scenario is about")
+ assert "deviceReady," in src, (
+ "the answer never reaches the apps: ChatPanel defaults the prop to "
+ "true, so a composer wired this way is merely never closed rather "
+ "than correct")
+ assert src.index("transport.onDeviceIdentity = ") \
+ < src.index("await transport.connect("), (
+ "the callback is wired after connect(), which is where device_hello "
+ "runs -- its answer is missed and the composer starts closed")
+
+
def test_history_still_renders(probe):
"""
Not about sending at all, and here because it broke without a sound: