diff --git a/tests/10apidoc/09synced.pl b/tests/10apidoc/09synced.pl index df1add021..c35df4935 100644 --- a/tests/10apidoc/09synced.pl +++ b/tests/10apidoc/09synced.pl @@ -6,6 +6,7 @@ sync_timeline_contains await_sync await_sync_timeline_contains + await_sync_timeline_or_state_contains await_sync_presence_contains ); @@ -181,6 +182,30 @@ sub await_sync_timeline_contains { ) } +=head2 await_sync_timeline_or_state_contains + +Waits for something to appear in a the timeline or the state of a particular +room, see await_sync for details. + +The C function gets given individual events. + +=cut + +sub await_sync_timeline_or_state_contains { + my ( $user, $room_id, %params ) = @_; + + my $check = delete $params{check} or die "Must supply a 'check' param"; + + await_sync( $user, + check => sub { + my ( $body ) = @_; + + sync_timeline_contains( $body, $room_id, $check ) || sync_room_contains( $body, $room_id, "state", $check ) + }, + %params, + ) +} + =head2 await_sync_presence_contains Waits for presence events to come down sync, see await_sync for details. diff --git a/tests/30rooms/60version_upgrade.pl b/tests/30rooms/60version_upgrade.pl index 212199257..520ad0521 100644 --- a/tests/30rooms/60version_upgrade.pl +++ b/tests/30rooms/60version_upgrade.pl @@ -408,6 +408,53 @@ sub upgrade_room_synced { }; +test "/upgrade copies ban events to the new room", + requires => [ + local_user_and_room_fixtures(), + qw( can_upgrade_room_version ), + ], + + do => sub { + my ( $creator, $room_id ) = @_; + my ( $new_room_id ); + + my $content = { + membership => "ban", + }; + + matrix_put_room_state( + $creator, $room_id, + type => "m.room.member", + content => $content, + state_key => '@bob:matrix.org', + )->then( sub { + matrix_sync( $creator ); + })->then( sub { + upgrade_room_synced( + $creator, $room_id, + new_version => $TEST_NEW_VERSION, + ); + })->then( sub { + ( $new_room_id, ) = @_; + + await_sync_timeline_or_state_contains( $creator, $new_room_id, check => sub { + my ( $event ) = @_; + + return unless $event->{type} eq "m.room.member"; + return unless $event->{state_key} eq "\@bob:matrix.org"; + + assert_deeply_eq( + $event->{content}, + $content, + "no ban in replacement room", + ); + + return 1; + }); + }); + }; + + test "/upgrade moves aliases to the new room", requires => [ $main::HOMESERVER_INFO[0],