<commit_before><commit_msg>Test that other users can join rooms by room ID<commit_after>test "POST /rooms/:room_id/join can join a room",
   requires => [qw( first_http_client more_users room_id
                    can_initial_sync )],

   do => sub {
      my ( $http, $more_users, $room_id ) = @_;
      my $user = $more_users->[0];

      $http->do_request_json(
         method => "POST",
         uri    => "/rooms/$room_id/join",
         params => { access_token => $user->access_token },

         content => {},
      );
   },

   check => sub {
      my ( $http, $more_users, $room_id ) = @_;
      my $user = $more_users->[0];

      $http->do_request_json(
         method => "GET",
         uri    => "/initialSync",
         params => { access_token => $user->access_token },
      )->then( sub {
         my ( $body ) = @_;

         json_list_ok( $body->{rooms} );

         my $found;
         foreach my $room ( @{ $body->{rooms} } ) {
            json_keys_ok( $room, qw( room_id membership ));

            next unless $room->{room_id} eq $room_id;
            $found++;

            $room->{membership} eq "join" or die "Expected room membership to be 'join'";
         }

         $found or
            die "Failed to find expected room";

         provide can_join_room_by_id => 1;

         Future->done(1);
      });
   };
{'fraction_non_alphanumeric': 0.15219005196733482, 'fraction_numerical': 0.002969561989606533, 'mean_word_length': 1.8559322033898304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, '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': '5805933', 'n_tokens_mistral': 437, 'n_tokens_neox': 422, 'n_words': 103}