- Add bulk restore + archived-only force delete actions - Add jobs + tests for bulk restore/force delete - Treat restore_run status 'partial' as deletable for hygiene - Update feature tasks checklist
58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
|
|
use App\Filament\Resources\RestoreRunResource;
|
|
use App\Models\BackupSet;
|
|
use App\Models\BulkOperationRun;
|
|
use App\Models\RestoreRun;
|
|
use App\Models\Tenant;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
test('restore runs table bulk restore creates a run and restores archived records', function () {
|
|
$tenant = Tenant::factory()->create();
|
|
$user = User::factory()->create();
|
|
|
|
$backupSet = BackupSet::create([
|
|
'tenant_id' => $tenant->id,
|
|
'name' => 'Backup',
|
|
'status' => 'completed',
|
|
'item_count' => 0,
|
|
]);
|
|
|
|
$run = RestoreRun::create([
|
|
'tenant_id' => $tenant->id,
|
|
'backup_set_id' => $backupSet->id,
|
|
'status' => 'completed',
|
|
'is_dry_run' => true,
|
|
'requested_by' => 'tester@example.com',
|
|
]);
|
|
|
|
$run->delete();
|
|
expect($run->trashed())->toBeTrue();
|
|
|
|
Livewire::actingAs($user)
|
|
->test(RestoreRunResource\Pages\ListRestoreRuns::class)
|
|
->filterTable(\Filament\Tables\Filters\TrashedFilter::class, false)
|
|
->callTableBulkAction('bulk_restore', collect([$run]))
|
|
->assertHasNoTableBulkActionErrors();
|
|
|
|
$bulkRun = BulkOperationRun::query()
|
|
->where('tenant_id', $tenant->id)
|
|
->where('user_id', $user->id)
|
|
->where('resource', 'restore_run')
|
|
->where('action', 'restore')
|
|
->latest('id')
|
|
->first();
|
|
|
|
expect($bulkRun)->not->toBeNull();
|
|
expect($bulkRun->succeeded)->toBe(1)
|
|
->and($bulkRun->skipped)->toBe(0)
|
|
->and($bulkRun->failed)->toBe(0);
|
|
|
|
$run->refresh();
|
|
expect($run->trashed())->toBeFalse();
|
|
});
|