<?php

declare(strict_types=1);

use App\Models\OperationRun;
use App\Support\OpsUx\RunDetailPolling;

it('disables run-detail polling once the run is terminal', function (): void {
    $run = OperationRun::factory()->create([
        'status' => 'completed',
        'outcome' => 'succeeded',
    ]);

    expect(RunDetailPolling::interval($run))->toBeNull();
})->group('ops-ux');

it('enables run-detail polling while the run is queued or running', function (string $status): void {
    $run = OperationRun::factory()->create([
        'status' => $status,
        'outcome' => 'pending',
    ]);

    expect(RunDetailPolling::interval($run))->not->toBeNull();
})->with([
    'queued' => 'queued',
    'running' => 'running',
])->group('ops-ux');
