<?php

test('health endpoint returns 200 when no check fails', function () {
    $response = $this->getJson('/api/health');

    $response->assertOk()
        ->assertJsonStructure(['status', 'timestamp', 'checks' => ['database', 'storage', 'queue']]);

    expect($response->json('status'))->toBeIn(['healthy', 'warn']);
});

test('health endpoint returns JSON with timestamp', function () {
    $response = $this->getJson('/api/health');

    $response->assertOk()->assertJsonStructure(['timestamp']);

    expect($response->json('timestamp'))->toBeString();
});

test('health endpoint reports per-check status keys', function () {
    $checks = $this->getJson('/api/health')->json('checks');

    foreach (['database', 'redis', 'storage', 'queue'] as $key) {
        expect($checks)->toHaveKey($key);
        expect($checks[$key]['status'])->toBeIn(['ok', 'warn', 'fail', 'unknown']);
    }
});
