feat: add update functionality for device palettes in UI

This commit is contained in:
Benjamin Nussbaum 2026-02-06 23:42:14 +01:00
parent e71d79190a
commit 8beeff754f
2 changed files with 46 additions and 3 deletions

View file

@ -4,6 +4,7 @@ declare(strict_types=1);
use App\Models\DevicePalette;
use App\Models\User;
use Illuminate\Support\Facades\Http;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
@ -570,3 +571,29 @@ test('component refreshes palette list after deleting', function (): void {
expect($palettes)->toHaveCount($initialCount + 1);
expect(DevicePalette::count())->toBe($initialCount + 1);
});
test('update from API runs job and refreshes device palettes', function (): void {
$user = User::factory()->create();
$this->actingAs($user);
Http::fake([
'usetrmnl.com/api/palettes' => Http::response([
'data' => [
[
'id' => 'api-palette',
'name' => 'API Palette',
'grays' => 4,
'colors' => null,
'framework_class' => '',
],
],
], 200),
config('services.trmnl.base_url').'/api/models' => Http::response(['data' => []], 200),
]);
$component = Livewire::test('device-palettes.index')
->call('updateFromApi');
$devicePalettes = $component->get('devicePalettes');
expect($devicePalettes->pluck('name')->toArray())->toContain('api-palette');
});