Skip to content

Commit

Permalink
Retry getting unread counts (#1330)
Browse files Browse the repository at this point in the history
  • Loading branch information
S7evinK authored Jan 20, 2023
1 parent 7f2e85b commit d1c931a
Showing 1 changed file with 41 additions and 30 deletions.
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);
});
}
})
};

0 comments on commit d1c931a

Please sign in to comment.