-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test unread counts in pushes #224
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,10 +40,20 @@ | |
})->SyTest::pass_on_done( "Bob received invite" ), | ||
|
||
matrix_invite_user_to_room( $alice, $bob, $room_id ), | ||
flush_events_for( $alice ), | ||
) | ||
})->then( sub { | ||
# Bob accepts the invite by joining the room | ||
matrix_join_room( $bob, $room_id ) | ||
})->then( sub { | ||
await_event_for( $alice, filter => sub { | ||
return 1; | ||
})->then( sub { | ||
my ( $event ) = @_; | ||
matrix_advance_room_receipt( $alice, $room_id, | ||
"m.read" => $event->{event_id} | ||
); | ||
}); | ||
})->then( sub { | ||
# Now that Bob has joined the room, we will create a pusher for | ||
# Alice. This may race with Bob joining the room. So the first | ||
|
@@ -93,14 +103,15 @@ | |
my ( $request ) = @_; | ||
my $body = $request->body_from_json; | ||
|
||
log_if_fail "Request body", $body; | ||
log_if_fail "Message push request body", $body; | ||
|
||
assert_json_keys( my $notification = $body->{notification}, qw( | ||
id room_id type sender content devices counts | ||
)); | ||
assert_json_keys( $notification->{counts}, qw( | ||
unread | ||
)); | ||
assert_eq( $notification->{counts}->{unread}, 1, "unread count"); | ||
assert_json_keys( $notification->{devices}[0], qw( | ||
app_id pushkey pushkey_ts data tweaks | ||
)); | ||
|
@@ -112,6 +123,40 @@ | |
die "Unexpected message body"; | ||
|
||
pass "Alice was pushed"; # Alice has gone down the stairs | ||
|
||
Future->needs_all( | ||
await_http_request( "/alice_push", sub { | ||
my ( $request ) = @_; | ||
my $body = $request->body_from_json; | ||
|
||
return unless $body->{notification}{counts}; | ||
return 1; | ||
})->then( sub { | ||
my ( $request ) = @_; | ||
|
||
$request->respond( HTTP::Response->new( 200, "OK", [], "" ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need to be an actually-empty body? You didn't supply a
to have it fill in the content length at least. |
||
Future->done( $request ); | ||
}), | ||
|
||
# Now send a read receipt for that message | ||
matrix_advance_room_receipt( $alice, $notification->{room_id}, | ||
"m.read" => $notification->{event_id} | ||
)->SyTest::pass_on_done( "Receipt sent" ), | ||
) | ||
})->then( sub { | ||
my ( $request ) = @_; | ||
my $body = $request->body_from_json; | ||
my $notification = $body->{notification}; | ||
|
||
log_if_fail "Zero badge push request body", $body; | ||
|
||
assert_json_keys( $notification->{counts}, qw( | ||
unread | ||
)); | ||
assert_eq( $notification->{counts}{unread}, 0, "unread count"); | ||
|
||
pass "Zero badge push received"; | ||
|
||
Future->done(1); | ||
}); | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably don't want to wait for any possible event, because that leads to fragile tests that get upset about things like spurious
m.presence
updates. Consider looking for justm.room.receipt
events maybe?