mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-15 02:16:43 +00:00
feat(dashboard): refresh metrics and color server status indicators
Refresh visible dashboard metrics every minute and after backgrounding. Replace server status badges with accessible color-coded icon borders and status text.
This commit is contained in:
1 parent
3f47524baf
commit
7037633f45
6 files changed
+103
-28
No files matched your search
@@ -65,6 +65,20 @@ it('configures the dashboard chart as a ten minute cpu and memory sparkline with
|
||||
->toContain('labels: { show: false }');
|
||||
});
|
||||
|
||||
it('refreshes dashboard metrics every minute while visible and after returning from the background', function () {
|
||||
$chart = file_get_contents(resource_path('views/livewire/dashboard/server-metrics-chart.blade.php'));
|
||||
|
||||
expect($chart)
|
||||
->toContain('window.setInterval')
|
||||
->toContain('60000')
|
||||
->toContain('document.hidden')
|
||||
->toContain("document.addEventListener('visibilitychange'")
|
||||
->toContain('Date.now() - this.hiddenAt >= 60000')
|
||||
->toContain('$wire.loadData()')
|
||||
->toContain('window.clearInterval')
|
||||
->toContain("document.removeEventListener('visibilitychange'");
|
||||
});
|
||||
|
||||
it('keeps the status badge only on server cards without metrics', function () {
|
||||
$dashboard = file_get_contents(resource_path('views/livewire/dashboard.blade.php'));
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
test('server cards use icon borders instead of ready badges', function () {
|
||||
$dashboard = file_get_contents(resource_path('views/livewire/dashboard.blade.php'));
|
||||
$serverIndex = file_get_contents(resource_path('views/livewire/server/index.blade.php'));
|
||||
|
||||
expect($dashboard)
|
||||
->not->toContain('<x-status-badge :status="$serverStatus"')
|
||||
->toContain("'border-emerald-500/70' => \$serverStatusType === 'success'")
|
||||
->toContain("'border-amber-500/70' => \$serverStatusType === 'warning'")
|
||||
->toContain("'border-red-500/70' => \$serverStatusType === 'error'")
|
||||
->toContain('title="{{ $serverStatus }}"')
|
||||
->toContain('aria-label="Server status: {{ $serverStatus }}"');
|
||||
|
||||
expect(substr_count($serverIndex, '<x-status-badge'))->toBe(1)
|
||||
->and($serverIndex)
|
||||
->toContain("\$isReady => 'success'")
|
||||
->toContain("\$isTransferredAway || \$server->settings->force_disabled => 'error'")
|
||||
->toContain("default => 'warning'")
|
||||
->toContain("server.statusType === 'success' ? 'border-emerald-500/70'")
|
||||
->toContain("server.statusType === 'warning' ? 'border-amber-500/70'")
|
||||
->toContain("'border-red-500/70'")
|
||||
->toContain(':title="server.status"')
|
||||
->toContain(':aria-label="`Server status: ${server.status}`"');
|
||||
});
|
||||
|
||||
test('server table keeps status text without a badge', function () {
|
||||
$serverIndex = file_get_contents(resource_path('views/livewire/server/index.blade.php'));
|
||||
|
||||
expect($serverIndex)
|
||||
->toContain('<span x-text="server.status"></span>')
|
||||
->toContain('text-[11px] font-medium')
|
||||
->not->toContain('<x-status-badge dynamic>');
|
||||
});
|
||||
Reference in new issue
Block a user