Files
coolify/tests/Feature/DatabaseRestoreDialogTest.php
T
Andras BacsaiandClaude Opus 5.5 9e999a2782 fix(database): restore every supported backup format safely
- Detect the backup format before any database is changed. "All databases"
  imports no longer drop everything when the file cannot be restored.
- PostgreSQL: restore custom and tar archives with pg_restore and SQL with
  psql in both modes, including gzip; restore the #11481 custom-archive fix.
  Replacing existing data recreates the database for SQL backups.
- MySQL/MariaDB: accept a tar with one dump; reject dumps with more than one
  database in single mode instead of restoring them partially.
- MongoDB: restore plain and gzip archives and dump directories packed as
  tar; "Replace collections" maps to --drop.
- Prepare bz2, xz, and zip backups in the helper image, because database
  images do not ship those tools; stream S3 backups from the S3 helper.
- Show the exact restore script in the import form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 11:32:04 +02:00

40 lines
2.0 KiB
PHP

<?php
test('database restore output opens in the centered process dialog', function () {
$view = file_get_contents(resource_path('views/livewire/project/database/import-form.blade.php'));
expect($view)
->toContain('<x-process-dialog @databaserestore.window="processDialogOpen = true" closeWithX size="xl">')
->toContain('<livewire:activity-monitor wire:key="database-restore-{{ $resourceUuid }}" header="Logs" fullHeight />')
->not->toContain('<x-slide-over @databaserestore.window="slideOverOpen = true"');
});
test('postgresql dump all restore warns that administrator passwords are overwritten', function () {
$view = file_get_contents(resource_path('views/livewire/project/database/import-form.blade.php'));
expect($view)
->toContain("@if (\$resourceDbType === 'standalone-postgresql' && \$dumpAll)")
->toContain('Full restore overwrites administrator passwords')
->toContain('The backup replaces PostgreSQL administrator role passwords, including the destination administrator password.')
->toContain("If the administrator password changes, update it in Coolify's database configuration after the restore.");
});
test('postgresql single database restore offers explicit object replacement', function () {
$view = file_get_contents(resource_path('views/livewire/project/database/import-form.blade.php'));
expect($view)
->toContain('Replace objects that already exist')
->toContain('wire:model="restoreCommandText"')
->toContain('readonly label="Import command"');
});
test('restore confirmation dialogs warn that existing objects can block the import', function () {
$view = file_get_contents(resource_path('views/livewire/project/database/import-form.blade.php'));
expect($view)
->toContain('submitAction="runImport"')
->toContain('submitAction="restoreFromS3"')
->toContain('Existing objects can cause the import to fail unless replacement is enabled.')
->not->toContain('All existing data will be replaced.');
});