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