Skip to content
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

Retry getting unread counts #1330

Merged
merged 1 commit into from
Jan 20, 2023
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
71 changes: 41 additions & 30 deletions tests/61push/03_unread_count.pl
Original file line number Diff line number Diff line change
Expand Up @@ -68,38 +68,46 @@ sub user_with_push_rule_fixture

matrix_advance_room_receipt_synced( $user1, $room_id, "m.read" => $event_id );
})->then( sub {
matrix_sync( $user1 );
})->then( sub {
my ( $body ) = @_;
retry_until_success {
matrix_sync( $user1 )->then( sub {
my ( $body ) = @_;

my $room = $body->{rooms}{join}{$room_id};
log_if_fail "room in sync response", $room;
my $room = $body->{rooms}{join}{$room_id};

assert_json_keys( $room, "unread_notifications" );
my $unread = $room->{unread_notifications};
assert_json_keys( $unread, $counter );
assert_json_keys( $room, "unread_notifications" );
my $unread = $room->{unread_notifications};
assert_json_keys( $unread, $counter );
log_if_fail "room notifications:", $unread;

$unread->{$counter} == 0
or die "Expected $counter to be 0";

$unread->{$counter} == 0
or die "Expected $counter to be 0";

Future->done(1);
});
}
})->then( sub {
matrix_send_room_text_message_synced( $user2, $room_id,
body => "Test message 2",
);
})->then( sub {
matrix_sync( $user1 );
})->then( sub {
my ( $body ) = @_;
retry_until_success {
matrix_sync( $user1 )->then( sub {
my ( $body ) = @_;

my $room = $body->{rooms}{join}{$room_id};
my $room = $body->{rooms}{join}{$room_id};

assert_json_keys( $room, "unread_notifications" );
my $unread = $room->{unread_notifications};
assert_json_keys( $unread, $counter );
assert_json_keys( $room, "unread_notifications" );
my $unread = $room->{unread_notifications};
assert_json_keys( $unread, $counter );

$unread->{$counter} == 1
or die "Expected $counter to be 1";
log_if_fail "room notifications:", $unread;
$unread->{$counter} == 1
or die "Expected $counter to be 1";

Future->done(1);
Future->done(1);
});
}
});
};
}
Expand Down Expand Up @@ -149,19 +157,22 @@ sub user_with_push_rule_fixture
body => "Test message 2",
);
})->then( sub {
matrix_sync( $user1 );
})->then( sub {
my ( $body ) = @_;
retry_until_success {
matrix_sync( $user1 )->then( sub {
my ( $body ) = @_;

my $room = $body->{rooms}{join}{$room_id};
my $room = $body->{rooms}{join}{$room_id};

assert_json_keys( $room, "unread_notifications" );
my $unread = $room->{unread_notifications};
assert_json_keys( $unread, "highlight_count" );
assert_json_keys( $room, "unread_notifications" );
my $unread = $room->{unread_notifications};
assert_json_keys( $unread, "highlight_count" );

$unread->{highlight_count} == 1
or die "Expected unread highlight count to be 1";
log_if_fail "room notifications:", $unread;
$unread->{highlight_count} == 1
or die "Expected unread highlight count to be 1";

Future->done(1);
Future->done(1);
});
}
})
};