'{{ $slot }}', 'button.blade.php' => '', 'card.blade.php' => '
{{ $slot }}
', 'heading.blade.php' => '
{{ $slot }}
', 'input.blade.php' => '', 'select.blade.php' => '', 'text.blade.php' => '
{{ $slot }}
', 'textarea.blade.php' => '', ]; foreach ($stubs as $file => $contents) { file_put_contents($componentPath.'/'.$file, $contents); } Blade::anonymousComponentPath($componentPath, 'flux'); app('view')->addNamespace('hub', $base.'/hub'); } } if (! function_exists('loadAgenticLivewireComponent')) { function loadAgenticLivewireComponent(string $component): string { $phpRoot = dirname(__DIR__, 4); require_once $phpRoot."/Agentic/Livewire/{$component}.php"; return "Core\\Mod\\Agentic\\Livewire\\{$component}"; } } beforeEach(function (): void { prepareAgenticLivewireHarness(); $this->actingAsHades(); }); it('wires credit actions and flux blade controls', function (): void { $phpRoot = dirname(__DIR__, 4); $componentSource = file_get_contents($phpRoot.'/Agentic/Livewire/CreditLedger.php'); $bladeSource = file_get_contents($phpRoot.'/resources/views/livewire/agentic/credit-ledger.blade.php'); expect($componentSource) ->toContain('AwardCredits') ->toContain('GetBalance') ->toContain('GetCreditHistory'); expect($bladeSource) ->toContain('toContain('wire:click="deductCredits"') ->toContain('wire:click="refundCredits"'); }); it('renders balance and transaction history for the selected agent', function (): void { $component = loadAgenticLivewireComponent('CreditLedger'); $workspace = createWorkspace(); FleetNode::query()->create([ 'workspace_id' => $workspace->id, 'agent_id' => 'alpha', 'platform' => 'darwin', 'status' => FleetNode::STATUS_ONLINE, 'registered_at' => now(), 'last_heartbeat_at' => now(), ]); AwardCredits::run($workspace->id, 'alpha', 'manual-refund', 5, null, 'Initial award'); Livewire::test($component, ['workspaceId' => $workspace->id]) ->assertSee('Credit Ledger') ->assertSee('alpha') ->assertSee('Initial award') ->assertSee('5'); }); it('refunds and deducts credits through the ledger actions', function (): void { $component = loadAgenticLivewireComponent('CreditLedger'); $workspace = createWorkspace(); FleetNode::query()->create([ 'workspace_id' => $workspace->id, 'agent_id' => 'alpha', 'platform' => 'darwin', 'status' => FleetNode::STATUS_ONLINE, 'registered_at' => now(), 'last_heartbeat_at' => now(), ]); Livewire::test($component, ['workspaceId' => $workspace->id]) ->set('selectedAgentId', 'alpha') ->set('adjustmentAmount', 3) ->set('adjustmentReason', 'Manual refund') ->call('refundCredits') ->assertHasNoErrors() ->set('adjustmentAmount', 2) ->set('adjustmentReason', 'Manual deduction') ->call('deductCredits') ->assertHasNoErrors(); assertDatabaseHas('credit_entries', [ 'workspace_id' => $workspace->id, 'task_type' => 'manual-refund', 'amount' => 3, 'description' => 'Manual refund', ]); assertDatabaseHas('credit_entries', [ 'workspace_id' => $workspace->id, 'task_type' => 'manual-deduction', 'amount' => -2, 'description' => 'Manual deduction', ]); expect(GetBalance::run($workspace->id, 'alpha')['balance'])->toBe(1); });