Files
pricebuddy/tests/Unit/Services/AiConfigHealerPromptTest.php
Jeremy 8b02abb0aa feat: AI self-healing store config
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
2026-06-09 15:07:40 +10:00

33 lines
943 B
PHP

<?php
namespace Tests\Unit\Services;
use App\Services\AiConfigHealer;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
class AiConfigHealerPromptTest extends TestCase
{
private function prompt(): string
{
return (string) (new ReflectionClass(AiConfigHealer::class))->getConstant('PROMPT');
}
public function test_prompt_instructs_static_first_then_browser_fallback(): void
{
$prompt = $this->prompt();
$this->assertStringContainsString('rendered=false', $prompt);
$this->assertStringContainsString('rendered=true', $prompt);
}
public function test_prompt_tells_the_agent_to_switch_to_browser_when_blocked(): void
{
$prompt = strtolower($this->prompt());
$this->assertStringContainsString('blocked', $prompt);
$this->assertStringContainsString('captcha', $prompt);
$this->assertStringContainsString('browser scraping', $prompt);
}
}