mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-03-14 12:23:33 +00:00
feat(#194): refactor cache to be device specific
This commit is contained in:
parent
c194ab5db1
commit
26b5f3ceb1
8 changed files with 278 additions and 110 deletions
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use App\Jobs\GenerateScreenJob;
|
||||
use App\Models\Device;
|
||||
use App\Models\DeviceModel;
|
||||
use App\Models\Plugin;
|
||||
use Bnussbau\TrmnlPipeline\TrmnlPipeline;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
|
@ -58,3 +60,26 @@ test('it preserves gitignore file during cleanup', function (): void {
|
|||
|
||||
Storage::disk('public')->assertExists('/images/generated/.gitignore');
|
||||
});
|
||||
|
||||
test('it saves current_image_metadata for recipe plugins', function (): void {
|
||||
$deviceModel = DeviceModel::factory()->create([
|
||||
'width' => 800,
|
||||
'height' => 480,
|
||||
'rotation' => 0,
|
||||
'mime_type' => 'image/png',
|
||||
'palette_id' => null,
|
||||
]);
|
||||
$device = Device::factory()->create(['device_model_id' => $deviceModel->id]);
|
||||
$plugin = Plugin::factory()->create(['plugin_type' => 'recipe']);
|
||||
|
||||
$job = new GenerateScreenJob($device->id, $plugin->id, '<div>Test</div>');
|
||||
$job->handle();
|
||||
|
||||
$plugin->refresh();
|
||||
expect($plugin->current_image)->not->toBeNull();
|
||||
expect($plugin->current_image_metadata)->toBeArray();
|
||||
expect($plugin->current_image_metadata)->toHaveKeys(['width', 'height', 'rotation', 'palette_id', 'mime_type']);
|
||||
expect($plugin->current_image_metadata['width'])->toBe(800);
|
||||
expect($plugin->current_image_metadata['height'])->toBe(480);
|
||||
expect($plugin->current_image_metadata['mime_type'])->toBe('image/png');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue