feat(navigation): add structural identity and transitions for NOTIFICATIONS trap
This commit is contained in:
@@ -141,6 +141,7 @@ class TestScreenTopologyBackTransitions:
|
||||
ScreenType.FOLLOW_LIST,
|
||||
ScreenType.STORY_VIEW,
|
||||
ScreenType.COMMENTS,
|
||||
ScreenType.NOTIFICATIONS,
|
||||
):
|
||||
# These are "leaf" screens with a deterministic parent — OK to keep
|
||||
continue
|
||||
|
||||
39
tests/tdd/test_gallery_trap_guard.py
Normal file
39
tests/tdd/test_gallery_trap_guard.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from GramAddict.core.perception.screen_identity import ScreenIdentity, ScreenType
|
||||
|
||||
|
||||
def test_gallery_screen_is_modal():
|
||||
"""
|
||||
Test that the Gallery/New Post screen is correctly identified as a MODAL,
|
||||
preventing it from being hallucinated as POST_DETAIL or HOME_FEED.
|
||||
"""
|
||||
xml_dump = """<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
|
||||
<hierarchy rotation="0">
|
||||
<node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.instagram.android" bounds="[0,0][1080,2400]">
|
||||
<node index="0" text="New post" resource-id="" class="android.widget.TextView" bounds="[0,0][100,100]" />
|
||||
<node index="1" text="" resource-id="com.instagram.android:id/gallery_grid_item_thumbnail" class="android.widget.Button" content-desc="Selected media number 1 Photo thumbnail created on 3 May 2026 10:30" bounds="[0,100][500,600]" />
|
||||
<node index="2" text="" resource-id="com.instagram.android:id/next_button_textview" class="android.widget.Button" content-desc="Next" bounds="[900,0][1080,100]" />
|
||||
</node>
|
||||
</hierarchy>
|
||||
"""
|
||||
identity = ScreenIdentity("bot_user")
|
||||
result = identity.identify(xml_dump)
|
||||
|
||||
assert result["screen_type"] == ScreenType.MODAL
|
||||
|
||||
|
||||
def test_camera_screen_is_modal():
|
||||
"""
|
||||
Test that the Camera creation screen is correctly identified as a MODAL.
|
||||
"""
|
||||
xml_dump = """<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
|
||||
<hierarchy rotation="0">
|
||||
<node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.instagram.android" bounds="[0,0][1080,2400]">
|
||||
<node index="0" text="" resource-id="com.instagram.android:id/camera_cancel_button" class="android.widget.ImageView" bounds="[0,0][100,100]" />
|
||||
<node index="1" text="" resource-id="com.instagram.android:id/quick_capture" class="android.widget.FrameLayout" bounds="[0,100][1080,2400]" />
|
||||
</node>
|
||||
</hierarchy>
|
||||
"""
|
||||
identity = ScreenIdentity("bot_user")
|
||||
result = identity.identify(xml_dump)
|
||||
|
||||
assert result["screen_type"] == ScreenType.MODAL
|
||||
22
tests/tdd/test_notifications_screen.py
Normal file
22
tests/tdd/test_notifications_screen.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from GramAddict.core.perception.screen_identity import ScreenIdentity, ScreenType
|
||||
|
||||
|
||||
def test_notifications_screen_identification():
|
||||
"""
|
||||
Test that the Notifications/Activity screen is correctly identified,
|
||||
preventing it from being hallucinated as POST_DETAIL.
|
||||
"""
|
||||
xml_dump = """<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
|
||||
<hierarchy rotation="0">
|
||||
<node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.instagram.android" bounds="[0,0][1080,2400]">
|
||||
<node index="0" text="Notifications" resource-id="com.instagram.android:id/action_bar_title" class="android.widget.TextView" bounds="[0,0][1080,100]" />
|
||||
<node index="1" text="User liked your photo." resource-id="com.instagram.android:id/row_newsfeed_text" class="android.widget.TextView" bounds="[100,100][1000,200]" />
|
||||
<node index="2" text="" resource-id="com.instagram.android:id/newsfeed_tab" selected="true" class="android.widget.FrameLayout" bounds="[600,2300][800,2400]" />
|
||||
</node>
|
||||
</hierarchy>
|
||||
"""
|
||||
identity = ScreenIdentity("bot_user")
|
||||
result = identity.identify(xml_dump)
|
||||
|
||||
assert result["screen_type"] == ScreenType.NOTIFICATIONS
|
||||
assert "tap home tab" in result["available_actions"] or "press back" in result["available_actions"]
|
||||
@@ -28,7 +28,8 @@ def test_sae_detects_obstacle_keyboard():
|
||||
xml_with_keyboard = """<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
|
||||
<hierarchy rotation="0">
|
||||
<node index="0" package="com.instagram.android" resource-id="" text="" content-desc="" />
|
||||
<node index="1" package="com.google.android.inputmethod.latin" resource-id="com.google.android.inputmethod.latin:id/keyboard_view" text="" content-desc="Keyboard" />
|
||||
<node index="1" class="android.widget.EditText" focused="true" />
|
||||
<node index="2" package="com.google.android.inputmethod.latin" resource-id="com.google.android.inputmethod.latin:id/keyboard_view" text="" content-desc="Keyboard" />
|
||||
</hierarchy>
|
||||
"""
|
||||
|
||||
@@ -45,7 +46,8 @@ def test_obstacle_guard_dismisses_keyboard():
|
||||
xml_with_keyboard = """<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
|
||||
<hierarchy rotation="0">
|
||||
<node index="0" package="com.instagram.android" resource-id="" text="" content-desc="" />
|
||||
<node index="1" package="com.google.android.inputmethod.latin" resource-id="com.google.android.inputmethod.latin:id/keyboard_view" text="" content-desc="Keyboard" />
|
||||
<node index="1" class="android.widget.EditText" focused="true" />
|
||||
<node index="2" package="com.google.android.inputmethod.latin" resource-id="com.google.android.inputmethod.latin:id/keyboard_view" text="" content-desc="Keyboard" />
|
||||
</hierarchy>
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user