mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-14 00:33:44 -04:00
- Mark Analytics, Dashboard\TrafficAnalytics and Project\Application\Analytics Livewire components #[Lazy] with skeleton placeholder() views so pages render instantly while Sentinel data loads in a deferred request - Add SentinelTrafficClient::prefetchServerWide() to warm all server-wide endpoints in a single batched docker exec instead of ~14-15 serial SSH round-trips, and refactor overview/paths/breakdown URL building into shared helpers - Cap per-app leaderboard overviews fetched via MAX_LEADERBOARD_APPS to bound requests on servers with many apps - Add hasRequestSeries() to detect empty request charts and render a no-data state instead of a blank chart - Gate ServerSetting's automatic Sentinel restart on is_sentinel_enabled so tuning geoip/traffic settings no longer silently enables Sentinel - Add reusable skeleton UI components (skeleton, skeleton/table, skeleton/tiles) for the new placeholder views
65 lines
1.9 KiB
PHP
65 lines
1.9 KiB
PHP
<?php
|
|
|
|
use App\Livewire\Analytics;
|
|
use App\Livewire\Dashboard\TrafficAnalytics as DashboardTrafficAnalytics;
|
|
use App\Models\PrivateKey;
|
|
use App\Models\Server;
|
|
use App\Models\Team;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
Server::flushIdentityMap();
|
|
$this->team = Team::factory()->create();
|
|
$this->user = User::factory()->create();
|
|
$this->team->members()->attach($this->user->id, ['role' => 'owner']);
|
|
$this->actingAs($this->user);
|
|
session(['currentTeam' => $this->team]);
|
|
$this->privateKey = PrivateKey::factory()->create(['team_id' => $this->team->id]);
|
|
});
|
|
|
|
function disabledServer(): Server
|
|
{
|
|
$server = Server::factory()->create([
|
|
'team_id' => test()->team->id,
|
|
'private_key_id' => test()->privateKey->id,
|
|
]);
|
|
$server->settings->is_traffic_analytics_enabled = false;
|
|
$server->settings->save();
|
|
|
|
return $server;
|
|
}
|
|
|
|
it('does not show a traffic nudge on the dashboard', function () {
|
|
disabledServer();
|
|
|
|
loadLazy(Livewire::test(DashboardTrafficAnalytics::class))
|
|
->assertOk()
|
|
->assertDontSee('can start collecting traffic analytics');
|
|
});
|
|
|
|
it('shows the analytics-page nudge when an eligible server has analytics disabled', function () {
|
|
disabledServer();
|
|
|
|
loadLazy(Livewire::test(Analytics::class))
|
|
->assertOk()
|
|
->assertSee('can start collecting traffic analytics');
|
|
});
|
|
|
|
it('does not count swarm or build servers in the analytics-page nudge', function () {
|
|
$swarm = disabledServer();
|
|
$swarm->settings->is_swarm_manager = true;
|
|
$swarm->settings->save();
|
|
|
|
$build = disabledServer();
|
|
$build->settings->is_build_server = true;
|
|
$build->settings->save();
|
|
|
|
loadLazy(Livewire::test(Analytics::class))
|
|
->assertOk()
|
|
->assertDontSee('can start collecting traffic analytics');
|
|
});
|