PricingTier::create([ 'tier_no' => 1, 'leads_in_tier' => null, 'price_per_lead_kopecks' => 10000, 'is_active' => true, 'effective_from' => now()->toDateString(), ])); it('bulk resume launches only what fits, skips rest with balance reason', function () { Queue::fake(); // 1000 ₽ / 100 ₽ за лид = 10 лидов ёмкости $t = Tenant::factory()->create(['balance_rub' => '1000.00', 'delivered_in_month' => 0]); $a = Project::factory()->for($t)->create(['is_active' => false, 'daily_limit_target' => 6, 'paused_at' => now(), 'preflight_blocked_at' => null]); $b = Project::factory()->for($t)->create(['is_active' => false, 'daily_limit_target' => 6, 'paused_at' => now(), 'preflight_blocked_at' => null]); $res = app(ProjectService::class)->bulkAction($t->id, 'resume', ['ids' => [$a->id, $b->id]]); // Первый (6 лидов) влезает; второй (6+6=12 > 10) — скип. expect($res['updated'])->toBe(1); expect($res['skipped'])->toHaveCount(1); expect($res['skipped'][0]['reason'])->toBe('balance_insufficient'); });