fix(deployment): detect application configuration changes consistently

Expand configuration snapshots, handle defaults from older snapshots, and refresh configuration state after Livewire setting changes.
This commit is contained in:
Andras Bacsai committed 2026-07-14 12:54:31 +02:00
1 parent 5381287606
commit 99e255a572
16 files changed
+415 -11

No files matched your search

@@ -16,6 +16,8 @@ uses(RefreshDatabase::class);
function createApplicationForAdvancedStopGracePeriodTest(): Application
{
$team = Team::factory()->create();
$team->members()->attach(auth()->id(), ['role' => 'owner']);
session(['currentTeam' => $team]);
$server = Server::factory()->create(['team_id' => $team->id]);
$project = Project::factory()->create(['team_id' => $team->id]);
$environment = Environment::factory()->create(['project_id' => $project->id]);
@@ -43,7 +45,8 @@ it('saves a valid stop grace period', function () {
->set('stopGracePeriod', '300')
->call('saveStopGracePeriod')
->assertHasNoErrors()
->assertDispatched('success');
->assertDispatched('success')
->assertDispatched('configurationChanged');
expect($application->settings()->first()->stop_grace_period)->toBe(300);
});
@@ -0,0 +1,44 @@
<?php
use App\Livewire\Project\Shared\EnvironmentVariable\All as EnvironmentVariableAll;
use App\Livewire\Project\Shared\HealthChecks;
use App\Models\Application;
use App\Models\Environment;
use App\Models\InstanceSettings;
use App\Models\Project;
use App\Models\Team;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
uses(RefreshDatabase::class);
beforeEach(function () {
InstanceSettings::unguarded(function () {
InstanceSettings::updateOrCreate(['id' => 0], []);
});
$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]);
$project = Project::factory()->create(['team_id' => $this->team->id]);
$environment = Environment::factory()->create(['project_id' => $project->id]);
$this->application = Application::factory()->create(['environment_id' => $environment->id])->refresh();
});
it('refreshes configuration changes after health check saves', function (string $method) {
Livewire::test(HealthChecks::class, ['resource' => $this->application])
->call($method)
->assertHasNoErrors()
->assertDispatched('configurationChanged');
})->with(['instantSave', 'submit', 'toggleHealthcheck']);
it('refreshes configuration changes after environment variable settings are saved', function () {
Livewire::test(EnvironmentVariableAll::class, ['resource' => $this->application])
->set('use_build_secrets', true)
->call('instantSave')
->assertHasNoErrors()
->assertDispatched('configurationChanged');
});
@@ -0,0 +1,36 @@
<?php
use App\Livewire\Project\Application\Swarm;
use App\Models\Application;
use App\Models\Environment;
use App\Models\Project;
use App\Models\Server;
use App\Models\Team;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
uses(RefreshDatabase::class);
it('dispatches configuration changed when Swarm settings are saved', function (string $method) {
$team = Team::factory()->create();
$user = User::factory()->create();
$team->members()->attach($user->id, ['role' => 'owner']);
$server = Server::factory()->create(['team_id' => $team->id]);
$project = Project::factory()->create(['team_id' => $team->id]);
$environment = Environment::factory()->create(['project_id' => $project->id]);
$application = Application::factory()->create([
'environment_id' => $environment->id,
'destination_id' => $server->standaloneDockers()->firstOrFail()->id,
'destination_type' => $server->standaloneDockers()->firstOrFail()->getMorphClass(),
'swarm_replicas' => 1,
]);
$this->actingAs($user);
Livewire::test(Swarm::class, ['application' => $application])
->set('isSwarmOnlyWorkerNodes', false)
->call($method)
->assertHasNoErrors()
->assertDispatched('configurationChanged');
})->with(['instantSave', 'submit']);