1, 'leads_in_tier' => null, 'price_per_lead_kopecks' => 10000, 'is_active' => true, 'effective_from' => now()->toDateString(), ]); }); it('refuses resume via API when balance insufficient (409)', function () { $t = Tenant::factory()->create(['balance_rub' => '100.00', 'delivered_in_month' => 0]); $u = User::factory()->for($t)->create(); $p = Project::factory()->for($t)->create(['is_active' => false, 'daily_limit_target' => 5, 'paused_at' => now(), 'preflight_blocked_at' => null]); $resp = $this->actingAs($u)->patchJson("/api/projects/{$p->id}/toggle-active", ['is_active' => true]); $resp->assertStatus(409); $resp->assertJsonPath('error', 'balance_insufficient'); expect($p->fresh()->is_active)->toBeFalse(); }); it('resumes via API when balance sufficient (200 with data)', function () { $t = Tenant::factory()->create(['balance_rub' => '1000.00', 'delivered_in_month' => 0]); $u = User::factory()->for($t)->create(); $p = Project::factory()->for($t)->create(['is_active' => false, 'daily_limit_target' => 5, 'paused_at' => now(), 'preflight_blocked_at' => null]); $resp = $this->actingAs($u)->patchJson("/api/projects/{$p->id}/toggle-active", ['is_active' => true]); $resp->assertOk(); $resp->assertJsonStructure(['data']); expect($p->fresh()->is_active)->toBeTrue(); }); it('pauses via API without balance check (200)', function () { $t = Tenant::factory()->create(['balance_rub' => '0.00', 'delivered_in_month' => 0]); $u = User::factory()->for($t)->create(); $p = Project::factory()->for($t)->create(['is_active' => true, 'daily_limit_target' => 5]); $resp = $this->actingAs($u)->patchJson("/api/projects/{$p->id}/toggle-active", ['is_active' => false]); $resp->assertOk(); expect($p->fresh()->is_active)->toBeFalse(); });