- Add proper Tests\ namespace to all test classes in tests/Feature and tests/Unit - Split RemainingModelsTest.php into separate files (PSR-4 compliance) - Create missing factories: MetaFactory, RemoteEmailFactory - Add HasFactory trait to RemoteEmail model - Add missing ReflectionClass imports to test files - Fix mass assignment issues in Meta and RemoteEmail models - Override database connection for RemoteEmail in testing environment - Fix DateTime comparison precision issues in tests
61 lines
1.8 KiB
PHP
61 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?');
|
|
}
|
|
} |