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"]
