<?php

declare(strict_types=1);

use App\Support\ProductTelemetry\ProductUsageEventCatalog;

it('exposes the bounded first-slice event catalog', function () {
    $catalog = new ProductUsageEventCatalog();

    expect($catalog->names())->toBe([
        ProductUsageEventCatalog::ONBOARDING_CHECKPOINT_COMPLETED,
        ProductUsageEventCatalog::SUPPORT_DIAGNOSTICS_OPENED,
        ProductUsageEventCatalog::OPERATIONS_STARTED,
        ProductUsageEventCatalog::STORED_REPORT_CREATED,
        ProductUsageEventCatalog::REVIEW_PACK_REQUESTED,
    ])->and($catalog->visibleFamilies())->toBe([
        ProductUsageEventCatalog::ONBOARDING_CHECKPOINT_COMPLETED => 'Onboarding checkpoints',
        ProductUsageEventCatalog::SUPPORT_DIAGNOSTICS_OPENED => 'Support diagnostics',
        ProductUsageEventCatalog::OPERATIONS_STARTED => 'Operations started',
        ProductUsageEventCatalog::STORED_REPORT_CREATED => 'Stored reports',
        ProductUsageEventCatalog::REVIEW_PACK_REQUESTED => 'Review packs requested',
    ])->and($catalog->allowedMetadataKeys(ProductUsageEventCatalog::ONBOARDING_CHECKPOINT_COMPLETED))
        ->toBe(['checkpoint_key', 'lifecycle_state', 'completed_at']);
});

it('rejects unknown product telemetry events', function () {
    $catalog = new ProductUsageEventCatalog();

    expect(fn () => $catalog->definition('product.unknown'))
        ->toThrow(InvalidArgumentException::class, 'Unknown product telemetry event');
});