<?php

namespace Tests\Feature\Api;

use App\Models\Device;
use App\Models\Site;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Str;
use Tests\TestCase;

class ConfigTest extends TestCase
{
    use RefreshDatabase;

    public function test_config_endpoint_returns_expected_shape(): void
    {
        $site = Site::factory()->create();
        $token = Str::random(64);
        Device::factory()->create(['site_id' => $site->id, 'token_hash' => hash('sha256', $token)]);

        $response = $this->withHeaders(['X-Device-Token' => $token])->getJson('/api/v1/config');
        $response->assertOk();
        $response->assertJsonStructure([
            'config_version', 'match_threshold', 'liveness_enabled', 'liveness_threshold',
            'debounce_minutes', 'direction_area_ratio', 'min_direction_confidence',
            'sync_interval_s', 'heartbeat_interval_s', 'snapshot_upload', 'shift_start', 'shift_end',
        ]);
    }
}
