Skip to content

Commit

Permalink
Fix usage of typing API
Browse files Browse the repository at this point in the history
- Timeout is a required parameter when starting typing.
- The typing parameter takes a bool not an integer.

Signed-off-by: Kurt Roeckx <[email protected]>
  • Loading branch information
kroeckx committed Jul 22, 2021
1 parent ba1157a commit 288f896
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
54 changes: 53 additions & 1 deletion tests/10apidoc/35room-typing.pl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use JSON qw( decode_json );

test "PUT /rooms/:room_id/typing/:user_id sets typing notification",
requires => [ local_user_and_room_fixtures() ],

Expand All @@ -10,7 +12,10 @@
method => "PUT",
uri => "/r0/rooms/$room_id/typing/:user_id",

content => { typing => JSON::true },
content => {
typing => JSON::true,
timeout => 30000,
},
)->then( sub {
my ( $body ) = @_;

Expand All @@ -19,3 +24,50 @@
Future->done(1);
});
};

test "PUT /rooms/:room_id/typing/:user_id without timeout fails",
requires => [ local_user_and_room_fixtures() ],

proves => [qw( can_set_room_typing )],

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

do_request_json_for( $user,
method => "PUT",
uri => "/r0/rooms/$room_id/typing/:user_id",

content => { typing => JSON::true },
)->main::expect_http_400()
->then( sub {
my ( $response ) = @_;
my $body = decode_json( $response->content );
assert_eq( $body->{errcode}, "M_BAD_JSON", 'responsecode' );
Future->done( 1 );
});
};

test "PUT /rooms/:room_id/typing/:user_id with invalid json fails",
requires => [ local_user_and_room_fixtures() ],

proves => [qw( can_set_room_typing )],

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

do_request_json_for( $user,
method => "PUT",
uri => "/r0/rooms/$room_id/typing/:user_id",

content => {
typing => 1,
timeout => 30000,
},
)->main::expect_http_400()
->then( sub {
my ( $response ) = @_;
my $body = decode_json( $response->content );
assert_eq( $body->{errcode}, "M_BAD_JSON", 'responsecode' );
Future->done( 1 );
});
};
2 changes: 1 addition & 1 deletion tests/30rooms/20typing.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

=head1 matrix_typing
matrix_typing($user, $room_id, typing => 1, timeout => 30000)->get;
matrix_typing($user, $room_id, typing => JSON::true, timeout => 30000)->get;
Mark the user as typing.
Expand Down
2 changes: 2 additions & 0 deletions tests/50federation/43typing.pl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
room_id => $room_id,
user_id => $creator->user_id,
typing => JSON::true,
timeout => 30000,
},
);
})->then( sub {
Expand All @@ -36,6 +37,7 @@
room_id => $room_id,
user_id => $user_id,
typing => JSON::true,
timeout => 30000,
},
);
})->then( sub {
Expand Down
2 changes: 1 addition & 1 deletion tests/90jira/SYN-516.pl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
})->then( sub {
( $room_id ) = @_;

matrix_typing( $user, $room_id, typing => 1, timeout => 30000 )
matrix_typing( $user, $room_id, typing => JSON::true, timeout => 30000 )
->SyTest::pass_on_done( "Sent typing notification" );
})->then( sub {
matrix_send_room_message( $user, $room_id,
Expand Down

0 comments on commit 288f896

Please sign in to comment.