<?php

namespace Tests\Feature\Livewire;

use App\Filament\Pages\QuestionManagement;
use App\Services\QuestionServiceApi;
use App\Services\QuestionBankService;
use App\Services\KnowledgeGraphService;
use Livewire\Livewire;
use Tests\TestCase;
use Mockery;

class QuestionManagementTest extends TestCase
{
    protected function setUp(): void
    {
        parent::setUp();
        
        // Mock Services
        $this->mock(QuestionServiceApi::class, function ($mock) {
            $mock->shouldReceive('listQuestions')->andReturn(['data' => [], 'meta' => []]);
            $mock->shouldReceive('getStatistics')->andReturn(['total' => 0]);
            $mock->shouldReceive('getKnowledgePointOptions')->andReturn(['KP1001' => 'Test KP']);
        });

        $this->mock(KnowledgeGraphService::class, function ($mock) {
            $mock->shouldReceive('getSkillsByKnowledgePoint')->andReturn([]);
        });
    }

    public function test_component_can_render()
    {
        Livewire::test(QuestionManagement::class)
            ->assertStatus(200);
    }

    public function test_filters_update_properties()
    {
        Livewire::test(QuestionManagement::class)
            ->set('selectedKpCode', 'KP1001')
            ->set('selectedDifficulty', '0.5')
            ->set('selectedType', 'CHOICE') // New property
            ->assertSet('selectedKpCode', 'KP1001')
            ->assertSet('selectedDifficulty', '0.5')
            ->assertSet('selectedType', 'CHOICE');
    }

    public function test_generation_modal_properties()
    {
        Livewire::test(QuestionManagement::class)
            ->set('generateKpCode', 'KP1001')
            ->set('generateDifficulty', '0.8') // New property
            ->set('generateType', 'CALCULATION') // New property
            ->assertSet('generateKpCode', 'KP1001')
            ->assertSet('generateDifficulty', '0.8')
            ->assertSet('generateType', 'CALCULATION');
    }
}
