create(); $participant = User::factory()->create([ 'avatar_uri' => 'avatars/participant.png', 'xp' => 450, ]); $hunt = Hunts::withoutSyncingToSearch(fn () => Hunts::factory()->create([ 'title' => 'Treasure hunt', ])); $hunt->participants()->attach($participant->id, [ 'current_step_number' => 1, 'status' => 'in_progress', ]); HuntSteps::factory()->create([ 'hunt_id' => $hunt->id, 'step_number' => 1, 'title' => 'First step', 'xp' => 125, ]); HuntSteps::factory()->create([ 'hunt_id' => $hunt->id, 'step_number' => 2, 'title' => 'Second step', 'xp' => 75, ]); $response = $this ->actingAs($user, 'sanctum') ->getJson("/api/hunts/{$hunt->id}"); $response ->assertOk() ->assertJson(fn (AssertableJson $json) => $json ->where('id', $hunt->id) ->where('title', 'Treasure hunt') ->where('xp', 200) ->has('participants', 1) ->where('participants.0.id', $participant->id) ->where('participants.0.username', $participant->username) ->has('steps', 2) ->etc() ); });