Skip to content

Commit

Permalink
test /members (for matrix-org/synapse#3568)
Browse files Browse the repository at this point in the history
  • Loading branch information
ara4n committed Jul 20, 2018
1 parent 4ef6db9 commit 88c27a7
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions tests/30rooms/52members.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
use List::Util qw( first );

test "Can get rooms/{roomId}/members",
requires => [ local_user_fixture(), local_user_fixture(), qw ( can_send_message ) ],

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

matrix_create_and_join_room( [ $user1, $user2 ] )->then( sub {
my ( $room_id ) = @_;

do_request_json_for( $user1,
method => "GET",
uri => "/r0/rooms/$room_id/members",
);
})->then( sub {
my ( $body ) = @_;

assert_json_keys( $body, qw( chunk ) );

assert_room_members_in_state( $body->{chunk}, [
$user1->user_id,
$user2->user_id,
]);

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


test "Can get rooms/{roomId}/members at a given point",
requires => [
local_user_fixture(), local_user_fixture(),
qw ( can_send_message )
],

check => sub {
my ( $user1, $user2 ) = @_;
my ( $room_id, $event_id );

matrix_create_and_join_room( [ $user1 ] )->then( sub {
( $room_id ) = @_;
matrix_send_room_text_message( $user1, $room_id,
body => "Hello world",
);
})->then( sub {
( $event_id ) = @_;
matrix_join_room( $user2, $room_id );
})->then( sub {
matrix_send_room_text_message( $user1, $room_id,
body => "Hello back",
);
})->then( sub {
do_request_json_for( $user1,
method => "GET",
uri => "/r0/rooms/$room_id/members",
params => {
at => $event_id
}
);
})->then( sub {
my ( $body ) = @_;

assert_json_keys( $body, qw( chunk ) );

# as of the first 'Hello world' the only member in the room should be user1
assert_room_members_in_state( $body->{chunk}, [ $user1->user_id ]);

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

0 comments on commit 88c27a7

Please sign in to comment.