Files
instagram-bot/rewrite_tests.py
Marc Mintel fddf14fd67 test(e2e): purge FakeSAENormal and instantiate real Cognitive Stack
PRODUCTION FIX 2026-04-30 12:45:
The entire E2E suite was systematically lying by testing a shell of the bot:
1. FakeSAENormal was masking the actual SituationalAwarenessEngine, meaning structural perception failures (like the 'stuck on Other Profile' bug) were completely invisible to tests.
2. The e2e_cognitive_stack was hardcoded to return None for 80% of engines (NavGraph, ZeroEngine, Telepathic, Darwin, ActiveInference), causing plugins to silently bypass their core logic during tests.
3. get_screenshot_b64 and screenshot() returned None, preventing the VLM stack from even running structural fallback code.

Fix:
- Systematically stripped FakeSAENormal from all 29 E2E workflow tests.
- Built e2e_cognitive_stack_factory to instantiate the REAL Cognitive Stack (GrowthBrain, QNavGraph, ZeroLatencyEngine, etc.) just like in bot_flow.py.
- Patched ONLY the external LLM network requests in conftest.py via mock_llm_network_calls so that structural execution stays 100% real but avoids non-deterministic LLM timeouts.
- Injected a valid 1x1 black image for screenshots.

All 29 E2E tests now execute the true production logic path and pass in 49 seconds.
2026-04-30 12:46:01 +02:00

20 lines
795 B
Python

import os
import glob
import re
for file in glob.glob("tests/e2e/test_workflow_*.py"):
with open(file, "r") as f:
content = f.read()
# Remove FakeSAENormal class definition
content = re.sub(r'class FakeSAENormal:\n(?: {4}.*\n)+', '', content)
# Remove monkeypatch.setattr for SituationalAwarenessEngine
content = re.sub(r' +monkeypatch\.setattr\(\n +["\']GramAddict\.core\.behaviors\.obstacle_guard\.SituationalAwarenessEngine["\'],\n +FakeSAENormal,?\n +\)\n', '', content)
# Also inline ones
content = re.sub(r' +monkeypatch\.setattr\("GramAddict\.core\.behaviors\.obstacle_guard\.SituationalAwarenessEngine", FakeSAENormal\)\n', '', content)
with open(file, "w") as f:
f.write(content)
print("Removed FakeSAENormal from all tests")