<?php

declare(strict_types=1);

use App\Support\OperationCatalog;
use App\Support\OperationRunType;

it('uses canonical dotted operation codes as enum values', function (): void {
    expect(OperationRunType::BaselineCapture->value)->toBe('baseline.capture')
        ->and(OperationRunType::BaselineCompare->value)->toBe('baseline.compare')
        ->and(OperationRunType::InventorySync->value)->toBe('inventory.sync')
        ->and(OperationRunType::DirectoryGroupsSync->value)->toBe('directory.groups.sync')
        ->and(OperationRunType::BackupScheduleExecute->value)->toBe('backup.schedule.execute')
        ->and(OperationRunType::BackupScheduleRetention->value)->toBe('backup.schedule.retention')
        ->and(OperationRunType::BackupSchedulePurge->value)->toBe('backup.schedule.purge')
        ->and(OperationRunType::DirectoryRoleDefinitionsSync->value)->toBe('directory.role_definitions.sync');
});

it('keeps enum canonicalCode as a no-op compatibility shim', function (): void {
    foreach (OperationRunType::cases() as $case) {
        expect($case->canonicalCode())->toBe($case->value);
    }
});

it('does not expose legacy raw aliases as enum values', function (): void {
    expect(OperationRunType::values())->not->toContain(
        'baseline_capture',
        'baseline_compare',
        'inventory_sync',
        'entra_group_sync',
        'backup_schedule_run',
        'backup_schedule_retention',
        'backup_schedule_purge',
        'directory_role_definitions.sync',
    );
});

it('keeps every enum value in the operation catalog as current canonical truth', function (): void {
    foreach (OperationRunType::values() as $type) {
        $resolution = OperationCatalog::resolve($type);

        expect($resolution->aliasStatus)->toBe('canonical')
            ->and($resolution->canonical->canonicalCode)->toBe($type);
    }
});
