101 lines
3.0 KiB
PHP
101 lines
3.0 KiB
PHP
<?php
|
|
|
|
use App\Filament\Resources\RestoreRunResource\Pages\CreateRestoreRun;
|
|
use App\Models\BackupItem;
|
|
use App\Models\BackupSet;
|
|
use App\Models\Policy;
|
|
use App\Models\Tenant;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
test('restore selection shows readable labels and descriptions', function () {
|
|
$tenant = Tenant::factory()->create(['status' => 'active']);
|
|
$tenant->makeCurrent();
|
|
|
|
$policy = Policy::factory()->create([
|
|
'tenant_id' => $tenant->id,
|
|
'external_id' => 'policy-1',
|
|
'policy_type' => 'settingsCatalogPolicy',
|
|
'display_name' => 'Policy Display',
|
|
'platform' => 'windows',
|
|
]);
|
|
$ignoredPolicy = Policy::factory()->create([
|
|
'tenant_id' => $tenant->id,
|
|
'external_id' => 'policy-ignored',
|
|
'policy_type' => 'deviceCompliancePolicy',
|
|
'display_name' => 'Ignored Policy',
|
|
'platform' => 'windows',
|
|
'ignored_at' => now(),
|
|
]);
|
|
|
|
$backupSet = BackupSet::factory()->for($tenant)->create([
|
|
'item_count' => 2,
|
|
]);
|
|
|
|
BackupItem::factory()
|
|
->for($tenant)
|
|
->for($backupSet)
|
|
->state([
|
|
'policy_id' => $policy->id,
|
|
'policy_identifier' => $policy->external_id,
|
|
'policy_type' => $policy->policy_type,
|
|
'platform' => $policy->platform,
|
|
'payload' => ['id' => $policy->external_id],
|
|
])
|
|
->create();
|
|
|
|
BackupItem::factory()
|
|
->for($tenant)
|
|
->for($backupSet)
|
|
->state([
|
|
'policy_id' => $ignoredPolicy->id,
|
|
'policy_identifier' => $ignoredPolicy->external_id,
|
|
'policy_type' => $ignoredPolicy->policy_type,
|
|
'platform' => $ignoredPolicy->platform,
|
|
'payload' => ['id' => $ignoredPolicy->external_id],
|
|
])
|
|
->create();
|
|
|
|
BackupItem::factory()
|
|
->for($tenant)
|
|
->for($backupSet)
|
|
->state([
|
|
'policy_id' => null,
|
|
'policy_identifier' => 'tag-1',
|
|
'policy_type' => 'roleScopeTag',
|
|
'platform' => 'all',
|
|
'payload' => [
|
|
'id' => 'tag-1',
|
|
'displayName' => 'Scope Tag Alpha',
|
|
],
|
|
'metadata' => [
|
|
'displayName' => 'Scope Tag Alpha',
|
|
],
|
|
])
|
|
->create();
|
|
|
|
$user = User::factory()->create();
|
|
$this->actingAs($user);
|
|
|
|
Livewire::test(CreateRestoreRun::class)
|
|
->fillForm([
|
|
'backup_set_id' => $backupSet->id,
|
|
])
|
|
->goToNextWizardStep()
|
|
->fillForm([
|
|
'scope_mode' => 'selected',
|
|
])
|
|
->assertSee('Policy Display')
|
|
->assertDontSee('Ignored Policy')
|
|
->assertSee('Scope Tag Alpha')
|
|
->assertSee('Settings Catalog Policy')
|
|
->assertSee('Scope Tag')
|
|
->assertSee('restore: enabled')
|
|
->assertSee('id: policy-1')
|
|
->assertSee('id: tag-1')
|
|
->assertSee('Include foundations');
|
|
});
|