TenantAtlas/apps/platform/tests/Feature/OpsUx/RunDetailPollingStopsOnTerminalTest.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

79 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\OperationRun;
use App\Support\OperationRunOutcome;
use App\Support\OperationRunStatus;
use App\Support\OpsUx\RunDetailPolling;
use Illuminate\Support\Carbon;
it('returns the expected interval for active runs based on age', function (string $status, int $ageSeconds, string $expectedInterval): void {
$referenceTime = now();
Carbon::setTestNow($referenceTime);
try {
$run = OperationRun::factory()->make([
'status' => $status,
'outcome' => OperationRunOutcome::Pending->value,
'created_at' => $referenceTime->copy()->subSeconds($ageSeconds),
]);
expect(RunDetailPolling::interval($run))->toBe($expectedInterval);
} finally {
Carbon::setTestNow();
}
})->with([
'queued runs younger than 10 seconds poll every second' => [
OperationRunStatus::Queued->value,
9,
'1s',
],
'queued runs at 10 seconds slow to 5 seconds' => [
OperationRunStatus::Queued->value,
10,
'5s',
],
'running runs younger than 60 seconds poll every 5 seconds' => [
OperationRunStatus::Running->value,
59,
'5s',
],
'running runs at 60 seconds slow to 10 seconds' => [
OperationRunStatus::Running->value,
60,
'10s',
],
])->group('ops-ux');
it('disables run-detail polling once the run is terminal or unrecognized', function (string $status, string $outcome): void {
$run = OperationRun::factory()->make([
'status' => $status,
'outcome' => $outcome,
]);
expect(RunDetailPolling::interval($run))->toBeNull();
})->with([
'completed succeeded' => [
OperationRunStatus::Completed->value,
OperationRunOutcome::Succeeded->value,
],
'completed partially succeeded' => [
OperationRunStatus::Completed->value,
OperationRunOutcome::PartiallySucceeded->value,
],
'completed failed' => [
OperationRunStatus::Completed->value,
OperationRunOutcome::Failed->value,
],
'legacy failed status' => [
'failed',
OperationRunOutcome::Pending->value,
],
'unknown status fallback' => [
'stalled',
OperationRunOutcome::Pending->value,
],
])->group('ops-ux');