mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
* according to https://docs.usetrmnl.com/go/diy/byos#screens
This commit is contained in:
parent
4b88726c96
commit
eacb891cba
2 changed files with 68 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Jobs\GenerateScreenJob;
|
||||
use App\Models\Device;
|
||||
use App\Models\Playlist;
|
||||
use App\Models\PlaylistItem;
|
||||
|
|
@ -838,3 +839,42 @@ test('device returns sleep.png and correct refresh time when paused', function (
|
|||
expect($json['image_url'])->toContain('sleep.png');
|
||||
expect($json['refresh_rate'])->toBeLessThanOrEqual(3600); // ~60 min
|
||||
});
|
||||
|
||||
test('screens endpoint accepts nullable file_name', function () {
|
||||
Queue::fake();
|
||||
|
||||
$device = Device::factory()->create([
|
||||
'mac_address' => '00:11:22:33:44:55',
|
||||
'api_key' => 'test-api-key',
|
||||
]);
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'id' => $device->mac_address,
|
||||
'access-token' => $device->api_key,
|
||||
])->post('/api/screens', [
|
||||
'image' => [
|
||||
'content' => '<div>Test content</div>',
|
||||
],
|
||||
]);
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
Queue::assertPushed(GenerateScreenJob::class);
|
||||
});
|
||||
|
||||
test('screens endpoint returns 404 for invalid device credentials', function () {
|
||||
$response = $this->withHeaders([
|
||||
'id' => 'invalid-mac',
|
||||
'access-token' => 'invalid-key',
|
||||
])->post('/api/screens', [
|
||||
'image' => [
|
||||
'content' => '<div>Test content</div>',
|
||||
'file_name' => 'test.blade.php',
|
||||
],
|
||||
]);
|
||||
|
||||
$response->assertNotFound()
|
||||
->assertJson([
|
||||
'message' => 'MAC Address not registered or invalid access token',
|
||||
]);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue