mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-20 00:23:27 +00:00
feat(server): auto-resolve Sentinel URL and polish setup UI
Ensure a Sentinel endpoint from instance FQDN/IP when enabling, use process dialogs for validation with install state, and tidy server create, boarding, metrics empty state, and log timestamps.
This commit is contained in:
@@ -23,13 +23,10 @@ class StartSentinel
|
||||
$refreshRate = data_get($server, 'settings.sentinel_metrics_refresh_rate_seconds');
|
||||
$pushInterval = data_get($server, 'settings.sentinel_push_interval_seconds');
|
||||
$token = $server->settings->ensureValidSentinelToken();
|
||||
$endpoint = data_get($server, 'settings.sentinel_custom_url');
|
||||
$endpoint = $server->settings->ensureSentinelUrl();
|
||||
$debug = data_get($server, 'settings.is_sentinel_debug_enabled');
|
||||
$mountDir = '/data/coolify/sentinel';
|
||||
$image = coolifyRegistryUrl().'/coollabsio/sentinel:'.$version;
|
||||
if (! $endpoint) {
|
||||
throw new \RuntimeException('You should set FQDN in Instance Settings.');
|
||||
}
|
||||
$environments = [
|
||||
'TOKEN' => $token,
|
||||
'DEBUG' => $debug ? 'true' : 'false',
|
||||
|
||||
@@ -114,9 +114,10 @@ class Sentinel extends Component
|
||||
|
||||
return;
|
||||
}
|
||||
$this->isSentinelEnabled = true;
|
||||
$customImage = isDev() ? $this->sentinelCustomDockerImage : null;
|
||||
StartSentinel::run($this->server, true, null, $customImage);
|
||||
$this->sentinelCustomUrl = $this->server->settings->sentinel_custom_url;
|
||||
$this->isSentinelEnabled = true;
|
||||
} else {
|
||||
$this->isSentinelEnabled = false;
|
||||
$this->isMetricsEnabled = false;
|
||||
|
||||
@@ -39,6 +39,8 @@ class ValidateAndInstall extends Component
|
||||
|
||||
public bool $ask = false;
|
||||
|
||||
public bool $isInstalling = false;
|
||||
|
||||
protected $listeners = [
|
||||
'init',
|
||||
'validateConnection',
|
||||
@@ -51,6 +53,7 @@ class ValidateAndInstall extends Component
|
||||
|
||||
public function init(int $data = 0)
|
||||
{
|
||||
$this->isInstalling = false;
|
||||
$this->uptime = null;
|
||||
$this->supported_os_type = null;
|
||||
$this->prerequisites_installed = null;
|
||||
@@ -172,6 +175,7 @@ class ValidateAndInstall extends Component
|
||||
if ($this->number_of_tries <= $this->max_tries) {
|
||||
$this->installationStep = 'Prerequisites';
|
||||
$activity = $this->server->installPrerequisites();
|
||||
$this->isInstalling = true;
|
||||
$this->number_of_tries++;
|
||||
$this->dispatch('activityMonitor', $activity->id, 'init', $this->number_of_tries, "{$this->installationStep} Installation Logs");
|
||||
}
|
||||
@@ -208,6 +212,7 @@ class ValidateAndInstall extends Component
|
||||
if ($this->number_of_tries <= $this->max_tries) {
|
||||
$this->installationStep = 'Docker';
|
||||
$activity = $this->server->installDocker();
|
||||
$this->isInstalling = true;
|
||||
$this->number_of_tries++;
|
||||
$this->dispatch('activityMonitor', $activity->id, 'init', $this->number_of_tries, "{$this->installationStep} Installation Logs");
|
||||
}
|
||||
|
||||
@@ -219,7 +219,22 @@ class ServerSetting extends Model
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function generateSentinelUrl(bool $save = true, bool $ignoreEvent = false)
|
||||
public function ensureSentinelUrl(): string
|
||||
{
|
||||
$url = $this->sentinel_custom_url;
|
||||
|
||||
if (blank($url)) {
|
||||
$url = $this->generateSentinelUrl(ignoreEvent: true);
|
||||
}
|
||||
|
||||
if (blank($url)) {
|
||||
throw new \RuntimeException('Set an instance FQDN or public IP before enabling Sentinel.');
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function generateSentinelUrl(bool $save = true, bool $ignoreEvent = false): ?string
|
||||
{
|
||||
$domain = null;
|
||||
$settings = InstanceSettings::get();
|
||||
|
||||
@@ -253,7 +253,7 @@ function decode_remote_command_output(?ApplicationDeploymentQueue $application_d
|
||||
} catch (Exception) {
|
||||
$timestamp->setTimezone('UTC');
|
||||
}
|
||||
data_set($i, 'timestamp', $timestamp->format('Y-M-d H:i:s.u'));
|
||||
data_set($i, 'timestamp', $timestamp->format('Y-M-d H:i:s'));
|
||||
|
||||
return $i;
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@php use App\Actions\CoolifyTask\RunRemoteProcess; @endphp
|
||||
<div @class([
|
||||
'h-full flex flex-col overflow-hidden' => $fullHeight,
|
||||
'h-full overflow-hidden' => !$fullHeight,
|
||||
'overflow-hidden' => !$fullHeight,
|
||||
])>
|
||||
@if ($activity)
|
||||
@if (isset($header))
|
||||
|
||||
@@ -507,16 +507,16 @@
|
||||
</section>
|
||||
@endif
|
||||
|
||||
<x-slide-over closeWithX fullScreen>
|
||||
<x-process-dialog closeWithX size="xl">
|
||||
<x-slot:title>Server validation</x-slot:title>
|
||||
<x-slot:content>
|
||||
<livewire:server.validate-and-install :server="$this->createdServer" />
|
||||
</x-slot:content>
|
||||
<x-forms.button @click="slideOverOpen=true" class="w-full justify-center"
|
||||
<x-forms.button @click="processDialogOpen = true" class="w-full justify-center"
|
||||
wire:click.prevent="installServer" isHighlighted>
|
||||
Start validation
|
||||
</x-forms.button>
|
||||
</x-slide-over>
|
||||
</x-process-dialog>
|
||||
</div>
|
||||
</x-slot:actions>
|
||||
<x-slot:explanation>
|
||||
@@ -659,7 +659,7 @@
|
||||
</div>
|
||||
|
||||
@if ($currentState !== 'welcome' && $currentState !== 'create-resource')
|
||||
<div class="mt-6 flex w-full max-w-3xl flex-col items-center gap-3">
|
||||
<div class="mx-auto mt-6 flex w-full max-w-3xl flex-col items-center gap-3">
|
||||
<div
|
||||
class="inline-flex flex-wrap items-center justify-center gap-0.5 rounded-lg border border-neutral-200 bg-neutral-50 p-0.5 dark:border-white/[0.08] dark:bg-white/[0.025]">
|
||||
<button type="button" wire:click="skipBoarding"
|
||||
|
||||
@@ -280,10 +280,6 @@
|
||||
@else
|
||||
<x-application.settings-section id="server-metrics-overview-section" title="Metrics"
|
||||
helper="Inspect recent CPU and memory usage reported by Sentinel.">
|
||||
<x-slot:actions>
|
||||
<x-status-badge status="Unavailable" type="warning" />
|
||||
</x-slot:actions>
|
||||
|
||||
<x-empty size="sm" title="Sentinel is required"
|
||||
description="Enable Sentinel before collecting CPU and memory metrics for this server."
|
||||
icon-name="dashboard">
|
||||
|
||||
@@ -3,38 +3,42 @@
|
||||
New Server | Coolify
|
||||
</x-slot>
|
||||
|
||||
<div class="mb-4 flex flex-wrap items-center justify-end gap-2">
|
||||
<a href="{{ $selectedType ? route('server.create') : route('server.index') }}" class="button"
|
||||
{{ wireNavigate() }}>
|
||||
{{ $selectedType ? 'Change method' : 'Back to servers' }}
|
||||
</a>
|
||||
@if ($selectedType && $selectedType !== 'manual' && ! $selectedTokenUuid)
|
||||
@php
|
||||
$tokenProvider = $selectedType === 'digital-ocean' ? 'digitalocean' : $selectedType;
|
||||
$tokenProviderName = $selectedType === 'digital-ocean'
|
||||
? 'DigitalOcean'
|
||||
: str($selectedType)->headline();
|
||||
@endphp
|
||||
@can('create', App\Models\CloudProviderToken::class)
|
||||
<x-modal-input title="New {{ $tokenProviderName }} token">
|
||||
<x-slot:content>
|
||||
<button type="button"
|
||||
class="button button-highlighted">
|
||||
<x-reicon name="plus" class="size-3.5" />
|
||||
New token
|
||||
</button>
|
||||
</x-slot:content>
|
||||
<livewire:security.cloud-provider-token-form :modal_mode="true" :provider="$tokenProvider"
|
||||
wire:key="new-server-token-{{ $tokenProvider }}" />
|
||||
</x-modal-input>
|
||||
@endcan
|
||||
@endif
|
||||
<div class="mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
||||
<h1 class="min-w-0 text-[24px]! leading-7! font-semibold! tracking-tight!">New server</h1>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
@if ($selectedType)
|
||||
<a href="{{ route('server.create') }}" class="button" {{ wireNavigate() }}>
|
||||
Change method
|
||||
</a>
|
||||
@endif
|
||||
@if ($selectedType && $selectedType !== 'manual' && ! $selectedTokenUuid)
|
||||
@php
|
||||
$tokenProvider = $selectedType === 'digital-ocean' ? 'digitalocean' : $selectedType;
|
||||
$tokenProviderName = $selectedType === 'digital-ocean'
|
||||
? 'DigitalOcean'
|
||||
: str($selectedType)->headline();
|
||||
@endphp
|
||||
@can('create', App\Models\CloudProviderToken::class)
|
||||
<x-modal-input title="New {{ $tokenProviderName }} token">
|
||||
<x-slot:content>
|
||||
<button type="button"
|
||||
class="button button-highlighted">
|
||||
<x-reicon name="plus" class="size-3.5" />
|
||||
New token
|
||||
</button>
|
||||
</x-slot:content>
|
||||
<livewire:security.cloud-provider-token-form :modal_mode="true" :provider="$tokenProvider"
|
||||
wire:key="new-server-token-{{ $tokenProvider }}" />
|
||||
</x-modal-input>
|
||||
@endcan
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (!$selectedType)
|
||||
<div class="application-settings-form">
|
||||
<x-application.settings-section title="Add a server"
|
||||
description="Provision with a cloud provider or connect any reachable Linux server." flush>
|
||||
<section class="application-settings-section">
|
||||
<div class="application-settings-section-body is-flush">
|
||||
<div class="grid grid-cols-1 gap-3 p-3 sm:grid-cols-2 lg:grid-cols-4">
|
||||
@can('viewAny', App\Models\CloudProviderToken::class)
|
||||
<a href="{{ route('server.create.type', ['type' => 'hetzner']) }}"
|
||||
@@ -115,7 +119,8 @@
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</x-application.settings-section>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@else
|
||||
<div class="application-settings-form">
|
||||
|
||||
@@ -20,28 +20,17 @@
|
||||
</button>
|
||||
</x-slot:actions>
|
||||
|
||||
<div class="grid gap-4 lg:grid-cols-2">
|
||||
<x-forms.input id="name" label="Name" required />
|
||||
<x-forms.input id="description" label="Description" />
|
||||
</div>
|
||||
|
||||
<div class="mt-5 grid gap-4 border-t border-neutral-200 pt-4 lg:grid-cols-3 dark:border-white/[0.08]">
|
||||
<div class="mb-5">
|
||||
<x-forms.input id="ip" label="IP address or domain" required
|
||||
helper="For example 127.0.0.1 or server.example.com." />
|
||||
<x-forms.input id="user" label="User" required
|
||||
helper="Non-root SSH users are experimental." />
|
||||
<x-forms.input type="number" id="port" label="Port" required />
|
||||
</div>
|
||||
|
||||
<div class="mt-5 grid items-end gap-4 border-t border-neutral-200 pt-4 lg:grid-cols-2 dark:border-white/[0.08]">
|
||||
<x-forms.listbox id="private_key_id" label="Private key"
|
||||
placeholder="Select a private key" :options="$privateKeyOptions" />
|
||||
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<x-forms.checkbox id="is_build_server"
|
||||
helper="Build servers compile applications but do not host deployments."
|
||||
label="Use as a build server" />
|
||||
|
||||
<div class="mb-5">
|
||||
<div class="flex items-end gap-3">
|
||||
<div class="min-w-0 flex-1">
|
||||
<x-forms.listbox id="private_key_id" label="Private key"
|
||||
placeholder="Select a private key" :options="$privateKeyOptions" />
|
||||
</div>
|
||||
@can('create', App\Models\PrivateKey::class)
|
||||
<div x-data="{ dropdownOpen: false }" class="relative shrink-0"
|
||||
@click.outside="dropdownOpen = false"
|
||||
@@ -81,6 +70,33 @@
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 border-t border-neutral-200 pt-4 lg:grid-cols-2 dark:border-white/[0.08]">
|
||||
<x-forms.input id="name" label="Name" required />
|
||||
<x-forms.input id="description" label="Description" />
|
||||
</div>
|
||||
|
||||
<div x-data="{ advancedOpen: false }"
|
||||
class="mt-5 border-t border-neutral-200 pt-4 dark:border-white/[0.08]">
|
||||
<button type="button" @click="advancedOpen = !advancedOpen"
|
||||
class="flex w-full items-center justify-between gap-3 text-left text-[13px] font-medium text-neutral-600 dark:text-fg-dim"
|
||||
:aria-expanded="advancedOpen">
|
||||
Advanced settings
|
||||
<x-reicon name="chevron-down" class="size-3.5 transition-transform"
|
||||
x-bind:class="advancedOpen && 'rotate-180'" />
|
||||
</button>
|
||||
|
||||
<div x-show="advancedOpen" x-cloak class="mt-4 flex flex-col gap-4">
|
||||
<div class="grid gap-4 lg:grid-cols-2">
|
||||
<x-forms.input id="user" label="User" required
|
||||
helper="Non-root SSH users are experimental." />
|
||||
<x-forms.input type="number" id="port" label="Port" required />
|
||||
</div>
|
||||
<x-forms.checkbox id="is_build_server"
|
||||
helper="Build servers compile applications but do not host deployments. Enabling this makes the server build-only."
|
||||
label="Use as a dedicated build server" />
|
||||
</div>
|
||||
</div>
|
||||
</x-application.settings-section>
|
||||
</form>
|
||||
@endif
|
||||
|
||||
@@ -13,19 +13,14 @@
|
||||
helper="Monitor server and container health while collecting historical metrics.">
|
||||
<x-slot:actions>
|
||||
<div class="flex items-center gap-2">
|
||||
<x-status-badge
|
||||
:status="!$isSentinelEnabled
|
||||
? 'Disabled'
|
||||
: ($server->isSentinelLive() ? 'In sync' : 'Out of sync')"
|
||||
:type="!$isSentinelEnabled
|
||||
? 'neutral'
|
||||
: ($server->isSentinelLive() ? 'success' : 'warning')" />
|
||||
@if (!$isSentinelEnabled)
|
||||
<x-forms.button canGate="update" :canResource="$server" isHighlighted
|
||||
wire:click="toggleSentinel">
|
||||
Enable Sentinel
|
||||
</x-forms.button>
|
||||
@else
|
||||
<x-status-badge :status="$server->isSentinelLive() ? 'In sync' : 'Out of sync'"
|
||||
:type="$server->isSentinelLive() ? 'success' : 'warning'" />
|
||||
<x-forms.button wire:click="restartSentinel" canGate="update"
|
||||
:canResource="$server">
|
||||
<x-reicon name="refresh" class="size-3.5" />
|
||||
|
||||
@@ -192,17 +192,17 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<x-slide-over closeWithX fullScreen>
|
||||
<x-process-dialog closeWithX size="xl">
|
||||
<x-slot:title>Validate and configure</x-slot:title>
|
||||
<x-slot:content>
|
||||
<livewire:server.validate-and-install :server="$server" :ask="$server->isFunctional()" />
|
||||
</x-slot:content>
|
||||
<x-forms.button type="button"
|
||||
@click="slideOverOpen=true" wire:click.prevent="validateServer">
|
||||
<x-reicon name="refresh" class="size-3.5" />
|
||||
<x-forms.button type="button" :isHighlighted="! $server->isFunctional()"
|
||||
@click="processDialogOpen = true" wire:click.prevent="validateServer">
|
||||
<x-reicon :name="$server->isFunctional() ? 'refresh' : 'alert-circle'" class="size-3.5" />
|
||||
{{ $server->isFunctional() ? 'Revalidate connection' : 'Validate connection' }}
|
||||
</x-forms.button>
|
||||
</x-slide-over>
|
||||
</x-process-dialog>
|
||||
</x-slot:actions>
|
||||
|
||||
@if ($this->limaStartCommand)
|
||||
@@ -261,10 +261,11 @@
|
||||
@if ($isBuildServerLocked)
|
||||
<x-forms.checkbox disabled id="isBuildServer"
|
||||
helper="This server already hosts resources and cannot become build-only."
|
||||
label="Use as a build server" />
|
||||
label="Use as a dedicated build server" />
|
||||
@else
|
||||
<x-forms.checkbox canGate="update" :canResource="$server" instantSave
|
||||
id="isBuildServer" label="Use as a build server"
|
||||
id="isBuildServer" label="Use as a dedicated build server"
|
||||
helper="Build servers compile applications but do not host deployments. Enabling this makes the server build-only."
|
||||
:disabled="$isValidating" />
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
$showDocker = (bool) ($uptime && $supported_os_type && $prerequisites_installed);
|
||||
$showCompose = $showDocker;
|
||||
$showVersion = (bool) ($showDocker && $docker_compose_installed);
|
||||
$validationComplete = (bool) ($uptime
|
||||
&& $supported_os_type
|
||||
&& $prerequisites_installed
|
||||
&& $docker_installed
|
||||
&& $docker_compose_installed
|
||||
&& $docker_version);
|
||||
|
||||
$checkpoints = [
|
||||
[
|
||||
@@ -66,7 +72,7 @@
|
||||
];
|
||||
@endphp
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex h-full min-h-0 flex-col gap-4 overflow-y-auto scrollbar">
|
||||
@if ($ask)
|
||||
<div
|
||||
class="rounded-[10px] border border-neutral-200 bg-neutral-50 px-4 py-3 text-[13px] leading-5 text-neutral-600 dark:border-white/[0.08] dark:bg-white/[0.025] dark:text-fg-dim">
|
||||
@@ -77,28 +83,36 @@
|
||||
Continue
|
||||
</x-forms.button>
|
||||
@else
|
||||
<section class="application-settings-section">
|
||||
<header>
|
||||
<div class="flex items-center gap-2">
|
||||
<h3>Validation checkpoints</h3>
|
||||
</div>
|
||||
</header>
|
||||
<div class="application-settings-section-body is-flush">
|
||||
<div class="divide-y divide-neutral-200 dark:divide-white/[0.07]">
|
||||
@foreach ($checkpoints as $checkpoint)
|
||||
@continue(! $checkpoint['visible'])
|
||||
<x-checkpoint-item :title="$checkpoint['title']" :description="$checkpoint['description']"
|
||||
:status="$checkpoint['status']" />
|
||||
@endforeach
|
||||
</div>
|
||||
<div data-validation-checkpoints
|
||||
class="overflow-hidden rounded-[10px] border border-neutral-200 dark:border-white/[0.08]">
|
||||
<div class="border-b border-neutral-200 px-4 py-2.5 dark:border-white/[0.08]">
|
||||
<h3 class="text-[13px] font-medium text-neutral-600 dark:text-fg-dim">Validation checkpoints</h3>
|
||||
</div>
|
||||
</section>
|
||||
<div class="divide-y divide-neutral-200 dark:divide-white/[0.07]">
|
||||
@foreach ($checkpoints as $checkpoint)
|
||||
<x-checkpoint-item :title="$checkpoint['title']" :description="$checkpoint['description']"
|
||||
:status="$checkpoint['status']" />
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="application-settings-section">
|
||||
<div class="application-settings-section-body">
|
||||
<livewire:activity-monitor :header="$installationStep.' installation logs'" :showWaiting="false" />
|
||||
@if ($validationComplete)
|
||||
<div class="mt-auto flex shrink-0 items-center justify-between gap-3 rounded-[10px] border border-emerald-500/20 bg-emerald-500/[0.06] px-4 py-3">
|
||||
<div class="flex items-center gap-2 text-[13px] font-medium text-emerald-700 dark:text-emerald-300">
|
||||
<x-reicon name="check-circle" class="size-4 shrink-0" />
|
||||
Validation complete
|
||||
</div>
|
||||
<x-forms.button type="button" @click="processDialogOpen = false">
|
||||
Close
|
||||
</x-forms.button>
|
||||
</div>
|
||||
</section>
|
||||
@elseif ($isInstalling)
|
||||
<section class="application-settings-section">
|
||||
<div class="application-settings-section-body">
|
||||
<livewire:activity-monitor :header="$installationStep.' installation logs'" :showWaiting="false" />
|
||||
</div>
|
||||
</section>
|
||||
@endif
|
||||
|
||||
@isset($error)
|
||||
<div
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
test('boarding utility actions are centered', function () {
|
||||
$view = file_get_contents(resource_path('views/livewire/boarding/index.blade.php'));
|
||||
|
||||
expect($view)->toContain('class="mx-auto mt-6 flex w-full max-w-3xl flex-col items-center gap-3"');
|
||||
});
|
||||
|
||||
test('server validation opens in the centered process dialog', function () {
|
||||
$view = file_get_contents(resource_path('views/livewire/boarding/index.blade.php'));
|
||||
|
||||
expect($view)
|
||||
->toContain('<x-process-dialog closeWithX size="xl">')
|
||||
->toContain('@click="processDialogOpen = true"')
|
||||
->not->toContain('<x-slide-over closeWithX fullScreen>');
|
||||
});
|
||||
@@ -19,3 +19,20 @@ it('dispatches a server navbar refresh after toggling sentinel', function () {
|
||||
expect($matches['body'] ?? '')
|
||||
->toContain("\$this->dispatch('refreshServerShow');");
|
||||
});
|
||||
|
||||
it('only marks sentinel enabled after startup succeeds', function () {
|
||||
$componentSource = file_get_contents(app_path('Livewire/Server/Sentinel.php'));
|
||||
|
||||
preg_match('/public function toggleSentinel\([^)]*\).*?\{(?<body>.*?)\n \}/s', $componentSource, $matches);
|
||||
$toggleBody = $matches['body'] ?? '';
|
||||
|
||||
expect(strpos($toggleBody, 'StartSentinel::run'))->toBeLessThan(
|
||||
strpos($toggleBody, '$this->isSentinelEnabled = true;')
|
||||
);
|
||||
});
|
||||
|
||||
it('does not repeat a disabled status badge in the sentinel empty state', function () {
|
||||
$view = file_get_contents(resource_path('views/livewire/server/sentinel.blade.php'));
|
||||
|
||||
expect($view)->not->toContain("? 'Disabled'");
|
||||
});
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
test('server settings explain dedicated build server mode', function () {
|
||||
$view = file_get_contents(resource_path('views/livewire/server/show.blade.php'));
|
||||
|
||||
expect($view)
|
||||
->toContain('label="Use as a dedicated build server"')
|
||||
->toContain('helper="Build servers compile applications but do not host deployments. Enabling this makes the server build-only."');
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
test('server creation uses the standard page title without redundant navigation', function () {
|
||||
$view = file_get_contents(resource_path('views/livewire/server/create.blade.php'));
|
||||
|
||||
expect($view)
|
||||
->toContain('<h1 class="min-w-0 text-[24px]! leading-7! font-semibold! tracking-tight!">New server</h1>')
|
||||
->not->toContain('Back to servers')
|
||||
->not->toContain('title="Add a server"');
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
test('server creation keeps private key actions together and advanced options collapsed', function () {
|
||||
$view = file_get_contents(resource_path('views/livewire/server/new/by-ip.blade.php'));
|
||||
|
||||
expect($view)
|
||||
->toContain('class="flex items-end gap-3"')
|
||||
->toContain('x-data="{ advancedOpen: false }"')
|
||||
->toContain('x-show="advancedOpen" x-cloak')
|
||||
->toContain('Advanced settings')
|
||||
->toContain('label="Use as a dedicated build server"')
|
||||
->toContain('helper="Build servers compile applications but do not host deployments. Enabling this makes the server build-only."');
|
||||
});
|
||||
|
||||
test('server creation places the IP address and private key before optional details', function () {
|
||||
$view = file_get_contents(resource_path('views/livewire/server/new/by-ip.blade.php'));
|
||||
|
||||
expect($view)
|
||||
->toContain('class="mb-5"')
|
||||
->and(strpos($view, 'id="ip"'))->toBeLessThan(strpos($view, 'id="private_key_id"'))
|
||||
->and(strpos($view, 'id="private_key_id"'))->toBeLessThan(strpos($view, 'id="name"'));
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
test('sentinel-required metrics state does not repeat an unavailable badge', function () {
|
||||
$view = file_get_contents(resource_path('views/livewire/server/charts.blade.php'));
|
||||
$sentinelRequiredState = str($view)->after('@else')->before('@endif')->toString();
|
||||
|
||||
expect($sentinelRequiredState)
|
||||
->toContain('title="Sentinel is required"')
|
||||
->not->toContain('status="Unavailable"');
|
||||
});
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
test('server revalidation opens in the centered process dialog', function () {
|
||||
$view = file_get_contents(resource_path('views/livewire/server/show.blade.php'));
|
||||
|
||||
expect($view)
|
||||
->toContain('<x-process-dialog closeWithX size="xl">')
|
||||
->toContain(':isHighlighted="! $server->isFunctional()"')
|
||||
->toContain('@click="processDialogOpen = true" wire:click.prevent="validateServer"');
|
||||
});
|
||||
|
||||
test('completed server validation shows a close action instead of empty logs', function () {
|
||||
$view = file_get_contents(resource_path('views/livewire/server/validate-and-install.blade.php'));
|
||||
|
||||
expect($view)
|
||||
->toContain('$validationComplete')
|
||||
->toContain('mt-auto')
|
||||
->toContain('<x-forms.button type="button" @click="processDialogOpen = false">')
|
||||
->toContain('@click="processDialogOpen = false"')
|
||||
->toContain('Validation complete')
|
||||
->toContain('Close');
|
||||
});
|
||||
|
||||
test('installation logs are only shown after an installation starts', function () {
|
||||
$view = file_get_contents(resource_path('views/livewire/server/validate-and-install.blade.php'));
|
||||
$component = file_get_contents(app_path('Livewire/Server/ValidateAndInstall.php'));
|
||||
|
||||
expect($view)->toContain('@elseif ($isInstalling)')
|
||||
->and($component)
|
||||
->toContain('public bool $isInstalling = false;')
|
||||
->toContain('$this->isInstalling = true;');
|
||||
});
|
||||
|
||||
test('server validation content scrolls within the dialog', function () {
|
||||
$view = file_get_contents(resource_path('views/livewire/server/validate-and-install.blade.php'));
|
||||
$activityMonitor = file_get_contents(resource_path('views/livewire/activity-monitor.blade.php'));
|
||||
|
||||
expect($view)->toContain('class="flex h-full min-h-0 flex-col gap-4 overflow-y-auto scrollbar"')
|
||||
->and($activityMonitor)->toContain("'overflow-hidden' => !\$fullHeight")
|
||||
->and($activityMonitor)->not->toContain("'h-full overflow-hidden' => !\$fullHeight");
|
||||
});
|
||||
|
||||
test('validation checkpoints use the standard bordered list treatment', function () {
|
||||
$view = file_get_contents(resource_path('views/livewire/server/validate-and-install.blade.php'));
|
||||
|
||||
expect($view)
|
||||
->toContain('data-validation-checkpoints')
|
||||
->toContain('overflow-hidden rounded-[10px] border border-neutral-200 dark:border-white/[0.08]');
|
||||
});
|
||||
|
||||
test('all validation checkpoints remain visible while only the current phase runs', function () {
|
||||
$view = file_get_contents(resource_path('views/livewire/server/validate-and-install.blade.php'));
|
||||
|
||||
expect($view)->not->toContain("@continue(! \$checkpoint['visible'])");
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
test('deployment log timestamps omit microseconds', function () {
|
||||
$helper = file_get_contents(dirname(__DIR__, 2).'/bootstrap/helpers/remoteProcess.php');
|
||||
|
||||
expect($helper)
|
||||
->toContain("->format('Y-M-d H:i:s')")
|
||||
->not->toContain("->format('Y-M-d H:i:s.u')");
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
test('sentinel startup regenerates an empty endpoint from instance settings', function () {
|
||||
$action = file_get_contents(dirname(__DIR__, 2).'/app/Actions/Server/StartSentinel.php');
|
||||
$component = file_get_contents(dirname(__DIR__, 2).'/app/Livewire/Server/Sentinel.php');
|
||||
|
||||
expect($action)
|
||||
->toContain('ensureSentinelUrl()')
|
||||
->and($component)
|
||||
->toContain('$this->sentinelCustomUrl = $this->server->settings->sentinel_custom_url;')
|
||||
->and(file_get_contents(dirname(__DIR__, 2).'/app/Models/ServerSetting.php'))
|
||||
->toContain('generateSentinelUrl(ignoreEvent: true)')
|
||||
->toContain('Set an instance FQDN or public IP before enabling Sentinel.')
|
||||
->and($component)
|
||||
->toContain('$this->sentinelCustomUrl = $this->server->settings->sentinel_custom_url;');
|
||||
});
|
||||
Reference in New Issue
Block a user