diff options
Diffstat (limited to 'packages/meshbay-hub/tests/test_network_change.py')
| -rw-r--r-- | packages/meshbay-hub/tests/test_network_change.py | 33 |
1 files changed, 33 insertions, 0 deletions
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 |