Closes #11 Adds comprehensive Livewire tests in tests/Feature/Livewire/ covering: - DashboardTest: stats structure, refresh action, blocked alert, quick links - PlansTest: auth, filters, activate/complete/archive/delete actions - PlanDetailTest: auth, plan loading, phase actions, task validation - SessionsTest: auth, filters, pause/resume/complete/fail actions - SessionDetailTest: auth, polling, modal states, session control - ToolAnalyticsTest: auth, setDays, filters, success rate colour helpers - ApiKeysTest: auth, create/edit/revoke modals, validation, stats - ApiKeyManagerTest: workspace binding, create form, toggleScope - ToolCallsTest: auth, filters, viewCall/closeCallDetail, badge helpers - RequestLogTest: filters, selectRequest/closeDetail interactions - TemplatesTest: auth, preview/import/create modals, clearFilters - PlaygroundTest: server loading, API key validation, execute behaviour Infrastructure: - LivewireTestCase base class with stub view namespace registration - HadesUser fixture for auth()->user()->isHades() checks - Minimal stub blade views in tests/views/ (agentic and mcp namespaces) - composer.json: add livewire/livewire and pest-plugin-livewire to require-dev; fix autoload-dev paths to lowercase tests/ directory Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Mod\Agentic\Tests\Feature\Livewire;
|
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\Fixtures\HadesUser;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Base test case for Livewire component tests.
|
|
*
|
|
* Registers stub view namespaces so components can render during tests
|
|
* without requiring the full hub/mcp Blade component library.
|
|
*/
|
|
abstract class LivewireTestCase extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected HadesUser $hadesUser;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
// Register stub view namespaces so Livewire can render components
|
|
// without the full Blade component library from host-uk/core.
|
|
// Stubs live in tests/views/{namespace}/ and use minimal HTML.
|
|
$viewsBase = realpath(__DIR__.'/../../views');
|
|
|
|
$this->app['view']->addNamespace('agentic', $viewsBase);
|
|
$this->app['view']->addNamespace('mcp', $viewsBase.'/mcp');
|
|
|
|
// Create a Hades-privileged user for component tests
|
|
$this->hadesUser = new HadesUser([
|
|
'id' => 1,
|
|
'name' => 'Hades Test User',
|
|
'email' => 'hades@test.example',
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Act as the Hades user (admin with full access).
|
|
*/
|
|
protected function actingAsHades(): static
|
|
{
|
|
return $this->actingAs($this->hadesUser);
|
|
}
|
|
}
|