Skip to content

Commit

Permalink
Merge pull request #139 from matrix-org/erikj/SYN-589
Browse files Browse the repository at this point in the history
Test for SYN-589, that old left rooms don't get sent down new links
  • Loading branch information
erikjohnston committed Jan 13, 2016
2 parents 8e62fec + b5de90a commit d7a19d5
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tests/31sync/09archived.pl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,75 @@
};


test "Previously left rooms don't appear in the leave section of sync",
requires => [ local_user_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ),
qw( can_sync ) ],

check => sub {
my ( $user, $user2 ) = @_;

my ( $filter_id, $room_id_1, $room_id_2, $next );

my $filter = {
room => { timeline => { limit => 1 }, include_leave => JSON::true }
};

matrix_create_filter( $user, $filter )->then( sub {
( $filter_id ) = @_;

Future->needs_all(
matrix_create_room( $user )->on_done( sub { ( $room_id_1 ) = @_; } ),
matrix_create_room( $user )->on_done( sub { ( $room_id_2 ) = @_; } ),
);
})->then( sub {
matrix_join_room( $user2, $room_id_1 );
})->then( sub {
matrix_join_room( $user2, $room_id_2 );
})->then( sub {
matrix_sync( $user, filter => $filter_id );
})->then( sub {
my ( $body ) = @_;

$next = $body->{next_batch};

matrix_leave_room( $user, $room_id_1 );
})->then( sub {
matrix_sync( $user, filter => $filter_id, since => $next );
})->then( sub {
my ( $body ) = @_;

$next = $body->{next_batch};

matrix_put_room_state( $user2, $room_id_1,
content => { "filler" => $_, membership => "join" },
type => "m.room.member",
state_key => $user2->user_id,
)
})->then( sub {
# Pad out the timeline with filler messages to create a "gap" between
# this sync and the next.
Future->needs_all( map {
matrix_send_room_message( $user2, $room_id_2,
content => { "filler" => $_ },
type => "a.made.up.filler.type",
)
} 0 .. 5 );
})->then( sub {
matrix_sync( $user, filter => $filter_id, since => $next );
})->then( sub {
my ( $body ) = @_;

my $leave = $body->{rooms}{leave};

assert_json_object( $leave );
keys %$leave == 0 or die "Expected no rooms in 'leave' state";

Future->done(1);
});
};



test "Left rooms appear in the leave section of full state sync",
requires => [ local_user_fixture( with_events => 0 ),
qw( can_sync ) ],
Expand Down

0 comments on commit d7a19d5

Please sign in to comment.