Skip to content

Commit

Permalink
Merge pull request #1160 from S7evinK/deprecated-events-tests
Browse files Browse the repository at this point in the history
Update tests using `/events` to use `/sync`
  • Loading branch information
kegsay authored Nov 1, 2021
2 parents 2588826 + c30d665 commit 2b106fe
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 65 deletions.
36 changes: 14 additions & 22 deletions tests/90jira/SYN-115.pl → tests/50federation/44presence.pl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use Future::Utils qw( repeat );

multi_test "New federated private chats get full presence information (SYN-115)",
# TODO: deprecated endpoint used in this test
requires => [ local_user_fixture(), remote_user_fixture( with_events => 1 ),
qw( can_create_private_room )],

Expand Down Expand Up @@ -29,15 +28,12 @@
})->then( sub {

# Bob should receive the invite
await_event_for( $bob, filter => sub {
my ( $event ) = @_;
return unless $event->{type} eq "m.room.member" and
$event->{room_id} eq $room_id and
$event->{state_key} eq $bob->user_id and
$event->{content}{membership} eq "invite";

return 1;
})->SyTest::pass_on_done( "Received invite" )
await_sync( $bob, check => sub {
my ( $body ) = @_;

return 0 unless exists $body->{rooms}{invite}{$room_id};
return $body->{rooms}{invite}{$room_id};
})->SyTest::pass_on_done( "Bob received invite" ),
})->then( sub {

# Bob accepts the invite by joining the room
Expand All @@ -54,22 +50,18 @@
my %presence_by_userid;

my $f = repeat {
my $is_initial = !$_[0];

do_request_json_for( $user,
method => "GET",
uri => $is_initial ? "/r0/initialSync" : "/r0/events",
params => { from => $user->eventstream_token, timeout => 500 * $TIMEOUT_FACTOR }
)->then( sub {
await_sync_presence_contains( $user, check => sub {
my ( $event ) = @_;
return unless $event->{type} eq "m.presence";
return 1;
})->then( sub {
my ( $body ) = @_;
$user->eventstream_token = $body->{end};

my @presence = $is_initial
? @{ $body->{presence} }
: grep { $_->{type} eq "m.presence" } @{ $body->{chunk} };
my @presence = @{ $body->{presence}{events} };

foreach my $event ( @presence ) {
my $user_id = $event->{content}{user_id};

my $user_id = $event->{sender};
pass "User ${\$user->user_id} received presence for $user_id";
$presence_by_userid{$user_id} = $event;
}
Expand Down
25 changes: 13 additions & 12 deletions tests/61push/01message-pushed.pl
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ sub matrix_set_pusher {
# We also wait for the push notification for it

Future->needs_all(
await_event_for( $bob, filter => sub {
my ( $event ) = @_;
return unless $event->{type} eq "m.room.member" and
$event->{room_id} eq $room_id and
$event->{state_key} eq $bob->user_id and
$event->{content}{membership} eq "invite";
return 1;
await_sync( $bob, check => sub {
my ( $body ) = @_;

return 0 unless exists $body->{rooms}{invite}{$room_id};
return $body->{rooms}{invite}{$room_id};
})->SyTest::pass_on_done( "Bob received invite" ),

matrix_invite_user_to_room( $alice, $bob, $room_id ),
Expand All @@ -69,14 +67,17 @@ sub matrix_set_pusher {
# Bob accepts the invite by joining the room
matrix_join_room( $bob, $room_id )
})->then( sub {
await_event_for( $alice, filter => sub {
my ( $event ) = @_;
return unless $event->{type} eq "m.room.member";
return 1;
my $join_event;
await_sync_timeline_contains( $alice, $room_id, check => sub {
my ( $event ) = @_;
return unless $event->{type} eq "m.room.member";
return unless $event->{content}{membership} eq "join";
$join_event = $event;
return 1;
})->then( sub {
my ( $event ) = @_;
matrix_advance_room_receipt( $alice, $room_id,
"m.read" => $event->{event_id}
"m.read" => $join_event->{event_id}
);
});
})->then( sub {
Expand Down
31 changes: 0 additions & 31 deletions tests/90jira/SYN-202.pl

This file was deleted.

0 comments on commit 2b106fe

Please sign in to comment.