<?php

declare(strict_types=1);

use App\Services\Entitlements\WorkspacePlanProfileCatalog;

it('exposes a bounded profile catalog with exactly one default profile', function (): void {
    $catalog = app(WorkspacePlanProfileCatalog::class);
    $profiles = $catalog->all();

    expect($profiles)
        ->toHaveCount(3)
        ->and(collect($profiles)->where('is_default', true))->toHaveCount(1)
        ->and(WorkspacePlanProfileCatalog::defaultProfileId())->toBe('standard')
        ->and($catalog->default()['label'])->toBe('Standard');
});

it('resolves known profiles and falls back to the default for unknown identifiers', function (): void {
    $catalog = app(WorkspacePlanProfileCatalog::class);

    expect($catalog->resolve('starter'))
        ->toMatchArray([
            'id' => 'starter',
            'managed_tenant_limit_default' => 1,
            'review_pack_generation_default' => false,
        ])
        ->and($catalog->resolve('missing-profile')['id'])->toBe('standard')
        ->and($catalog->optionLabels())
        ->toMatchArray([
            'starter' => 'Starter',
            'standard' => 'Standard',
            'scale' => 'Scale',
        ]);
});