How to get all users with Author role capabilities?

Here’s a way to collect roles with the publish_posts capability:

$roles__in = [];
foreach( wp_roles()->roles as $role_slug => $role )
{
    if( ! empty( $role['capabilities']['publish_posts'] ) )
        $roles__in[] = $role_slug;
}

and then we can query users with these roles:

if( $roles__in )
    $users = get_users( [ 'roles__in' => $roles__in, 'fields' => 'ids' ] );

where we might need pagination for large amount of users.

One can also loop over few users and check with:

user_can( $user, 'publish_posts' )

See docs here.