Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

test(metrics): assert KPI tiles, stale badge, and container toggle render

Aditya Tripathifbce977dbfb8
diff --git a/tests/Feature/Livewire/Fleet/MetricsDataTest.php b/tests/Feature/Livewire/Fleet/MetricsDataTest.php
index 1ef9cd5b32..ee10acade2 100644
--- a/tests/Feature/Livewire/Fleet/MetricsDataTest.php
+++ b/tests/Feature/Livewire/Fleet/MetricsDataTest.php
@@ -115,6 +115,25 @@ it('ranks containers across servers by the selected metric', function () {
expect(array_column($component->get('topContainers'), 'id')[0])->toBe('high');
});
+it('shows the KPI tiles, a stale badge for offline servers, and the container toggle', function () {
+ $ok = metricsServer($this->team, $this->privateKey);
+ $ok->update(['name' => 'web-1']);
+ $dead = metricsServer($this->team, $this->privateKey);
+ $dead->update(['name' => 'web-2']);
+
+ StubMetricsClient::$summaries = [
+ $ok->uuid => onlineSummary(['cpu' => 95.0, 'diskPercent' => 95.0]),
+ $dead->uuid => null,
+ ];
+
+ Livewire::test(TestableMetrics::class)
+ ->assertSee('web-1')
+ ->assertSee('web-2')
+ ->assertSee('Fleet CPU')
+ ->assertSee('needs attention')
+ ->assertSee('Offline');
+});
+
it('cannot see another team’s servers', function () {
$otherTeam = Team::factory()->create();
// Reuse the existing key id: the factory's private key is hardcoded, so a second