Skip to content

Commit 8b90c32

Browse files
committed
Fix usage of typing API
- Timeout is a required parameter when starting typing. - The typing parameter takes a bool not an integer. Signed-off-by: Kurt Roeckx <[email protected]>
1 parent 6ef0340 commit 8b90c32

File tree

4 files changed

+57
-3
lines changed

4 files changed

+57
-3
lines changed

tests/10apidoc/35room-typing.pl

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use JSON qw( decode_json );
2+
13
test "PUT /rooms/:room_id/typing/:user_id sets typing notification",
24
requires => [ local_user_and_room_fixtures() ],
35

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

13-
content => { typing => JSON::true },
15+
content => {
16+
typing => JSON::true,
17+
timeout => 30000,
18+
},
1419
)->then( sub {
1520
my ( $body ) = @_;
1621

@@ -19,3 +24,50 @@
1924
Future->done(1);
2025
});
2126
};
27+
28+
test "PUT /rooms/:room_id/typing/:user_id without timeout fails",
29+
requires => [ local_user_and_room_fixtures() ],
30+
31+
proves => [qw( can_set_room_typing )],
32+
33+
do => sub {
34+
my ( $user, $room_id ) = @_;
35+
36+
do_request_json_for( $user,
37+
method => "PUT",
38+
uri => "/r0/rooms/$room_id/typing/:user_id",
39+
40+
content => { typing => JSON::true },
41+
)->main::expect_http_400()
42+
->then( sub {
43+
my ( $response ) = @_;
44+
my $body = decode_json( $response->content );
45+
assert_eq( $body->{errcode}, "M_BAD_JSON", 'responsecode' );
46+
Future->done( 1 );
47+
});
48+
};
49+
50+
test "PUT /rooms/:room_id/typing/:user_id with invalid json fails",
51+
requires => [ local_user_and_room_fixtures() ],
52+
53+
proves => [qw( can_set_room_typing )],
54+
55+
do => sub {
56+
my ( $user, $room_id ) = @_;
57+
58+
do_request_json_for( $user,
59+
method => "PUT",
60+
uri => "/r0/rooms/$room_id/typing/:user_id",
61+
62+
content => {
63+
typing => 1,
64+
timeout => 30000,
65+
},
66+
)->main::expect_http_400()
67+
->then( sub {
68+
my ( $response ) = @_;
69+
my $body = decode_json( $response->content );
70+
assert_eq( $body->{errcode}, "M_BAD_JSON", 'responsecode' );
71+
Future->done( 1 );
72+
});
73+
};

tests/30rooms/20typing.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
=head1 matrix_typing
66
7-
matrix_typing($user, $room_id, typing => 1, timeout => 30000)->get;
7+
matrix_typing($user, $room_id, typing => JSON::true, timeout => 30000)->get;
88
99
Mark the user as typing.
1010

tests/50federation/43typing.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
room_id => $room_id,
2626
user_id => $creator->user_id,
2727
typing => JSON::true,
28+
timeout => 30000,
2829
},
2930
);
3031
})->then( sub {
@@ -36,6 +37,7 @@
3637
room_id => $room_id,
3738
user_id => $user_id,
3839
typing => JSON::true,
40+
timeout => 30000,
3941
},
4042
);
4143
})->then( sub {

tests/90jira/SYN-516.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
})->then( sub {
2424
( $room_id ) = @_;
2525

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

0 commit comments

Comments
 (0)