create(); $to = Destination::factory()->create(); PopularRoute::factory()->create([ 'from_destination_id' => $from->id, 'to_destination_id' => $to->id, 'description' => 'A scenic drive.', 'mm_description' => 'သာယာသောခရီးစဉ်။', 'is_active' => true, ]); PopularRoute::factory()->create(['is_active' => false]); $this->getJson('/api/v1/popular-routes') ->assertSuccessful() ->assertJsonCount(1, 'data') ->assertJsonPath('data.0.from_destination.id', $from->id) ->assertJsonPath('data.0.to_destination.id', $to->id) ->assertJsonPath('data.0.description', 'A scenic drive.') ->assertJsonPath('data.0.mm_description', 'သာယာသောခရီးစဉ်။'); }); test('the nested destinations only expose id, name and mm_name, not the full catalog fields', function () { $from = Destination::factory()->create(); $to = Destination::factory()->create(); PopularRoute::factory()->create([ 'from_destination_id' => $from->id, 'to_destination_id' => $to->id, 'is_active' => true, ]); $this->getJson('/api/v1/popular-routes') ->assertSuccessful() ->assertJsonPath('data.0.from_destination', [ 'id' => $from->id, 'name' => $from->name, 'mm_name' => $from->mm_name, ]) ->assertJsonPath('data.0.to_destination', [ 'id' => $to->id, 'name' => $to->name, 'mm_name' => $to->mm_name, ]); }); test('an inactive popular route is excluded from the list', function () { PopularRoute::factory()->create(['is_active' => false]); $this->getJson('/api/v1/popular-routes') ->assertSuccessful() ->assertJsonCount(0, 'data'); });