update
This commit is contained in:
76
AzA march 2026/_test_contacts_badge_reopen_blank_chat.py
Normal file
76
AzA march 2026/_test_contacts_badge_reopen_blank_chat.py
Normal file
@@ -0,0 +1,76 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Reopen aus Kontakte: kein Fokus auf leeres AzA Chat · Desktop, Office-SSO-Neustart."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
import unittest
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import aza_empfang_webview as ew
|
||||
|
||||
|
||||
class WindowTitleMatchTests(unittest.TestCase):
|
||||
def test_prefix_matches_desktop_false_positive(self):
|
||||
chat = ew._window_title_for_mode(ew._MODE_EMPFANG_CHAT_SHELL)
|
||||
desktop = ew._window_title_for_mode(ew._MODE_DESKTOP_SHELL)
|
||||
self.assertTrue(
|
||||
ew._window_title_matches(desktop, prefixes=(chat,))
|
||||
)
|
||||
self.assertFalse(
|
||||
ew._window_title_matches(desktop, exact_titles=(chat,))
|
||||
)
|
||||
|
||||
def test_exact_matches_chat_only(self):
|
||||
chat = ew._window_title_for_mode(ew._MODE_EMPFANG_CHAT_SHELL)
|
||||
self.assertTrue(ew._window_title_matches(chat, exact_titles=(chat,)))
|
||||
self.assertFalse(
|
||||
ew._window_title_matches(
|
||||
ew._window_title_for_mode(ew._MODE_DESKTOP_SHELL),
|
||||
exact_titles=(chat,),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class FocusEmpfangChatShellReopenTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.focus_src = inspect.getsource(ew.EmpfangWebviewApi.focus_empfang_chat_shell)
|
||||
|
||||
def test_focus_uses_exact_title_not_prefix(self):
|
||||
self.assertIn("exact_titles=(chat_title", self.focus_src)
|
||||
self.assertNotIn("_focus_other_empfang_host_window(prefixes", self.focus_src)
|
||||
|
||||
def test_no_autonomous_login_url_spawn(self):
|
||||
self.assertNotIn("_spawn_empfang_chat_shell_process()", self.focus_src)
|
||||
self.assertNotIn("_build_default_empfang_chat_shell_url", self.focus_src)
|
||||
|
||||
def test_office_ipc_handoff(self):
|
||||
self.assertIn("request_office_open_empfang_chat_shell_ipc", self.focus_src)
|
||||
|
||||
def test_no_desktop_shell_in_reopen_path(self):
|
||||
self.assertNotIn("_MODE_DESKTOP_SHELL", self.focus_src)
|
||||
|
||||
def test_no_direct_subprocess_in_focus(self):
|
||||
count = self.focus_src.count("subprocess.Popen")
|
||||
self.assertEqual(count, 0)
|
||||
|
||||
|
||||
class KontaktPanelHandoffUnchangedTests(unittest.TestCase):
|
||||
def test_kontakt_helper_still_awaits_dm_open(self):
|
||||
html = (Path(__file__).resolve().parent / "web" / "empfang.html").read_text(
|
||||
encoding="utf-8-sig"
|
||||
)
|
||||
idx = html.find("async function kontaktPanelOpenMessagesBadgeInHuelle")
|
||||
self.assertGreater(idx, 0)
|
||||
block = html[idx : idx + 1200]
|
||||
self.assertIn("await apiFetch", block)
|
||||
self.assertIn("focus_empfang_chat_shell", block)
|
||||
dm = block.find("await apiFetch")
|
||||
focus = block.find("focus_empfang_chat_shell")
|
||||
self.assertGreater(focus, dm)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user