fix(server): hide sentinel status before validation
This commit is contained in:
parent
bf37db3b5f
commit
4435a46f07
2 changed files with 59 additions and 2 deletions
|
|
@ -15,7 +15,10 @@
|
|||
<div class="flex flex-col gap-1.5">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<h1>Server</h1>
|
||||
@if ($server->proxySet() || $server->isSentinelEnabled())
|
||||
@php
|
||||
$showSentinelStatus = $server->isFunctional() && $server->isSentinelEnabled();
|
||||
@endphp
|
||||
@if ($server->proxySet() || $showSentinelStatus)
|
||||
<div data-testid="server-status-summary" class="flex flex-wrap items-center gap-2">
|
||||
@if ($server->proxySet())
|
||||
<div class="flex items-center gap-1">
|
||||
|
|
@ -38,7 +41,7 @@
|
|||
type="warning" />
|
||||
</div>
|
||||
@endif
|
||||
@if ($server->isSentinelEnabled())
|
||||
@if ($showSentinelStatus)
|
||||
@if ($server->isSentinelLive())
|
||||
<x-status-badge label="Sentinel" status="In sync" type="success" />
|
||||
@else
|
||||
|
|
|
|||
54
tests/Feature/ServerNavbarStatusVisibilityTest.php
Normal file
54
tests/Feature/ServerNavbarStatusVisibilityTest.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
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]);
|
||||
});
|
||||
|
||||
function makeNavbarServer(bool $isFunctional): array
|
||||
{
|
||||
$team = Team::factory()->create();
|
||||
$user = User::factory()->create();
|
||||
$user->teams()->attach($team, ['role' => 'admin']);
|
||||
|
||||
$server = Server::factory()->create([
|
||||
'team_id' => $team->id,
|
||||
'sentinel_updated_at' => now(),
|
||||
]);
|
||||
|
||||
$server->settings()->update([
|
||||
'is_reachable' => $isFunctional,
|
||||
'is_usable' => $isFunctional,
|
||||
'is_sentinel_enabled' => true,
|
||||
]);
|
||||
|
||||
test()->actingAs($user);
|
||||
session(['currentTeam' => $team]);
|
||||
|
||||
return [$server->fresh(), $user, $team];
|
||||
}
|
||||
|
||||
it('does not show sentinel sync status before the server is validated', function () {
|
||||
[$server] = makeNavbarServer(isFunctional: false);
|
||||
|
||||
Livewire::test('server.navbar', ['server' => $server])
|
||||
->assertDontSee('Sentinel')
|
||||
->assertDontSee('In sync')
|
||||
->assertDontSee('Out of sync');
|
||||
});
|
||||
|
||||
it('shows sentinel sync status after the server is validated', function () {
|
||||
[$server] = makeNavbarServer(isFunctional: true);
|
||||
|
||||
Livewire::test('server.navbar', ['server' => $server])
|
||||
->assertSee('Sentinel')
|
||||
->assertSee('In sync');
|
||||
});
|
||||
Loading…
Reference in a new issue