Files
pricebuddy/tests/Feature/Filament/PriceHistoryChartTest.php
Jeremy d1a8f1d009 feat: product insights tab
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
2026-06-18 23:13:14 +10:00

42 lines
1.1 KiB
PHP

<?php
namespace Tests\Feature\Filament;
use App\Filament\Resources\ProductResource\Widgets\PriceHistoryChart;
use App\Models\Product;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
use Tests\TestCase;
class PriceHistoryChartTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
$this->actingAs(User::factory()->create());
}
public function test_chart_includes_a_best_price_dataset(): void
{
$product = Product::factory()
->addUrlWithPrices('https://example-a.com/p', [60, 55, 50])
->create();
Livewire::test(PriceHistoryChart::class, ['record' => $product])
->assertSee('Best price');
}
public function test_chart_includes_target_line_when_notify_price_is_set(): void
{
$product = Product::factory()
->addUrlWithPrices('https://example-a.com/p', [60, 55, 50])
->create(['notify_price' => 45.00]);
Livewire::test(PriceHistoryChart::class, ['record' => $product])
->assertSee('Your target');
}
}