Skip to content

Commit

Permalink
Test that leaving wakes up /sync
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Jan 5, 2016
1 parent 598a13f commit a50fc69
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/31sync/08polling.pl
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,50 @@
Future->done(1)
})
};

test "Sync is woken up for leaves",
requires => [ local_user_fixture( with_events => 0 ),
qw( can_sync ) ],

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

my ( $filter_id, $room_id, $next );

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

matrix_create_room( $user );
})->then( sub {
( $room_id ) = @_;

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

$next = $body->{next_batch};
Future->needs_all(
matrix_sync( $user,
filter => $filter_id, since => $next, timeout => 10000
),

delay( 0.1 )->then( sub {
matrix_leave_room(
$user, $room_id
)
}),
)
})->then( sub {
my ( $body, $response, $event_id ) = @_;

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

my $events = $room->{timeline}{events} or
die "Expected an event timeline";
@$events == 1 or
die "Expected one timeline event";

Future->done(1)
})
};

0 comments on commit a50fc69

Please sign in to comment.