mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
Add a Customize action to toggle the summary stats and smart sections (buy now, recently dropped, needs attention). Make the tag-group drag handle the heading icon and text only, leaving the collapse chevron and empty space non-draggable.
56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Filament;
|
|
|
|
use App\Filament\Pages\HomeDashboard;
|
|
use App\Models\User;
|
|
use App\Services\Dashboard\DashboardLayoutService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
class HomeDashboardTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
private User $user;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->user = User::factory()->create();
|
|
$this->actingAs($this->user);
|
|
}
|
|
|
|
public function test_customize_action_seeds_current_section_visibility(): void
|
|
{
|
|
// Defaults: only buy_now visible.
|
|
Livewire::test(HomeDashboard::class)
|
|
->mountAction('customize')
|
|
->assertActionDataSet([
|
|
'stat_bar' => false,
|
|
'buy_now' => true,
|
|
'recently_dropped' => false,
|
|
'needs_attention' => false,
|
|
]);
|
|
}
|
|
|
|
public function test_customize_action_persists_section_visibility(): void
|
|
{
|
|
Livewire::test(HomeDashboard::class)
|
|
->callAction('customize', data: [
|
|
'stat_bar' => true,
|
|
'buy_now' => false,
|
|
'recently_dropped' => true,
|
|
'needs_attention' => false,
|
|
])
|
|
->assertDispatched('dashboard-sections-updated');
|
|
|
|
$layout = new DashboardLayoutService($this->user->fresh());
|
|
$this->assertTrue($layout->isSectionVisible('stat_bar'));
|
|
$this->assertFalse($layout->isSectionVisible('buy_now'));
|
|
$this->assertTrue($layout->isSectionVisible('recently_dropped'));
|
|
$this->assertFalse($layout->isSectionVisible('needs_attention'));
|
|
}
|
|
}
|