mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
- Delete Blade components, component classes, Livewire components and views that nothing uses after the redesign. - Delete tests that only compare Blade/CSS source text; keep the source checks for authorization gates, stable wire:key values and escaping. - Update stale tests to the current UI and behaviour. - Update DESIGN.md to the current navigation and layout. - Add a lesson: test behaviour, not source markup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
2.3 KiB
PHP
61 lines
2.3 KiB
PHP
<?php
|
|
|
|
use App\Livewire\Project\Shared\GetLogs;
|
|
use App\Livewire\Server\Sentinel\Logs;
|
|
use App\Models\InstanceSettings;
|
|
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 () {
|
|
InstanceSettings::create(['id' => 0]);
|
|
$team = Team::factory()->create();
|
|
$user = User::factory()->create();
|
|
$team->members()->attach($user->id, ['role' => 'owner']);
|
|
session(['currentTeam' => $team]);
|
|
$this->actingAs($user);
|
|
$this->server = Server::factory()->create(['team_id' => $team->id]);
|
|
});
|
|
|
|
it('shows Sentinel status and logs when the legacy flag and metrics are disabled', function (bool $recentHeartbeat) {
|
|
$this->server->sentinelHeartbeat(isReset: ! $recentHeartbeat);
|
|
$this->server->settings()->update(['is_sentinel_enabled' => false, 'is_metrics_enabled' => false]);
|
|
|
|
Livewire::withQueryParams(['server_uuid' => $this->server->uuid])
|
|
->test(Logs::class)
|
|
->assertSee($recentHeartbeat ? 'In sync' : 'Out of sync')
|
|
->assertDontSee('Enable Sentinel')
|
|
->assertDontSee('Sentinel is disabled')
|
|
->assertSeeLivewire(GetLogs::class);
|
|
})->with([false, true]);
|
|
|
|
it('shows Sentinel status independently of optional metrics', function (bool $metricsEnabled, bool $recentHeartbeat) {
|
|
$this->server->sentinelHeartbeat(isReset: ! $recentHeartbeat);
|
|
$this->server->settings()->update([
|
|
'is_sentinel_enabled' => false,
|
|
'is_metrics_enabled' => $metricsEnabled,
|
|
]);
|
|
|
|
Livewire::withQueryParams(['server_uuid' => $this->server->uuid])
|
|
->test(Logs::class)
|
|
->assertSee($recentHeartbeat ? 'In sync' : 'Out of sync')
|
|
->assertSeeLivewire(GetLogs::class);
|
|
})->with([false, true])->with([false, true]);
|
|
|
|
it('does not offer Sentinel controls or logs on unsupported servers', function (array $settings) {
|
|
$this->server->settings()->update($settings);
|
|
|
|
Livewire::withQueryParams(['server_uuid' => $this->server->uuid])
|
|
->test(Logs::class)
|
|
->assertDontSee('Enable Sentinel')
|
|
->assertDontSeeLivewire(GetLogs::class);
|
|
})->with([
|
|
'build server' => [['server_role' => 'build', 'is_build_server' => true]],
|
|
'swarm manager' => [['is_swarm_manager' => true]],
|
|
'swarm worker' => [['is_swarm_worker' => true]],
|
|
]);
|