mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
Add a Product Insights tab backed by a suite of price-analysis calculators and a redesigned price history chart. - Insights calculators: listing-history and daily best-price series builders, price stats, percentile, deal score, distribution, drop events, store showdown, seasonality, availability timeline, and target tracker - ProductInsights aggregator service composing the calculators - Price history chart: best-price and target datasets, best-price line honours the unit/retail filter, horizontal scroll on mobile - Rename the History tab to Insights with consistent heading styling - Feature and unit test coverage, plus review-feedback fixes
48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Filament;
|
|
|
|
use App\Filament\Resources\ProductResource;
|
|
use App\Models\Product;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class ProductInsightsTabTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected User $user;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->user = User::factory()->create();
|
|
$this->actingAs($this->user);
|
|
}
|
|
|
|
public function test_insights_tab_renders_modules_for_a_product_with_history(): void
|
|
{
|
|
$product = Product::factory()
|
|
->addUrlWithPrices('https://example-a.com/p', [60, 55, 50, 45, 42])
|
|
->create(['notify_price' => 40, 'user_id' => $this->user->getKey()]);
|
|
|
|
$this->get(ProductResource::getUrl('view', ['record' => $product]))
|
|
->assertOk()
|
|
->assertSee('Insights')
|
|
->assertSee('Should I buy right now?')
|
|
->assertSee('Price distribution')
|
|
->assertSee('Store showdown')
|
|
->assertSee('All-time low');
|
|
}
|
|
|
|
public function test_insights_tab_shows_empty_state_without_history(): void
|
|
{
|
|
$product = Product::factory()->create(['user_id' => $this->user->getKey()]);
|
|
|
|
$this->get(ProductResource::getUrl('view', ['record' => $product]))
|
|
->assertOk()
|
|
->assertSee('Not enough price history yet');
|
|
}
|
|
}
|