tests/test_page.py (1432 bytes)
1 """The first screen: what a visitor sees before choosing a file.""" 2 3 from __future__ import annotations 4 5 import re 6 7 8 def test_the_javascript_switch_is_on_the_first_screen_and_on(client): 9 page = client.get("/").text 10 switch = re.search(r'<input[^>]*\bid="in-browser"[^>]*>', page) 11 assert switch, "the page has no in-browser switch" 12 tag = switch.group(0) 13 # On when the page opens. autocomplete="off" stops a browser from 14 # bringing back an "off" from an earlier visit. 15 assert re.search(r"\schecked\b", tag) and 'autocomplete="off"' in tag 16 17 # Above the drop zone, so that it shows before a file is chosen. 18 dropzone = page.index('id="dropzone"') 19 assert switch.start() < dropzone 20 assert "JavaScript" in page[switch.start():dropzone] 21 22 23 def test_the_browser_mode_note_says_only_that_it_uses_no_cloud_credits(client): 24 # The note under the switch must carry no other message: not the beta 25 # debug-copy disclosure, not the server price, not an offer to turn it off. 26 page = client.get("/").text 27 app = client.get("/app.js").text 28 note = re.search(r'<p[^>]*id="mode-note"[^>]*>(.*?)</p>', page, re.S) 29 assert note 30 assert note.group(1).strip() == "The JavaScript version does not use any cloud credits." 31 assert "'The JavaScript version does not use any cloud credits.'" in app 32 for gone in ("has no limit", "Turn this off", "serverCost"): 33 assert gone not in app