""" Sprint 21 Tests: Send button polish — hidden until content, pop-in animation, icon-only circle design. """ import re import urllib.request BASE = "http://127.0.0.1:8788" def get_text(path): with urllib.request.urlopen(BASE + path, timeout=10) as r: return r.read().decode(), r.status # ── index.html ──────────────────────────────────────────────────────────── def test_send_button_present(): """btnSend must still exist in the DOM.""" html, status = get_text("/") assert status == 200 assert 'id="btnSend"' in html def test_send_button_hidden_by_default(): """btnSend must start hidden (display:none) — only shown when there is content.""" html, _ = get_text("/") btn_match = re.search(r'id="btnSend"[^>]*>', html) assert btn_match, "btnSend element not found" assert 'display:none' in btn_match.group(0) def test_send_button_no_text_label(): """Send button must be icon-only — no visible 'Send' text label.""" html, _ = get_text("/") # Find the full button element (from opening tag to closing tag) btn_open_end = html.find('>', html.find('id="btnSend"')) + 1 btn_end = html.find('', btn_open_end) + len('') btn_inner = html[btn_open_end:btn_end] # Strip SVG content and any remaining tags; check visible text no_svg = re.sub(r']*>.*?', '', btn_inner, flags=re.DOTALL) visible_text = re.sub(r'<[^>]+>', '', no_svg).strip() assert visible_text == '', f"Send button has visible text: {visible_text!r}" def test_send_button_has_svg_icon(): """Send button must have an SVG icon.""" html, _ = get_text("/") btn_start = html.find('id="btnSend"') btn_end = html.find('', btn_start) + len('') btn_html = html[btn_start:btn_end] assert ']*>', html) assert btn_match assert 'title=' in btn_match.group(0) def test_send_button_svg_arrow_up(): """Send button SVG should use an upward arrow (line + polyline or path).""" html, _ = get_text("/") btn_start = html.find('id="btnSend"') btn_end = html.find('', btn_start) + len('') btn_html = html[btn_start:btn_end] # Must have some directional shape element has_shape = ('