An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(resources): dispatch deletion cleanup after response
Andras Bacsaie514a2d61f26
diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.phpindex 7f0d3b173e..d2420a029f 100644--- a/app/Livewire/Project/Shared/Danger.php+++ b/app/Livewire/Project/Shared/Danger.php@@ -106,14 +106,13 @@ class Danger extends Componenttry {$this->authorize('delete', $this->resource);- $this->resource->delete();DeleteResourceJob::dispatch($this->resource,$this->delete_volumes,$this->delete_connected_networks,$this->delete_configurations,$this->docker_cleanup- );+ )->afterResponse();return redirectRoute($this, 'project.resource.index', ['project_uuid' => $this->projectUuid,diff --git a/tests/v4/Feature/DangerDeleteResourceTest.php b/tests/v4/Feature/DangerDeleteResourceTest.phpindex 7a73f59795..af409a3c46 100644--- a/tests/v4/Feature/DangerDeleteResourceTest.php+++ b/tests/v4/Feature/DangerDeleteResourceTest.php@@ -1,11 +1,13 @@<?php+use App\Jobs\DeleteResourceJob;use App\Livewire\Project\Shared\Danger;use App\Models\Application;use App\Models\Environment;use App\Models\InstanceSettings;use App\Models\Project;use App\Models\Server;+use App\Models\Service;use App\Models\StandaloneDocker;use App\Models\Team;use App\Models\User;@@ -18,7 +20,7 @@ use Livewire\Livewire;uses(RefreshDatabase::class);beforeEach(function () {- InstanceSettings::create(['id' => 0]);+ InstanceSettings::forceCreate(['id' => 0]);Queue::fake();$this->user = User::factory()->create([@@ -61,13 +63,28 @@ test('delete returns error string when password is incorrect', function () {expect(Application::find($this->application->id))->not->toBeNull();});-test('delete succeeds with correct password and redirects', function () {- Livewire::test(Danger::class, ['resource' => $this->application])+test('delete redirects before dispatching resource cleanup after the response', function () {+ $service = Service::factory()->create([+ 'environment_id' => $this->environment->id,+ 'server_id' => $this->server->id,+ 'destination_id' => $this->destination->id,+ 'destination_type' => $this->destination->getMorphClass(),+ ]);++ $component = Livewire::test(Danger::class, ['resource' => $service])+ ->set('projectUuid', $this->project->uuid)+ ->set('environmentUuid', $this->environment->uuid)->call('delete', 'test-password')- ->assertHasNoErrors();+ ->assertHasNoErrors()+ ->assertRedirectToRoute('project.resource.index', [+ 'project_uuid' => $this->project->uuid,+ 'environment_uuid' => $this->environment->uuid,+ ]);++ expect($component->effects)->toHaveKey('redirectUsingNavigate', true);- // Resource should be soft-deleted- expect(Application::find($this->application->id))->toBeNull();+ expect(Service::find($service->id))->not->toBeNull();+ Queue::assertPushed(DeleteResourceJob::class, fn (DeleteResourceJob $job) => $job->resource->is($service));});test('delete applies selectedActions from checkbox state', function () {