<commit_before>test "That sync can be polled for updates",
    requires => [qw( first_api_client can_sync )],

    check => sub {
        my ( $http ) = @_;
        my ( $user, $filter_id, $room_id, $next );

        matrix_register_user_with_filter( $http, {} )->then( sub {
            ( $user, $filter_id ) = @_;
            matrix_create_room( $user )
        })->then( sub {
            ( $room_id ) = @_;
            matrix_sync( $user, filter => $filter_id )
        })->then( sub {
            my ( $body ) = @_;
            $next = $body->{next_batch};
            Future->wait_any(
                Future->needs_all(
                    matrix_sync( $user,
                        filter => $filter_id, since => $next, timeout => 10000
                    ),
                    delay( 0.1 )->then( sub {
                        matrix_send_room_text_message(
                            $user, $room_id, body => "1"
                        )
                    })
                ),
                delay( 10 )->then_fail("Timeout waiting for sync")<commit_msg>We don't need an explicit 10 second timeout, the test runner already provides one<commit_after>test "That sync can be polled for updates",
    requires => [qw( first_api_client can_sync )],

    check => sub {
        my ( $http ) = @_;
        my ( $user, $filter_id, $room_id, $next );

        matrix_register_user_with_filter( $http, {} )->then( sub {
            ( $user, $filter_id ) = @_;
            matrix_create_room( $user )
        })->then( sub {
            ( $room_id ) = @_;
            matrix_sync( $user, filter => $filter_id )
        })->then( sub {
            my ( $body ) = @_;
            $next = $body->{next_batch};
            Future->needs_all(
                matrix_sync( $user,
                    filter => $filter_id, since => $next, timeout => 10000
                ),
                delay( 0.1 )->then( sub {
                    matrix_send_room_text_message(
                        $user, $room_id, body => "1"
                    )
                })
{'fraction_non_alphanumeric': 0.13239573229873908, 'fraction_numerical': 0.009699321047526674, 'mean_word_length': 1.3550228310502284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4119538', 'n_tokens_mistral': 623, 'n_tokens_neox': 581, 'n_words': 139}