diff --git a/tests/unit/test_chat_web.py b/tests/unit/test_chat_web.py index 892fc00..203d9b4 100644 --- a/tests/unit/test_chat_web.py +++ b/tests/unit/test_chat_web.py @@ -226,3 +226,27 @@ def test_immediate_pin_after_response_uses_final_server_revision(): patch = next(body for method,path,body in calls if method == 'PATCH') assert patch['revision'] == 2 browser.close() + + +def test_realtime_voice_is_prominent_on_desktop_and_mobile(): + with sync_playwright() as p: + browser = p.chromium.launch(headless=True) + for width in [1280,390]: + page = browser.new_page(viewport={'width':width,'height':900}) + calls, streams, conversations, messages = fixture(page) + page.goto('https://hope.test/'); page.wait_for_load_state('networkidle') + expect(page.get_by_role('button',name='Talk to Hope',exact=True)).to_be_visible() + page.locator('#primaryInput').fill('Keep this draft while I talk') + page.locator('#talkToHope').click() + expect(page.locator('#legacyVoice')).to_be_visible() + expect(page.locator('#startBtn')).to_be_visible() + expect(page.locator('#voiceModeBtn')).to_have_attribute('aria-pressed','true') + expect(page.locator('#backToChat')).to_be_visible() + page.locator('#backToChat').click() + expect(page.locator('#primaryInput')).to_have_value('Keep this draft while I talk') + expect(page.locator('#talkToHope')).to_be_visible() + assert not any(path == '/token' for method,path,body in calls) + assert page.evaluate('document.documentElement.scrollWidth <= innerWidth') + page.screenshot(path=f'/tmp/hope-talk-visible-{width}.png') + page.close() + browser.close() diff --git a/web/chat.js b/web/chat.js index de407aa..225b4c1 100644 --- a/web/chat.js +++ b/web/chat.js @@ -39,7 +39,8 @@ function adapt() { if (mobile.matches) $('conversationActions').setAttribute('popover', 'auto'); else {$('conversationActions').removeAttribute('popover');} $('chatSidebar').inert = mobile.matches && !$('chatSidebar').classList.contains('drawer-open'); if (!mobile.matches) { $('primaryChat').inert = false; $('legacyVoice').inert = false; $('drawerBackdrop').hidden = true; } } mobile.addEventListener('change', adapt); adapt(); - $('openVoice').onclick = () => { $('primaryChat').hidden = true; $('legacyVoice').hidden = false; if (mobile.matches) drawer(false); $('backToChat').focus(); }; + function showVoice() { $('primaryChat').hidden = true; $('legacyVoice').hidden = false; if (mobile.matches) drawer(false); $('voiceModeBtn').click(); $('startBtn').focus(); } + $('openVoice').onclick = showVoice; $('talkToHope').onclick = showVoice; $('backToChat').onclick = () => { $('primaryChat').hidden = false; $('legacyVoice').hidden = true; $('primaryInput').focus(); }; // Markdown uses DOM text nodes only: HTML is always literal; unsafe URLs never become links. function inline(parent, text) { diff --git a/web/index.html b/web/index.html index b1ae74c..8f45b7b 100644 --- a/web/index.html +++ b/web/index.html @@ -29,7 +29,7 @@
-

New chat

A little space to think.

Ask a question, work through an idea, or start something new.

Your chats are private to your account. Hope can make mistakes.