mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
Add AiConfigHealer to bootstrap or repair a store config via a tool-using structured agent (fetch/css/regex tools, HealingContext, shared StrategyExtractor). - Run healing before the one-shot enhancer; AI-bootstrap a store config when product create would otherwise fail; StoreUrl validation defers to self-healing when enabled - Per-feature AI provider resolution (AiFeature enum) and settings - Per-store self-healing opt-out plus cooldown; log heal attempts and unusable proposals - Heal with AI action with non-persisting preview/apply/discard in the store test modal; prompt switches to browser scraping when blocked
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Models;
|
|
|
|
use App\Models\Store;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Carbon;
|
|
use Tests\TestCase;
|
|
|
|
class StoreHealingSettingsTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_self_healing_disabled_defaults_to_false(): void
|
|
{
|
|
$store = Store::factory()->create(['settings' => []]);
|
|
|
|
$this->assertFalse($store->ai_self_healing_disabled);
|
|
}
|
|
|
|
public function test_self_healing_disabled_reads_from_settings(): void
|
|
{
|
|
$store = Store::factory()->create(['settings' => ['ai_self_healing_disabled' => true]]);
|
|
|
|
$this->assertTrue($store->ai_self_healing_disabled);
|
|
}
|
|
|
|
public function test_marks_and_clears_heal_failure_timestamp(): void
|
|
{
|
|
Carbon::setTestNow('2026-06-07 10:00:00');
|
|
$store = Store::factory()->create(['settings' => []]);
|
|
|
|
$this->assertNull($store->getAiHealFailedAt());
|
|
|
|
$store->markAiHealFailed();
|
|
$this->assertTrue($store->fresh()->getAiHealFailedAt()->equalTo(Carbon::parse('2026-06-07 10:00:00')));
|
|
|
|
$store->clearAiHealFailed();
|
|
$this->assertNull($store->fresh()->getAiHealFailedAt());
|
|
|
|
Carbon::setTestNow();
|
|
}
|
|
}
|