<?php

declare(strict_types=1);

use App\Support\References\ReferenceClass;
use App\Support\References\ReferenceDescriptor;
use App\Support\References\ReferenceResolutionState;
use App\Support\References\Resolvers\FallbackReferenceResolver;

it('renders unsupported references in a safe degraded form', function (): void {
    $resolved = app(FallbackReferenceResolver::class)->resolve(new ReferenceDescriptor(
        referenceClass: ReferenceClass::Unsupported,
        rawIdentifier: 'guid-123',
        fallbackLabel: 'Provider object',
    ));

    expect($resolved->state)->toBe(ReferenceResolutionState::PartiallyResolved)
        ->and($resolved->primaryLabel)->toBe('Provider object')
        ->and($resolved->linkTarget)->toBeNull();
});

it('keeps unsupported references visible when no fallback label exists', function (): void {
    $resolved = app(FallbackReferenceResolver::class)->resolve(new ReferenceDescriptor(
        referenceClass: ReferenceClass::Unsupported,
        rawIdentifier: 'guid-123',
    ));

    expect($resolved->state)->toBe(ReferenceResolutionState::Unresolved)
        ->and($resolved->primaryLabel)->toBe('Unresolved reference');
});
