mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Livewire;
|
|
|
|
use App\Livewire\ProductCardDetail;
|
|
use App\Models\Product;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
class ProductCardCountdownTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->actingAs(User::factory()->create());
|
|
}
|
|
|
|
public function test_card_renders_countdown_for_active_product(): void
|
|
{
|
|
$product = Product::factory()->create(['refresh_interval' => 3600, 'paused' => false]);
|
|
$product->forceFill(['next_check_at' => now()->addMinutes(30)])->saveQuietly();
|
|
|
|
Livewire::test(ProductCardDetail::class, ['product' => $product, 'showChart' => true])
|
|
->assertSee('Next check')
|
|
->assertSeeHtml('width: ${progress}%')
|
|
->assertDontSee('Paused');
|
|
}
|
|
|
|
public function test_card_shows_paused_state(): void
|
|
{
|
|
$product = Product::factory()->create(['refresh_interval' => 3600, 'paused' => true]);
|
|
|
|
Livewire::test(ProductCardDetail::class, ['product' => $product, 'showChart' => true])
|
|
->assertSee('Next check')
|
|
->assertSee('Paused');
|
|
}
|
|
}
|