fix: V8.4.2.1 — UX-Bug INFO, Test-Assertions, Test-Isolation

Fix 1 (BEFUND 5): INFO-Konflikte senden keine Buttons mehr.
_ask_keyword_conflict_resolution() prüft jetzt ob alle Konflikte
INFO sind → reiner Text-Hinweis ohne Buttons. CRITICAL/WARNING
bekommen weiterhin Buttons.

Fix 2 (BEFUND 6): 3 Test-Assert-Erweiterungen.
test_conflict_buttons_sent_for_context_vs_100 prüft jetzt:
- ℹ️-Emoji im Text
- "Keine Aktion nötig" im Text
- Keine attachments (nur 2 args: room_id, text)

Fix 3 (BEFUND 7): Test-Isolation via /tmp/archivar_test_state.json.
_build_mock_adapter() setzt ARCHIVAR_STATE_PATH auf temp file
und löscht es vor jedem Test — verhindert persistierte
State-Leaks zwischen Testläufen (gleiches Pattern wie V8.4.1).
This commit is contained in:
Bernd (Hermes)
2026-07-15 21:27:01 +02:00
parent 631e3c1db4
commit b83fa35017
2 changed files with 45 additions and 19 deletions
+28 -17
View File
@@ -3384,24 +3384,35 @@ class RocketChatAdapter(BasePlatformAdapter):
f"in {c['room_name']} ({severity}: {explanation})" f"in {c['room_name']} ({severity}: {explanation})"
) )
text = ( # V8.4.2.1: INFO-Konflikte sind reine Hinweise — keine Buttons
f"⚠️ **Keyword-Konflikt erkannt** ({keyword_label}-Keywords):\n\n" all_info = all(c["conflict_type"] == "INFO" for c in conflicts)
+ "\n".join(conflict_lines)
+ "\n\n👉 Möchtest Du die Keywords trotzdem verwenden oder andere wählen?"
)
_build = self._get_build_custom_buttons() if all_info:
buttons = _build( text = (
["1️⃣ Trotzdem verwenden", "2️⃣ Anderes Keyword"], f"ℹ️ **Keyword-Hinweis** ({keyword_label}-Keywords):\n\n"
prefix=f"CONFLICT:{rid}", + "\n".join(conflict_lines)
style="primary", + "\n\n💡 Der Butler wird im anderen Raum nachfragen. Keine Aktion nötig."
) )
attachments = [{ await self._post_message_with_retry(operator_room_id, text)
"color": "#f5a623", else:
"title": "Keyword-Konflikt auflösen", text = (
"actions": buttons, f"⚠️ **Keyword-Konflikt erkannt** ({keyword_label}-Keywords):\n\n"
}] + "\n".join(conflict_lines)
await self._post_message_with_retry(operator_room_id, text, attachments=attachments) + "\n\n👉 Möchtest Du die Keywords trotzdem verwenden oder andere wählen?"
)
_build = self._get_build_custom_buttons()
buttons = _build(
["1️⃣ Trotzdem verwenden", "2️⃣ Anderes Keyword"],
prefix=f"CONFLICT:{rid}",
style="primary",
)
attachments = [{
"color": "#f5a623",
"title": "Keyword-Konflikt auflösen",
"actions": buttons,
}]
await self._post_message_with_retry(operator_room_id, text, attachments=attachments)
async def _ask_onboarding_question(self, operator_room_id: str) -> None: async def _ask_onboarding_question(self, operator_room_id: str) -> None:
"""Sendet die aktuelle Interview-Frage an den Operator.""" """Sendet die aktuelle Interview-Frage an den Operator."""
+17 -2
View File
@@ -192,13 +192,22 @@ def _build_mock_adapter(room_map_path: str):
"""Build a RocketChatAdapter with mocked external dependencies. """Build a RocketChatAdapter with mocked external dependencies.
Uses __new__ to skip __init__ (same pattern as test_v8_3_4.py). Uses __new__ to skip __init__ (same pattern as test_v8_3_4.py).
V8.4.2.1: Isoliert ArchivarState via /tmp/archivar_test_state.json
um persistierte State-Leaks zwischen Testläufen zu verhindern.
""" """
os.environ["MULTIROOM_AGENT"] = "true" os.environ["MULTIROOM_AGENT"] = "true"
os.environ["ARCHIVAR_ROOM_MAP_PATH"] = room_map_path os.environ["ARCHIVAR_ROOM_MAP_PATH"] = room_map_path
os.environ["ARCHIVAR_STATE_PATH"] = "/tmp/archivar_test_state.json"
os.environ["ROCKETCHAT_BASE_URL"] = "https://rocket.example.com" os.environ["ROCKETCHAT_BASE_URL"] = "https://rocket.example.com"
os.environ["ROCKETCHAT_USER"] = "testbot" os.environ["ROCKETCHAT_USER"] = "testbot"
os.environ["ROCKETCHAT_PASSWORD"] = "testpass" os.environ["ROCKETCHAT_PASSWORD"] = "testpass"
# Clean leftover state from previous runs
try:
os.remove("/tmp/archivar_test_state.json")
except FileNotFoundError:
pass
from plugin.adapter import RocketChatAdapter, RocketChatREST from plugin.adapter import RocketChatAdapter, RocketChatREST
from archivar.conversation_history import ConversationHistory from archivar.conversation_history import ConversationHistory
from archivar.multiroom_context import MultiRoomContextRing from archivar.multiroom_context import MultiRoomContextRing
@@ -389,7 +398,7 @@ class TestV842OnboardingConflictResolution(unittest.TestCase):
self.assertIn("WARNUNG", text) self.assertIn("WARNUNG", text)
def test_conflict_buttons_sent_for_context_vs_100(self): def test_conflict_buttons_sent_for_context_vs_100(self):
"""Kontext-Keyword vs 100%-Keyword → INFO-Buttons.""" """Kontext-Keyword vs 100%-Keyword → INFO-Hinweis, KEINE Buttons."""
adapter = _build_mock_adapter(str(self.temp_path)) adapter = _build_mock_adapter(str(self.temp_path))
adapter._post_message_with_retry = AsyncMock(return_value=True) adapter._post_message_with_retry = AsyncMock(return_value=True)
adapter._get_build_custom_buttons = MagicMock(return_value=MagicMock(return_value=[])) adapter._get_build_custom_buttons = MagicMock(return_value=MagicMock(return_value=[]))
@@ -429,8 +438,14 @@ class TestV842OnboardingConflictResolution(unittest.TestCase):
)) ))
self.assertTrue(adapter._post_message_with_retry.called) self.assertTrue(adapter._post_message_with_retry.called)
text = adapter._post_message_with_retry.call_args[0][1] call_args = adapter._post_message_with_retry.call_args
text = call_args[0][1]
self.assertIn("INFO", text) self.assertIn("INFO", text)
# V8.4.2.1: INFO sendet KEINE Buttons — nur Text-Hinweis
self.assertIn("ℹ️", text)
self.assertIn("Keine Aktion nötig", text)
# Keine attachments übergeben
self.assertEqual(len(call_args[0]), 2) # nur (room_id, text), kein attachments
def test_keep_anyway_proceeds_to_next_question(self): def test_keep_anyway_proceeds_to_next_question(self):
"""'Trotzdem verwenden' → Keyword gespeichert, nächste Frage.""" """'Trotzdem verwenden' → Keyword gespeichert, nächste Frage."""