<?php

namespace Tests\Feature;

use App\Models\User;
use App\Models\Order;
use App\Models\TrafficSession;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
use App\Filament\Widgets\LiveTrafficWidget;
use App\Filament\Widgets\ConversionFunnelWidget;
use App\Filament\Widgets\ProductPerformanceWidget;
use App\Filament\Widgets\MarketingAttributionWidget;
use App\Filament\Widgets\CustomerBehaviorWidget;
use Tests\TestCase;

class AnalyticsWidgetsTest extends TestCase
{
    use RefreshDatabase;

    public function test_analytics_widgets_render_successfully(): void
    {
        $admin = User::factory()->create([
            'role' => 'admin',
        ]);

        $this->actingAs($admin);

        // Test LiveTrafficWidget
        Livewire::test(LiveTrafficWidget::class)
            ->assertSee('Active Storefront Visitors Right Now')
            ->assertSee('View Live Details');

        // Test ConversionFunnelWidget
        Livewire::test(ConversionFunnelWidget::class)
            ->assertSee('Storefront Conversion Funnel')
            ->assertSee('Sessions / Visits')
            ->assertSee('Product Views');

        // Test ProductPerformanceWidget
        Livewire::test(ProductPerformanceWidget::class)
            ->assertSee('Top Selling Products & Conversion');

        // Test MarketingAttributionWidget
        Livewire::test(MarketingAttributionWidget::class)
            ->assertSee('UTM Marketing & Acquisition Attribution');

        // Test CustomerBehaviorWidget
        Livewire::test(CustomerBehaviorWidget::class)
            ->assertSee('Customer Value & Cohorts (LTV)');
    }
}
