TenantAtlas/apps/platform/database/factories/RestoreRunFactory.php
ahmido f1a73490e4 feat: finalize dashboard recovery honesty (#215)
## Summary
- add a dedicated Recovery Readiness dashboard widget for backup posture and recovery evidence
- group Needs Attention items by domain and elevate the recovery call-to-action
- align restore-run and recovery posture tests with the extracted widget and continuity flows
- include the related spec artifacts for 184-dashboard-recovery-honesty

## Verification
- `cd /Users/ahmeddarrazi/Documents/projects/TenantAtlas/apps/platform && ./vendor/bin/sail bin pint --dirty --format agent`
- `cd /Users/ahmeddarrazi/Documents/projects/TenantAtlas/apps/platform && ./vendor/bin/sail artisan test --compact --filter="DashboardKpisWidget|DashboardRecoveryPosture|TenantDashboardDbOnly|TenantpilotSeedBackupHealthBrowserFixtureCommand|NeedsAttentionWidget"`
- browser smoke verified on the calm, unvalidated, and weakened dashboard states

## Notes
- Livewire v4.0+ compliant with Filament v5
- no panel provider changes; Laravel 11+ provider registration remains in `bootstrap/providers.php`
- Recovery Readiness stays within the existing tenant dashboard asset strategy; no new Filament asset registration required

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #215
2026-04-08 23:21:36 +00:00

141 lines
3.9 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\BackupSet;
use App\Models\Tenant;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\RestoreRun>
*/
class RestoreRunFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'tenant_id' => Tenant::factory(),
'backup_set_id' => BackupSet::factory(),
'status' => 'completed',
'is_dry_run' => false,
'requested_items' => [],
'preview' => [],
'results' => [],
'metadata' => [],
'group_mapping' => null,
'started_at' => now()->subHour(),
'completed_at' => now(),
];
}
public function previewOnly(): static
{
return $this->state(fn (): array => [
'status' => 'previewed',
'is_dry_run' => true,
'preview' => [
[
'policy_identifier' => 'preview-policy',
'policy_type' => 'deviceConfiguration',
'platform' => 'windows',
'action' => 'update',
],
],
'results' => [],
'metadata' => [],
'completed_at' => null,
]);
}
public function failedOutcome(): static
{
return $this->state(fn (): array => [
'status' => 'failed',
'is_dry_run' => false,
'results' => [
'foundations' => [],
'items' => [
[
'status' => 'failed',
'policy_identifier' => 'failed-policy',
],
],
],
'metadata' => [],
'completed_at' => now(),
]);
}
public function partialOutcome(): static
{
return $this->state(fn (): array => [
'status' => 'completed',
'is_dry_run' => false,
'results' => [
'foundations' => [],
'items' => [
[
'status' => 'partial',
'policy_identifier' => 'partial-policy',
],
],
],
'metadata' => [],
'completed_at' => now(),
]);
}
public function completedWithFollowUp(): static
{
return $this->state(fn (): array => [
'status' => 'completed',
'is_dry_run' => false,
'results' => [
'foundations' => [],
'items' => [
[
'status' => 'applied',
'policy_identifier' => 'follow-up-policy',
'assignment_outcomes' => [
['status' => 'skipped', 'assignment' => []],
],
],
],
],
'metadata' => [
'non_applied' => 1,
],
'completed_at' => now(),
]);
}
public function completedOutcome(): static
{
return $this->state(fn (): array => [
'status' => 'completed',
'is_dry_run' => false,
'results' => [
'foundations' => [],
'items' => [
[
'status' => 'applied',
'policy_identifier' => 'completed-policy',
'assignment_outcomes' => [
['status' => 'success', 'assignment' => []],
],
],
],
],
'metadata' => [
'non_applied' => 0,
],
'completed_at' => now(),
]);
}
}