Files
michaelschiemer/tests/Feature/Framework/LiveComponents/E2E/PartialRenderingE2ETest.php
2025-11-24 21:28:25 +01:00

57 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\Framework\LiveComponents\E2E;
use Tests\Feature\Framework\LiveComponents\TestHarness\LiveComponentTestCase;
/**
* E2E Tests for Partial Rendering
*
* Tests fragment-based partial updates end-to-end.
*/
class PartialRenderingE2ETest extends LiveComponentTestCase
{
public function test_updates_single_fragment_via_action(): void
{
$this->mount('counter:test', ['count' => 0]);
// Call action with fragment request
$this->call('increment', ['amount' => 5], ['counter-display']);
// Should return fragments instead of full HTML
$html = $this->getHtml();
$this->assertIsArray($html);
$this->assertArrayHasKey('counter-display', $html);
$this->assertStringContainsString('5', $html['counter-display']);
// State should be updated
$this->seeStateKey('count', 5);
}
public function test_updates_multiple_fragments_simultaneously(): void
{
// This would require a component with multiple fragments
$this->markTestSkipped('Requires component with multiple fragments');
}
public function test_falls_back_to_full_render_when_fragments_not_found(): void
{
$this->mount('counter:test', ['count' => 0]);
// Request non-existent fragment
$this->call('increment', ['amount' => 5], ['non-existent-fragment']);
// Should fall back to full HTML
$html = $this->getHtml();
$this->assertIsString($html);
$this->assertStringContainsString('5', $html);
}
}