From 8125df6d8149368ed8a84c9db6c5e37bfccb5a15 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Sat, 17 Oct 2026 18:37:35 +0200 Subject: fix(spa): a reconnect refused the local network says so Each failed attempt reaches the group page, which shows the same message and buttons as at opening while the reconnect goes on. Try now gives up an attempt still waiting on ICE and starts the next at once. Co-Authored-By: Claude Opus 5.5 --- packages/meshbay-hub/tests/test_network_change.py | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'packages/meshbay-hub/tests/test_network_change.py') diff --git a/packages/meshbay-hub/tests/test_network_change.py b/packages/meshbay-hub/tests/test_network_change.py index 2298e8e6..0d270ba7 100644 --- a/packages/meshbay-hub/tests/test_network_change.py +++ b/packages/meshbay-hub/tests/test_network_change.py @@ -88,3 +88,36 @@ def test_a_group_left_on_an_error_tries_again_when_the_network_changes(): block = re.search(r"onNetworkChange\(.*?\)", source, re.S) assert block, "the group page does not listen for another network" assert "setRetryKey" in source[block.start():block.start() + 200] + + +def test_a_reconnect_refused_the_local_network_says_so_and_goes_on(): + """Connected on mobile data, then on the node's Wi-Fi without the permission: + each attempt used to fail in silence, for ever. Each is now told to the page + with its reason, the reconnect goes on, and once the permission is granted + the page's "try now" reaches the group without waiting out the backoff.""" + out = _run("refused") + assert out["failures"] and set(out["failures"]) == {"local_network_blocked"}, out + assert out["stillReconnecting"], out + assert out["reconnectedAt"] - out["backAt"] < 3000, out + + +def test_try_now_gives_up_an_attempt_set_up_before_the_permission(): + """Measured on the Pixel: granted while an attempt was waiting on ICE, the + group came back 35 s later, once that attempt and the next backoff ran out.""" + out = _run("refused-during") + assert out["reconnectedAt"] - out["backAt"] < 2000, out + + +def test_the_group_page_explains_a_refused_reconnect_and_clears_it(): + source = (STATIC / "group-page.js").read_text(encoding="utf-8") + start = source.index("addReconnectFailureListener(") + refused = source[start:start + 400] + assert "local_network_blocked" in refused and "explainLanRefusal()" in refused + start = source.index("addReconnectListener(", start) + back = source[start:start + 300] + assert "lanLostRef.current" in back and "setError('')" in back + # The buttons ask the reconnect under way rather than tear it down. + assert "transport.retryNow()" in source + for button in ("group.retry", "group.lan_allow", "group.lan_open_settings"): + end = source.index(f"t('{button}')") + assert "retry()" in source[end - 700:end] or "onClick=${retry}" in source[end - 100:end], button -- cgit v1.2.3