Skip to content
Open
Show file tree
Hide file tree
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
50 changes: 49 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,46 @@
Future->done(1);
});
};

test "PUT /rooms/:room_id/typing/:user_id without timeout fails",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what makes you think timeout is mandatory? https://spec.matrix.org/unstable/client-server-api/#put_matrixclientr0roomsroomidtypinguserid doesn't mark it as required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re #1088 (comment): I don't agree with your interpretation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I think it's required when typing is true are:

  • It says: If false, the timeout key can be omitted., which to me implies that it needs to be present when it's true.
  • It says This tells the server that the user is typing for the next N milliseconds where N is the value specified in the timeout key. That implies to me that we need to have a value.

Note that I'm not the only one interpreting it that way. If you think this is wrong, please fix the specifications. Adding a default value on the server side is easy enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So to clarify it more, those are the options:

typing timeout
true present
true not present
false present
false not present

The can be omitted to me means that both the 3rd and 4th option are valid. Without the sentence, option 3 and 4 are also valid. But since the sentence is there, to me it says that if it's true you can not omit it.

requires => [ local_user_and_room_fixtures() ],

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() ],

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