Skip to content
Merged
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
46 changes: 42 additions & 4 deletions tests/10apidoc/34room-messages.pl
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ sub matrix_send_room_text_message

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

matrix_send_room_text_message_synced( $user, $room_id,
body => "Here is the message content",
)->then( sub {
matrix_sync( $user )
})->then( sub {
my ( $sync_body ) = @_;
my $token = $sync_body->{rooms}->{join}->{$room_id}->{timeline}->{prev_batch};

$token = $sync_body->{rooms}->{join}->{$room_id}->{timeline}->{prev_batch};
do_request_json_for( $user,
method => "GET",
uri => "/v3/rooms/$room_id/messages",
Expand All @@ -158,12 +158,30 @@ sub matrix_send_room_text_message
})->then( sub {
my ( $body ) = @_;

# We should still get events and a "end" key: check they are actually there
assert_json_keys( $body, qw( start end chunk ));
assert_json_list( $body->{chunk} );
$token = $body->{end};

scalar @{ $body->{chunk} } > 0 or
die "Expected some messages but got none at all\n";
})->then( sub {
# Do another call to /messages. This time we don't expect to receive a "end" key
do_request_json_for( $user,
method => "GET",
uri => "/v3/rooms/$room_id/messages",
params => {
dir => "b",
from => $token,
},
)
})->then( sub {
my ( $body ) = @_;

assert_json_keys( $body, qw( start chunk ));
if( exists $body->{end} ) {
die "Unexpected 'end' key in response"
}
Future->done(1);
});
};
Expand All @@ -174,14 +192,15 @@ sub matrix_send_room_text_message

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

matrix_send_room_text_message_synced( $user, $room_id,
body => "Here is the message content",
)->then( sub {
matrix_sync( $user )
})->then( sub {
my ( $sync_body ) = @_;
my $token = $sync_body->{rooms}->{join}->{$room_id}->{timeline}->{prev_batch};
$token = $sync_body->{rooms}->{join}->{$room_id}->{timeline}->{prev_batch};

do_request_json_for( $user,
method => "GET",
Expand All @@ -197,10 +216,12 @@ sub matrix_send_room_text_message
my ( $body ) = @_;

log_if_fail "Body", $body;


# We should still get events and a "end" key: check they are actually there
assert_json_keys( $body, qw( start end state chunk ));
assert_json_list( $body->{chunk} );
assert_json_list( $body->{state} );
$token = $body->{end};

assert_eq( scalar @{$body->{state}}, 1);
assert_eq( $body->{state}[0]{type}, 'm.room.member');
Expand All @@ -209,6 +230,23 @@ sub matrix_send_room_text_message
scalar @{ $body->{chunk} } > 0 or
die "Expected some messages but got none at all\n";

})->then( sub {
# Do another call to /messages. This time we don't expect to receive a "end" key
do_request_json_for( $user,
method => "GET",
uri => "/v3/rooms/$room_id/messages",
params => {
dir => "b",
from => $token,
},
)
})->then( sub {
my ( $body ) = @_;

assert_json_keys( $body, qw( start chunk ));
if( exists $body->{end} ) {
die "Unexpected 'end' key in response"
}
Future->done(1);
});
};
Expand Down