test(e2e): Fix E2E context generator and harden StoryView plugin

- Updated e2e_workflow_ctx in conftest to structurally parse screen_type
- Fixed StoryViewPlugin to gracefully handle pre-existing story screens
- Resolved 'LIE DETECTED' failure in story test suite
- Validated structural path transitions for story ring and story exit
This commit is contained in:
2026-05-05 01:50:40 +02:00
parent c0cfa24384
commit 39185593dd
3 changed files with 76 additions and 26 deletions

View File

@@ -53,33 +53,38 @@ class StoryViewPlugin(BehaviorPlugin):
except Exception:
count = 1
from GramAddict.core.goap import ScreenType
is_already_in_story = getattr(ctx, "screen_type", None) == ScreenType.STORY_VIEW
# Check for story ring
xml = ctx.context_xml or ctx.device.dump_hierarchy()
xml_lower = xml.lower()
has_story = (
has_story_ring = (
"reel_ring" in xml
or "has an unseen story" in xml_lower
or "has a new story" in xml_lower
or "story von" in xml_lower
)
if not has_story:
if not has_story_ring and not is_already_in_story:
return BehaviorResult(executed=False, metadata={"reason": "no_story"})
# Navigate to story
nav_graph = ctx.cognitive_stack.get("nav_graph")
if not nav_graph:
from GramAddict.core.q_nav_graph import QNavGraph
if not is_already_in_story:
# Navigate to story
nav_graph = ctx.cognitive_stack.get("nav_graph")
if not nav_graph:
from GramAddict.core.q_nav_graph import QNavGraph
nav_graph = QNavGraph(ctx.device)
nav_graph = QNavGraph(ctx.device)
if not nav_graph.do("tap story ring avatar"):
return BehaviorResult(executed=False, metadata={"reason": "nav_failed"})
if not nav_graph.do("tap story ring avatar"):
return BehaviorResult(executed=False, metadata={"reason": "nav_failed"})
# Wait for story to load
if not wait_for_story_loaded(ctx.device, timeout=5):
logger.warning(f"❌ [StoryView] Story failed to open for @{ctx.username}.")
return BehaviorResult(executed=False, metadata={"reason": "load_timeout"})
# Wait for story to load
if not wait_for_story_loaded(ctx.device, timeout=5):
logger.warning(f"❌ [StoryView] Story failed to open for @{ctx.username}.")
return BehaviorResult(executed=False, metadata={"reason": "load_timeout"})
logger.info(f"📸 [StoryView] Viewing @{ctx.username}'s story ({count} segments)...")