summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests/harness/group_tab_probe.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-15 02:48:25 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-15 02:48:25 +0200
commit99f95dadee1a3c892bb0bc87e3564f71d07c88e0 (patch)
tree47691af252accd7097c0d7f58a9c2d44c10fb6ae /packages/meshbay-hub/tests/harness/group_tab_probe.py
parentacb0d666540dacb092f596dada25822d1d0466f0 (diff)
downloadmeshbay-0.14.tar.gz
fix(ui): a group opened directly lands on the preferred app once preferences load0.14
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XuNrwLf5EFWCMHzfoEvnpm
Diffstat (limited to 'packages/meshbay-hub/tests/harness/group_tab_probe.py')
-rw-r--r--packages/meshbay-hub/tests/harness/group_tab_probe.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/packages/meshbay-hub/tests/harness/group_tab_probe.py b/packages/meshbay-hub/tests/harness/group_tab_probe.py
index da1e8d1..473bcdc 100644
--- a/packages/meshbay-hub/tests/harness/group_tab_probe.py
+++ b/packages/meshbay-hub/tests/harness/group_tab_probe.py
@@ -40,8 +40,17 @@ CASES = [
("preferred app absent", "music", ["chat", "files"]),
("preferred app present", "video", ["chat", "files", "video"]),
("preference names nothing real", "nonsense", ["files", "music"]),
+ # The preferences are fetched by app.js after sign-in, so a group opened
+ # directly (a reload, a link) mounts before they arrive.
+ ("preference arrives after the group opened", "video", ["chat", "files", "video"]),
+ ("tab chosen before the preference arrives", "video", ["chat", "files", "video"]),
]
+# How each case delivers the preference: at mount, or after mount — and, for
+# the second, after the reader has already clicked Files.
+LATE = {"preference arrives after the group opened"}
+CLICKED_FIRST = {"tab chosen before the preference arrives"}
+
FRAME = r"""<!doctype html><html><head><meta charset=utf-8>
<link rel="stylesheet" href="/style.css"></head><body>
<div id="root"></div>
@@ -69,9 +78,19 @@ import { initLocale } from '/i18n.js';
import { GroupPage } from '/group-page.js';
await initLocale();
-render(html`<${GroupPage} groupId="g1" token="t" username="me" userId="u1"
+const draw = (prefs) => render(html`<${GroupPage} groupId="g1" token="t" username="me" userId="u1"
group=${{ id: 'g1', name: 'a group', owner_username: 'me', is_admin: true }}
- userPrefs=${{ default_tab: %(pref)s }} />`, document.getElementById('root'));
+ userPrefs=${prefs} />`, document.getElementById('root'));
+const prefs = { default_tab: %(pref)s };
+if (%(late)s || %(clicked)s) {
+ draw({});
+ if (%(clicked)s) {
+ setTimeout(() => document.querySelectorAll('.group-tabs .group-tab')[1].click(), 400);
+ }
+ setTimeout(() => draw(prefs), 800);
+} else {
+ draw(prefs);
+}
setTimeout(() => {
const tabs = [...document.querySelectorAll('.group-tabs .group-tab')];
@@ -137,7 +156,10 @@ class H(http.server.BaseHTTPRequestHandler):
_, pref, enabled = CASES[index]
self._send((FRAME % {"index": index,
"pref": json.dumps(pref),
- "enabled": json.dumps(enabled)}).encode(),
+ "enabled": json.dumps(enabled),
+ "late": json.dumps(CASES[index][0] in LATE),
+ "clicked": json.dumps(CASES[index][0] in CLICKED_FIRST),
+ }).encode(),
"text/html; charset=utf-8")
elif path == "/v1/groups/g1/nodes":
self._send(b'{"nodes": [{"node_id": "n1"}]}', "application/json")