aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests/test_invitation_ui.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/tests/test_invitation_ui.py')
-rw-r--r--packages/meshbay-hub/tests/test_invitation_ui.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/packages/meshbay-hub/tests/test_invitation_ui.py b/packages/meshbay-hub/tests/test_invitation_ui.py
new file mode 100644
index 0000000..99538e9
--- /dev/null
+++ b/packages/meshbay-hub/tests/test_invitation_ui.py
@@ -0,0 +1,66 @@
+"""
+The two answers a person now gives, in the real application, in both engines.
+
+An invitee answers an invitation on the home page (harness/invitation_probe.py);
+a group owner answers a node that asked to host the group, and sees who was
+invited and has not answered (harness/group_hosts_probe.py). The hub side is
+`test_invitations_and_hosts.py`; this is where it meets the interface.
+"""
+
+import json
+import shutil
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+
+HARNESS = Path(__file__).parent / "harness"
+BINARY = {"chrome": "google-chrome", "firefox": "firefox"}
+
+
+def _run(probe: str, engine: str):
+ if shutil.which(BINARY[engine]) is None:
+ pytest.skip(f"{engine} is not available")
+ proc = subprocess.run([sys.executable, str(HARNESS / probe), "--engine", engine],
+ capture_output=True, text=True, timeout=240)
+ assert proc.returncode == 0, f"probe failed: {proc.stdout}{proc.stderr}"
+ return json.loads(proc.stdout)
+
+
+@pytest.fixture(scope="module", params=["chrome", "firefox"])
+def invitation(request):
+ return {c["case"]: c for c in _run("invitation_probe.py", request.param)}
+
+
+@pytest.fixture(scope="module", params=["chrome", "firefox"])
+def hosts(request):
+ return _run("group_hosts_probe.py", request.param)
+
+
+def test_an_invitation_is_listed_with_its_two_answers(invitation):
+ for c in invitation.values():
+ assert "error" not in c, c["error"]
+ assert c["listed"] and c["buttons"] == 2
+
+
+def test_accepting_joins_and_shows_the_group(invitation):
+ c = invitation["accept"]
+ assert c["answer_call"] == [
+ "POST /v1/groups/0f8fad5b-d9cb-469f-a165-70867728950e/invitation/accept"]
+ assert c["group_card"] and not c["invitation_still_shown"]
+
+
+def test_declining_leaves_no_group(invitation):
+ c = invitation["decline"]
+ assert c["answer_call"][0].endswith("/invitation/decline")
+ assert not c["group_card"] and not c["invitation_still_shown"]
+
+
+def test_the_owner_sees_the_invited_and_approves_a_host(hosts):
+ assert "error" not in hosts, hosts.get("error")
+ assert hosts["invited_row"]
+ assert hosts["host_rows"] == 2
+ assert hosts["buttons_on_request"] == 2 # approve and refuse
+ assert hosts["buttons_on_approved"] == 1 # refuse only
+ assert hosts["decision"] == ["POST /v1/groups/g1/hosts/n-asking"]