refactor: upgrade to Livewire 4

This commit is contained in:
Benjamin Nussbaum 2026-01-14 23:59:00 +01:00
parent c94dd89361
commit a15645ad88
56 changed files with 166 additions and 278 deletions

View file

@ -4,7 +4,6 @@ use App\Models\User;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
use Livewire\Livewire;
use Livewire\Volt\Volt;
use Symfony\Component\Yaml\Yaml;
beforeEach(function (): void {
@ -19,7 +18,7 @@ it('can render catalog component', function (): void {
Livewire::withoutLazyLoading();
$component = Volt::test('catalog.index');
$component = Livewire::test('catalog.index');
$component->assertSee('No plugins available');
});
@ -59,7 +58,7 @@ it('loads plugins from catalog URL', function (): void {
Livewire::withoutLazyLoading();
$component = Volt::test('catalog.index');
$component = Livewire::test('catalog.index');
$component->assertSee('Test Plugin');
$component->assertSee('testuser');
@ -102,7 +101,7 @@ it('hides preview button when screenshot_url is missing', function (): void {
Livewire::withoutLazyLoading();
Volt::test('catalog.index')
Livewire::test('catalog.index')
->assertSee('Test Plugin Without Screenshot')
->assertDontSeeHtml('variant="subtle" icon="eye"');
});
@ -114,7 +113,7 @@ it('shows error when plugin not found', function (): void {
Livewire::withoutLazyLoading();
$component = Volt::test('catalog.index');
$component = Livewire::test('catalog.index');
$component->call('installPlugin', 'non-existent-plugin');
@ -146,7 +145,7 @@ it('shows error when zip_url is missing', function (): void {
Livewire::withoutLazyLoading();
$component = Volt::test('catalog.index');
$component = Livewire::test('catalog.index');
$component->call('installPlugin', 'test-plugin');
@ -189,7 +188,7 @@ it('can preview a plugin', function (): void {
Livewire::withoutLazyLoading();
Volt::test('catalog.index')
Livewire::test('catalog.index')
->assertSee('Test Plugin')
->call('previewPlugin', 'test-plugin')
->assertSet('previewingPlugin', 'test-plugin')

View file

@ -3,7 +3,6 @@
use App\Models\Plugin;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Volt\Volt;
use Illuminate\Support\Str;
uses(RefreshDatabase::class);
@ -28,7 +27,7 @@ test('config modal correctly loads multi_string defaults into UI boxes', functio
'configuration' => ['tags' => 'alpha,beta']
]);
Volt::test('plugins.config-modal', ['plugin' => $plugin])
Livewire::test('plugins.config-modal', ['plugin' => $plugin])
->assertSet('multiValues.tags', ['alpha', 'beta']);
});
@ -50,7 +49,7 @@ test('config modal validates against commas in multi_string boxes', function ():
]
]);
Volt::test('plugins.config-modal', ['plugin' => $plugin])
Livewire::test('plugins.config-modal', ['plugin' => $plugin])
->set('multiValues.tags.0', 'no,commas,allowed')
->call('saveConfiguration')
->assertHasErrors(['multiValues.tags.0' => 'regex']);
@ -78,7 +77,7 @@ test('config modal merges multi_string boxes into a single CSV string on save',
'configuration' => []
]);
Volt::test('plugins.config-modal', ['plugin' => $plugin])
Livewire::test('plugins.config-modal', ['plugin' => $plugin])
->set('multiValues.items.0', 'First')
->call('addMultiItem', 'items')
->set('multiValues.items.1', 'Second')
@ -100,7 +99,7 @@ test('config modal resetForm clears dirty state and increments resetIndex', func
'configuration' => ['simple_key' => 'original_value']
]);
Volt::test('plugins.config-modal', ['plugin' => $plugin])
Livewire::test('plugins.config-modal', ['plugin' => $plugin])
->set('configuration.simple_key', 'dirty_value')
->call('resetForm')
->assertSet('configuration.simple_key', 'original_value')
@ -118,7 +117,7 @@ test('config modal dispatches update event for parent warning refresh', function
'data_strategy' => 'static'
]);
Volt::test('plugins.config-modal', ['plugin' => $plugin])
Livewire::test('plugins.config-modal', ['plugin' => $plugin])
->call('saveConfiguration')
->assertDispatched('config-updated');
});

View file

@ -6,7 +6,6 @@ use App\Models\Plugin;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Str;
use Livewire\Volt\Volt;
uses(RefreshDatabase::class);
@ -21,7 +20,7 @@ test('recipe settings can save trmnlp_id', function (): void {
$trmnlpId = (string) Str::uuid();
Volt::test('plugins.recipes.settings', ['plugin' => $plugin])
Livewire::test('plugins.recipes.settings', ['plugin' => $plugin])
->set('trmnlp_id', $trmnlpId)
->call('saveTrmnlpId')
->assertHasNoErrors();
@ -43,7 +42,7 @@ test('recipe settings validates trmnlp_id is unique per user', function (): void
'trmnlp_id' => null,
]);
Volt::test('plugins.recipes.settings', ['plugin' => $newPlugin])
Livewire::test('plugins.recipes.settings', ['plugin' => $newPlugin])
->set('trmnlp_id', 'existing-id-123')
->call('saveTrmnlpId')
->assertHasErrors(['trmnlp_id' => 'unique']);
@ -67,7 +66,7 @@ test('recipe settings allows same trmnlp_id for different users', function (): v
$this->actingAs($user2);
Volt::test('plugins.recipes.settings', ['plugin' => $plugin2])
Livewire::test('plugins.recipes.settings', ['plugin' => $plugin2])
->set('trmnlp_id', 'shared-id-123')
->call('saveTrmnlpId')
->assertHasNoErrors();
@ -86,7 +85,7 @@ test('recipe settings allows same trmnlp_id for the same plugin', function (): v
'trmnlp_id' => $trmnlpId,
]);
Volt::test('plugins.recipes.settings', ['plugin' => $plugin])
Livewire::test('plugins.recipes.settings', ['plugin' => $plugin])
->set('trmnlp_id', $trmnlpId)
->call('saveTrmnlpId')
->assertHasNoErrors();
@ -103,7 +102,7 @@ test('recipe settings can clear trmnlp_id', function (): void {
'trmnlp_id' => 'some-id',
]);
Volt::test('plugins.recipes.settings', ['plugin' => $plugin])
Livewire::test('plugins.recipes.settings', ['plugin' => $plugin])
->set('trmnlp_id', '')
->call('saveTrmnlpId')
->assertHasNoErrors();