aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/tests')
-rw-r--r--packages/meshbay-hub/tests/harness/copy_link_probe.py8
-rw-r--r--packages/meshbay-hub/tests/test_copy_link.py5
-rw-r--r--packages/meshbay-hub/tests/test_search_unreachable_note.py33
3 files changed, 45 insertions, 1 deletions
diff --git a/packages/meshbay-hub/tests/harness/copy_link_probe.py b/packages/meshbay-hub/tests/harness/copy_link_probe.py
index 50d269d..564d277 100644
--- a/packages/meshbay-hub/tests/harness/copy_link_probe.py
+++ b/packages/meshbay-hub/tests/harness/copy_link_probe.py
@@ -69,7 +69,7 @@ const pick = async (label) => {
await wait(50);
return true;
};
-const note = () => (document.querySelector('.copy-link-note') || {}).textContent || '';
+const note = () => (document.querySelector('.page-note') || {}).textContent || '';
const closeMenus = async () => {
document.body.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
await frame();
@@ -177,6 +177,12 @@ const rowNamed = (name) => [...document.querySelectorAll('tr.file-row')]
cases.push({ case: 'photos', tile: Boolean(tile), labels: tileLabels, copied: fromTile,
lightbox_button: Boolean(lb), lightbox_copied: COPIES.at(-1) || null });
+ // Said, then gone (note.js): still up just after, not 2.5 s later.
+ const upAfterCopy = Boolean(document.querySelector('.page-note'));
+ await wait(2700);
+ cases.push({ case: 'note goes', up_after_copy: upAfterCopy,
+ up_later: Boolean(document.querySelector('.page-note')) });
+
parent.postMessage({ cases, logs: LOGS, origin: location.origin }, '*');
} catch (err) {
parent.postMessage({ error: String(err && (err.stack || err)), logs: LOGS }, '*');
diff --git a/packages/meshbay-hub/tests/test_copy_link.py b/packages/meshbay-hub/tests/test_copy_link.py
index 7115d04..22e56e7 100644
--- a/packages/meshbay-hub/tests/test_copy_link.py
+++ b/packages/meshbay-hub/tests/test_copy_link.py
@@ -96,3 +96,8 @@ def test_the_link_is_the_hubs_not_the_pages():
source = (STATIC / "copy-link.js").read_text(encoding="utf-8")
assert "platform.hubOrigin() + '/#' + groupLinkRoute(" in source
assert "location.origin" not in source
+
+
+def test_the_note_goes_by_itself(cases):
+ c = cases["note goes"]
+ assert c["up_after_copy"] is True and c["up_later"] is False
diff --git a/packages/meshbay-hub/tests/test_search_unreachable_note.py b/packages/meshbay-hub/tests/test_search_unreachable_note.py
new file mode 100644
index 0000000..41ed25c
--- /dev/null
+++ b/packages/meshbay-hub/tests/test_search_unreachable_note.py
@@ -0,0 +1,33 @@
+"""
+"N groups unreachable" on the cross-group Search page is said once a pass is
+over, for a few seconds, in the same passing note as "Link copied" (note.js) —
+not left above the results for as long as the page is open.
+
+Source-level, as the other Search wiring checks are: what is held is where the
+line is said and that nothing renders it in the page any more.
+"""
+
+import re
+from pathlib import Path
+
+STATIC = Path(__file__).resolve().parents[1] / "src" / "meshbay_hub" / "static"
+
+
+def test_said_once_the_pass_is_over_and_not_rendered():
+ source = (STATIC / "search-page.js").read_text(encoding="utf-8")
+ assert "import { say } from './note.js';" in source
+ after = source[source.index("const { unreachable } = await fetchAllIndexes("):]
+ after = after[:after.index("})();")]
+ assert re.search(r"if \(cancelled\) return;\s*setFetching\(false\);", after)
+ assert "say(t('search.unreachable', { n: unreachable.length }), UNREACHABLE_NOTE_MS)" in after
+ assert "search-unreachable" not in source
+ ms = int(re.search(r"const UNREACHABLE_NOTE_MS = (\d+);", source).group(1))
+ assert 2000 <= ms <= 8000
+
+
+def test_one_note_for_the_whole_page():
+ note = (STATIC / "note.js").read_text(encoding="utf-8")
+ assert "export function say(text, ms = 2500)" in note
+ assert "clearTimeout(_timer)" in note
+ copy = (STATIC / "copy-link.js").read_text(encoding="utf-8")
+ assert "import { say } from './note.js';" in copy and "_say" not in copy