@@ -76,7 +76,7 @@ def test_not_in_room(self) -> None:
7676 """
7777 Upgrading a room should work fine.
7878 """
79- # THe user isn't in the room.
79+ # The user isn't in the room.
8080 roomless = self .register_user ("roomless" , "pass" )
8181 roomless_token = self .login (roomless , "pass" )
8282
@@ -263,3 +263,33 @@ def test_space(self) -> None:
263263 self .assertIn ((EventTypes .SpaceChild , self .room_id ), state_ids )
264264 # The child that was removed should not be copied over.
265265 self .assertNotIn ((EventTypes .SpaceChild , old_room_id ), state_ids )
266+
267+ def test_custom_room_type (self ) -> None :
268+ """Test upgrading a room that has a custom room type set."""
269+ test_room_type = "com.example.my_custom_room_type"
270+
271+ # Create a room with a custom room type.
272+ room_id = self .helper .create_room_as (
273+ self .creator ,
274+ tok = self .creator_token ,
275+ extra_content = {
276+ "creation_content" : {EventContentFields .ROOM_TYPE : test_room_type }
277+ },
278+ )
279+
280+ # Upgrade the room!
281+ channel = self ._upgrade_room (room_id = room_id )
282+ self .assertEqual (200 , channel .code , channel .result )
283+ self .assertIn ("replacement_room" , channel .json_body )
284+
285+ new_room_id = channel .json_body ["replacement_room" ]
286+
287+ state_ids = self .get_success (self .store .get_current_state_ids (new_room_id ))
288+
289+ # Ensure the new room is the same type as the old room.
290+ create_event = self .get_success (
291+ self .store .get_event (state_ids [(EventTypes .Create , "" )])
292+ )
293+ self .assertEqual (
294+ create_event .content .get (EventContentFields .ROOM_TYPE ), test_room_type
295+ )
0 commit comments