mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
Some stores (e.g. Amazon) remove the price element when a product is out of stock. A missing price was a scrape error, so the product could not be created, and AI self-healing could move the price selector onto an unrelated price on the page. Add a per-store 'Treat a missing price as out of stock' setting. When it is on, ScrapeUrl::resolveStockStatus() reads a page with a title but no price as OutOfStock, so creation succeeds and healing does not run. Fixes #222
48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Filament;
|
|
|
|
use App\Filament\Resources\StoreResource\Pages\EditStore;
|
|
use App\Models\Store;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
class StoreMissingPriceToggleTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->actingAs(User::factory()->create(['email' => 'test@test.com']));
|
|
}
|
|
|
|
public function test_toggle_is_rendered(): void
|
|
{
|
|
$store = Store::factory()->create(['settings' => ['scraper_service' => 'http']]);
|
|
|
|
Livewire::test(EditStore::class, ['record' => $store->getKey()])
|
|
->assertSee('Treat a missing price as out of stock');
|
|
}
|
|
|
|
public function test_toggle_persists(): void
|
|
{
|
|
$store = Store::factory()->create(['settings' => ['scraper_service' => 'http']]);
|
|
|
|
Livewire::test(EditStore::class, ['record' => $store->getKey()])
|
|
->set('data.domains', null)
|
|
->fillForm([
|
|
'domains' => [['domain' => 'example.com']],
|
|
'settings.locale_settings.locale' => 'en_US',
|
|
'settings.locale_settings.currency' => 'USD',
|
|
'settings.missing_price_out_of_stock' => true,
|
|
])
|
|
->call('save')
|
|
->assertHasNoFormErrors();
|
|
|
|
$this->assertTrue($store->fresh()->missing_price_out_of_stock);
|
|
}
|
|
}
|