TenantAtlas/apps/platform/tests/Unit/Support/BackupQuality/BackupSetQualitySummaryTest.php
ahmido ce0615a9c1 Spec 182: relocate Laravel platform to apps/platform (#213)
## Summary
- move the Laravel application into `apps/platform` and keep the repository root for orchestration, docs, and tooling
- update the local command model, Sail/Docker wiring, runtime paths, and ignore rules around the new platform location
- add relocation quickstart/contracts plus focused smoke coverage for bootstrap, command model, routes, and runtime behavior

## Validation
- `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/PlatformRelocation`
- integrated browser smoke validated `/up`, `/`, `/admin`, `/admin/choose-workspace`, and tenant route semantics for `200`, `403`, and `404`

## Remaining Rollout Checks
- validate Dokploy build context and working-directory assumptions against the new `apps/platform` layout
- confirm web, queue, and scheduler processes all start from the expected working directory in staging/production
- verify no legacy volume mounts or asset-publish paths still point at the old root-level `public/` or `storage/` locations

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #213
2026-04-08 08:40:47 +00:00

76 lines
2.6 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\BackupItem;
use App\Models\BackupSet;
use App\Support\BackupQuality\BackupQualityResolver;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
it('renders a clear backup-set summary when no degradations are detected', function (): void {
$backupSet = new BackupSet([
'status' => 'completed',
'item_count' => 2,
]);
$backupSet->setRelation('items', new EloquentCollection([
new BackupItem([
'payload' => ['id' => 'one'],
'metadata' => [],
'assignments' => [],
]),
new BackupItem([
'payload' => ['id' => 'two'],
'metadata' => [],
'assignments' => [],
]),
]));
$summary = app(BackupQualityResolver::class)->summarizeBackupSet($backupSet);
expect($summary->degradedItemCount)->toBe(0)
->and($summary->compactSummary)->toBe('No degradations detected across 2 items')
->and($summary->summaryMessage)->toBe('No degradations were detected across 2 captured items.');
});
it('aggregates degraded backup-set counts from existing item metadata', function (): void {
$backupSet = new BackupSet([
'status' => 'completed',
'item_count' => 3,
]);
$backupSet->setRelation('items', new EloquentCollection([
new BackupItem([
'payload' => ['id' => 'healthy'],
'metadata' => [],
'assignments' => [],
]),
new BackupItem([
'payload' => [],
'metadata' => [
'source' => 'metadata_only',
'assignments_fetch_failed' => true,
],
'assignments' => [],
]),
new BackupItem([
'payload' => ['id' => 'warning'],
'metadata' => [
'has_orphaned_assignments' => true,
'integrity_warning' => 'Protected values are intentionally hidden.',
],
'assignments' => [],
]),
]));
$summary = app(BackupQualityResolver::class)->summarizeBackupSet($backupSet);
expect($summary->degradedItemCount)->toBe(2)
->and($summary->metadataOnlyCount)->toBe(1)
->and($summary->assignmentIssueCount)->toBe(1)
->and($summary->orphanedAssignmentCount)->toBe(1)
->and($summary->integrityWarningCount)->toBe(1)
->and($summary->compactSummary)->toBe('2 degraded items • 1 metadata-only • 1 assignment issue • 1 orphaned assignment • 1 integrity warning')
->and($summary->nextAction)->toBe('Open the backup set detail and inspect degraded items before continuing into restore.');
});