Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tests/10apidoc/09synced.pl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
sync_timeline_contains
await_sync
await_sync_timeline_contains
await_sync_timeline_or_state_contains
await_sync_presence_contains
);

Expand Down Expand Up @@ -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<check> 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.
Expand Down
47 changes: 47 additions & 0 deletions tests/30rooms/60version_upgrade.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down