mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 23:18:10 +00:00
fix: update_firmware flag is only returned once to avoid upgrade loop
chore: fix code style
This commit is contained in:
parent
5367fc8a64
commit
6e5e4cd633
4 changed files with 59 additions and 1 deletions
|
|
@ -198,3 +198,48 @@ test('log endpoint requires valid device credentials', function () {
|
|||
$response->assertNotFound()
|
||||
->assertJson(['message' => 'Device not found or invalid access token']);
|
||||
});
|
||||
|
||||
test('update_firmware flag is only returned once', function () {
|
||||
$device = Device::factory()->create([
|
||||
'mac_address' => '00:11:22:33:44:55',
|
||||
'api_key' => 'test-api-key',
|
||||
'proxy_cloud_response' => [
|
||||
'update_firmware' => true,
|
||||
'firmware_url' => 'https://example.com/firmware.bin',
|
||||
],
|
||||
]);
|
||||
|
||||
// First request should return update_firmware as true
|
||||
$response = $this->withHeaders([
|
||||
'id' => $device->mac_address,
|
||||
'access-token' => $device->api_key,
|
||||
'rssi' => -70,
|
||||
'battery_voltage' => 3.8,
|
||||
'fw-version' => '1.0.0',
|
||||
])->get('/api/display');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
'update_firmware' => true,
|
||||
'firmware_url' => 'https://example.com/firmware.bin',
|
||||
]);
|
||||
|
||||
// Second request should return update_firmware as false
|
||||
$response = $this->withHeaders([
|
||||
'id' => $device->mac_address,
|
||||
'access-token' => $device->api_key,
|
||||
'rssi' => -70,
|
||||
'battery_voltage' => 3.8,
|
||||
'fw-version' => '1.0.0',
|
||||
])->get('/api/display');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
'update_firmware' => false,
|
||||
'firmware_url' => 'https://example.com/firmware.bin',
|
||||
]);
|
||||
|
||||
// Verify the proxy_cloud_response was updated
|
||||
$device->refresh();
|
||||
expect($device->proxy_cloud_response['update_firmware'])->toBeFalse();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue