mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
Add a meta-extraction API endpoint and refactor store scrape strategies onto strongly-typed DTOs. - POST /api/meta-extraction endpoint with SSRF protection on the target URL - Typed scrape-strategy DTOs and enums (StandardStrategyDto, AvailabilityMatchDto, AvailabilityMatchType, AvailabilityStrategyDto, StoreScraperStrategySetDto) with a model cast for the stores.scrape_strategy column - Convert ScrapeUrl, StrategyExtractor and availability resolution to consume the typed strategy slots; preserve legacy plain-string availability match entries - Filament scrape_strategy form bridge plus DTO test coverage
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services;
|
|
|
|
use App\Models\Store;
|
|
use App\Services\MetaExtractionService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class MetaExtractionServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_store_override_nested_cookies_are_promoted_to_the_store_model(): void
|
|
{
|
|
Store::factory()->create([
|
|
'domains' => [
|
|
['domain' => 'example.com'],
|
|
],
|
|
]);
|
|
|
|
$service = new class extends MetaExtractionService
|
|
{
|
|
public function resolveStoreForTest(string $url, array $storeOverride = []): ?Store
|
|
{
|
|
return $this->resolveStore($url, $storeOverride);
|
|
}
|
|
};
|
|
|
|
$store = $service->resolveStoreForTest('https://example.com/product', [
|
|
'settings' => [
|
|
'cookies' => 'sessionid=abc123',
|
|
'scraper_service' => 'http',
|
|
],
|
|
]);
|
|
|
|
$this->assertInstanceOf(Store::class, $store);
|
|
$this->assertSame('sessionid=abc123', $store->cookies);
|
|
}
|
|
}
|