set('dokploy.projects', [ 'core' => 'proj_1', ]); $fakeClient = Mockery::mock(DokployClient::class); $fakeClient->shouldReceive('project') ->with('proj_1') ->andReturn([ 'projectId' => 'proj_1', 'name' => 'Core', 'description' => 'Main stack', 'updatedAt' => now()->toIso8601String(), 'applications' => [ [ 'applicationId' => 'app_1', 'name' => 'API', 'applicationStatus' => 'running', 'repository' => 'repo/api', 'branch' => 'main', ], ], 'compose' => [ [ 'composeId' => 'cmp_1', 'name' => 'Main Compose', 'composeStatus' => 'done', ], ], 'redis' => [ [ 'redisId' => 'redis_1', 'name' => 'Redis', 'applicationStatus' => 'done', 'externalPort' => 6379, ], ], ]); $fakeClient->shouldReceive('applicationStatus') ->with('app_1') ->andReturn([ 'application' => [ 'name' => 'API', 'applicationStatus' => 'running', 'updatedAt' => now()->toIso8601String(), ], 'monitoring' => [ 'cpuPercent' => 12, ], ]); $fakeClient->shouldReceive('composeStatus') ->with('cmp_1') ->andReturn([ 'compose' => [ 'name' => 'Main Compose', 'composeStatus' => 'done', 'updatedAt' => now()->toIso8601String(), ], 'services' => [ [ 'serviceName' => 'web', 'status' => 'running', ], ], ]); $fakeClient->shouldReceive('composeDeployments') ->with('cmp_1', 1) ->andReturn([ [ 'createdAt' => now()->toIso8601String(), ], ]); $this->app->instance(DokployClient::class, $fakeClient); Livewire::test(DokployPlatformHealth::class) ->assertStatus(200) ->assertSee('Core') ->assertSee('API') ->assertSee('Main Compose') ->assertSee('Redis'); } public function test_widget_falls_back_to_compose_status_when_projects_missing(): void { config()->set('dokploy.projects', []); config()->set('dokploy.composes', [ 'stack' => 'cmp_main', ]); $fakeClient = Mockery::mock(DokployClient::class); $fakeClient->shouldReceive('composeStatus') ->with('cmp_main') ->andReturn([ 'compose' => [ 'name' => 'Main Stack', 'composeStatus' => 'done', 'updatedAt' => now()->toIso8601String(), ], 'services' => [ [ 'serviceName' => 'web', 'status' => 'running', ], ], ]); $fakeClient->shouldReceive('composeDeployments') ->with('cmp_main', 1) ->andReturn([ [ 'createdAt' => now()->toIso8601String(), ], ]); $this->app->instance(DokployClient::class, $fakeClient); Livewire::test(DokployPlatformHealth::class) ->assertStatus(200) ->assertSee('Main Stack') ->assertSee('web'); } }