mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-03-14 20:33:40 +00:00
feat: add update functionality for device palettes in UI
This commit is contained in:
parent
e71d79190a
commit
8beeff754f
2 changed files with 46 additions and 3 deletions
|
|
@ -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');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue