Files
zemailnator/tests/Feature/Livewire/DashboardTest.php
2025-11-14 01:51:35 -08:00

62 lines
1.8 KiB
PHP

<?php
namespace Tests\Feature\Livewire;
use App\Models\Plan;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Livewire\Livewire;
use Tests\TestCase;
class DashboardTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
// Clear all relevant caches to prevent conflicts
cache()->forget('app_plans');
cache()->forget('app_menus');
cache()->forget('app_blogs');
// Create plans for the dashboard to use BEFORE loading application data
Plan::factory()->count(2)->create();
// Reload application data to pick up the plans we just created
$this->loadApplicationData();
$this->user = User::factory()->create();
Auth::login($this->user);
}
/** @test */
public function it_renders_dashboard_component()
{
$component = Livewire::test(\App\Livewire\Dashboard\Dashboard::class);
$component->assertStatus(200);
$component->assertViewIs('livewire.dashboard.dashboard');
}
/** @test */
public function it_displays_user_information()
{
$component = Livewire::test(\App\Livewire\Dashboard\Dashboard::class);
// Check that dashboard renders with usage statistics
$component->assertSee('Mailbox Created');
$component->assertSee('Emails Received');
$component->assertSee('0'); // usage counts
}
/** @test */
public function it_shows_subscription_status()
{
$component = Livewire::test(\App\Livewire\Dashboard\Dashboard::class);
// Test that the component displays subscription pricing section (since user is not subscribed)
$component->assertSee('Purchase Subscription');
$component->assertSee('Have an Activation Key?');
}
}