blob: 41ed25c0a8a73e67ddc6d28716384be2a9f37c7b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
|