fix(resources): hide deleted resources on the environment page after the redirect

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2026-10-24 22:12:57 +02:00
co-authored by Claude Opus 5.5
parent d30f582bfe
commit 887461ab2d
2 changed files with 6 additions and 2 deletions
+2
View File
@@ -115,6 +115,8 @@ class Danger extends Component
try {
$this->authorize('delete', $this->resource);
// Soft delete first, so the environment page after the redirect does not list the resource.
$this->resource->delete();
DeleteResourceJob::dispatch(
$this->resource,
$this->delete_volumes,
@@ -64,7 +64,7 @@ test('delete returns error string when password is incorrect', function () {
expect(Application::find($this->application->id))->not->toBeNull();
});
test('delete redirects before dispatching resource cleanup after the response', function () {
test('delete hides the resource before the redirect and dispatches cleanup after the response', function () {
$service = Service::factory()->create([
'environment_id' => $this->environment->id,
'server_id' => $this->server->id,
@@ -84,7 +84,9 @@ test('delete redirects before dispatching resource cleanup after the response',
expect($component->effects)->toHaveKey('redirectUsingNavigate', true);
expect(Service::find($service->id))->not->toBeNull();
// The redirected environment page must not list the resource while the cleanup job still runs.
expect(Service::find($service->id))->toBeNull()
->and(Service::withTrashed()->find($service->id))->not->toBeNull();
Queue::assertPushed(DeleteResourceJob::class, fn (DeleteResourceJob $job) => $job->resource->is($service));
});