mirror of
https://github.com/tiennm99/coolify.git
synced 2026-09-08 20:19:56 +00:00
feat(ui): add volume backup storage controls and grouped navigation
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
|
||||
use App\Livewire\Storage\Resources as StorageResources;
|
||||
use App\Models\InstanceSettings;
|
||||
use App\Models\LocalPersistentVolume;
|
||||
use App\Models\S3Storage;
|
||||
use App\Models\ScheduledDatabaseBackup;
|
||||
use App\Models\ScheduledVolumeBackup;
|
||||
use App\Models\Team;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
@@ -75,6 +77,57 @@ beforeEach(function () {
|
||||
});
|
||||
|
||||
describe('Storage/Resources team-scoped backup access', function () {
|
||||
test('lists and manages volume backup schedules using this storage', function () {
|
||||
$volume = LocalPersistentVolume::create([
|
||||
'name' => 'minio-volume-data',
|
||||
'mount_path' => '/data',
|
||||
'resource_id' => 999,
|
||||
'resource_type' => 'App\\Models\\Application',
|
||||
]);
|
||||
$backup = ScheduledVolumeBackup::create([
|
||||
'uuid' => fake()->uuid(),
|
||||
'backupable_type' => $volume->getMorphClass(),
|
||||
'backupable_id' => $volume->id,
|
||||
'team_id' => $this->teamA->id,
|
||||
's3_storage_id' => $this->storageA->id,
|
||||
'frequency' => 'daily',
|
||||
'enabled' => true,
|
||||
'save_s3' => true,
|
||||
]);
|
||||
$destination = S3Storage::unguarded(fn () => S3Storage::create([
|
||||
'uuid' => fake()->uuid(),
|
||||
'name' => 'volume-backup-destination',
|
||||
'region' => 'us-east-1',
|
||||
'key' => 'key-c',
|
||||
'secret' => 'secret-c',
|
||||
'bucket' => 'bucket-c',
|
||||
'endpoint' => 'https://s3.example.com',
|
||||
'team_id' => $this->teamA->id,
|
||||
'is_usable' => true,
|
||||
]));
|
||||
|
||||
Livewire::test(StorageResources::class, ['storage' => $this->storageA])
|
||||
->assertSee('minio-volume-data')
|
||||
->assertSee('Volume')
|
||||
->assertSeeHtml('class="listbox-trigger"')
|
||||
->assertSeeHtml('x-teleport="body"')
|
||||
->assertSeeHtml('requestAnimationFrame')
|
||||
->assertSeeHtml('-panel"')
|
||||
->assertSeeHtml("visibility: positioned ? 'visible' : 'hidden'")
|
||||
->assertSeeHtml('positionPanel($el)')
|
||||
->assertSeeHtml('class="flex items-center"')
|
||||
->set("selectedVolumeStorages.{$backup->id}", $destination->id)
|
||||
->call('moveVolumeBackup', $backup->id);
|
||||
|
||||
expect($backup->refresh()->s3_storage_id)->toBe($destination->id);
|
||||
|
||||
Livewire::test(StorageResources::class, ['storage' => $destination])
|
||||
->call('disableVolumeS3', $backup->id);
|
||||
|
||||
expect($backup->refresh()->save_s3)->toBeFalse()
|
||||
->and($backup->s3_storage_id)->toBeNull();
|
||||
});
|
||||
|
||||
test('disableS3 on other team backup throws and leaves row unchanged', function () {
|
||||
expect(fn () => Livewire::test(StorageResources::class, ['storage' => $this->storageA])
|
||||
->call('disableS3', $this->backupB->id))
|
||||
|
||||
Reference in New Issue
Block a user