@@ -594,8 +594,7 @@ def test_map_content_trait_as_dict_camelizes_child_keys() -> None:
594594 assert data ["robotPosition" ] == {"x" : 25875 , "y" : 26125 }
595595
596596
597- @pytest .mark .parametrize ("trace_first" , [False , True ])
598- def test_current_room_tracks_latest_fixture_pose_and_map (trace_first : bool ) -> None :
597+ def test_current_room_tracks_latest_fixture_pose_and_map () -> None :
599598 """Current room and robot position consume the same latest map/trace inputs."""
600599 map_dps = MapDpsTrait ()
601600 trait = _map_trait (map_dps )
@@ -604,14 +603,9 @@ def test_current_room_tracks_latest_fixture_pose_and_map(trace_first: bool) -> N
604603 )
605604 trace = Q10TracePacket (points = [Q10Point (100 , 60 )])
606605 assert trait .current_room is None
607- if trace_first :
608- trait .update_from_trace_packet (trace )
609- assert trait .current_room is None
610- trait .update_from_map_packet (packet )
611- else :
612- trait .update_from_map_packet (packet )
613- assert trait .current_room is None
614- trait .update_from_trace_packet (trace )
606+ trait .update_from_map_packet (packet )
607+ assert trait .current_room is None
608+ trait .update_from_trace_packet (trace )
615609 assert trait .current_room == packet .rooms [1 ]
616610 assert trait .robot_position == trace .points [- 1 ].to_roborock ()
617611 assert trait .as_dict ()["currentRoom" ] == packet .rooms [1 ].as_dict ()
@@ -624,6 +618,20 @@ def test_current_room_tracks_latest_fixture_pose_and_map(trace_first: bool) -> N
624618 assert trait .current_room is None
625619
626620
621+ def test_map_arrival_resolves_current_room_from_existing_fixture_trace () -> None :
622+ """A map arriving after the live trace resolves its latest robot pose."""
623+ trait = _map_trait ()
624+ packet = replace (
625+ parse_map_packet (FIXTURE .read_bytes ()), header_calibration = Q10HeaderCalibration (0 , 50 , 5 , - 1 , - 1 , 0 )
626+ )
627+ trace = Q10TracePacket (points = [Q10Point (100 , 60 )])
628+ trait .update_from_trace_packet (trace )
629+ assert trait .current_room is None
630+ trait .update_from_map_packet (packet )
631+ assert trait .current_room == packet .rooms [1 ]
632+ assert trait .robot_position == trace .points [- 1 ].to_roborock ()
633+
634+
627635@pytest .mark .parametrize ("status" , [YXDeviceState .CHARGING , YXDeviceState .EMPTYING_THE_BIN ])
628636def test_docking_clears_room_and_ignores_late_fixture_trace (status : YXDeviceState ) -> None :
629637 map_dps = MapDpsTrait ()
0 commit comments