create(['username' => 'bonususer', 'email_verified_at' => now()]); } public function test_app_index_success_normalizes_fields() { Http::fake([ $this->base() . '/bonuses/app*' => Http::response([ 'available' => [ [ 'id' => 1, 'title' => 'Welcome Bonus', 'type' => 'deposit_match', 'amount_value' => 100, 'amount_unit' => '%', 'min_deposit' => 10, 'max_amount' => 200, 'currency' => 'USD', 'code' => 'WELCOME100', 'starts_at' => now()->subDay()->toIso8601String(), 'expires_at' => now()->addDay()->toIso8601String(), 'description' => 'Match bonus', ], ], 'active' => [], 'history' => [], 'now' => now()->toIso8601String(), ], 200), ]); $res = $this->actingAs($this->actingUser(), 'web')->get('/api/bonuses/app'); $res->assertStatus(200) ->assertJsonStructure([ 'available' => [ [ 'id','title','type','amount_value','amount_unit','currency','code','starts_at','expires_at','description' ] ], 'active', 'history', 'now', ]); } public function test_app_index_server_error_maps_to_503() { Http::fake([ $this->base() . '/bonuses/app*' => Http::response(['message' => 'Down'], 500), ]); $res = $this->actingAs($this->actingUser(), 'web')->get('/api/bonuses/app'); $res->assertStatus(503)->assertJson(['error' => 'service_unavailable']); } }