<?php

declare(strict_types=1);

namespace App\Tests\Mcp\Tool;

use App\Tests\AbstractApiTestCase;

/**
 * @internal
 */
class HistoryToolsTest extends AbstractApiTestCase
{
    public function testGetActivityLog(): void
    {
        $session = $this->createMcpClient('ROLE_VIEWER');

        $data = $this->callMcpTool($session, 'get_activity_log');

        $this->assertArrayHasKey('_parsed', $data);
        $this->assertArrayHasKey('items', $data['_parsed']);
        $this->assertArrayHasKey('total', $data['_parsed']);
        $this->assertArrayHasKey('page', $data['_parsed']);
        $this->assertArrayHasKey('limit', $data['_parsed']);
        $this->assertArrayHasKey('pageCount', $data['_parsed']);
        $this->assertIsArray($data['_parsed']['items']);
    }

    public function testGetEntityHistory(): void
    {
        $machine = $this->createMachine(name: 'History Machine');
        $session = $this->createMcpClient('ROLE_VIEWER');

        $data = $this->callMcpTool($session, 'get_entity_history', [
            'entityType' => 'machine',
            'entityId'   => $machine->getId(),
        ]);

        $this->assertArrayHasKey('_parsed', $data);
        $this->assertArrayHasKey('items', $data['_parsed']);
        $this->assertArrayHasKey('total', $data['_parsed']);
        $this->assertIsArray($data['_parsed']['items']);
    }
}
