chore: update trmnl base url

This commit is contained in:
Benjamin Nussbaum 2026-01-28 12:10:29 +01:00
parent 31ca919ba9
commit 1e43aded77
16 changed files with 109 additions and 73 deletions

View file

@ -29,7 +29,7 @@ test('fetch device models job can be dispatched', function (): void {
test('fetch device models job handles successful api response', function (): void {
Http::fake([
'usetrmnl.com/api/palettes' => Http::response(['data' => []], 200),
'usetrmnl.com/api/models' => Http::response([
config('services.trmnl.base_url').'/api/models' => Http::response([
'data' => [
[
'name' => 'test-model',
@ -82,7 +82,7 @@ test('fetch device models job handles successful api response', function (): voi
test('fetch device models job handles multiple device models', function (): void {
Http::fake([
'usetrmnl.com/api/palettes' => Http::response(['data' => []], 200),
'usetrmnl.com/api/models' => Http::response([
config('services.trmnl.base_url').'/api/models' => Http::response([
'data' => [
[
'name' => 'model-1',
@ -136,7 +136,7 @@ test('fetch device models job handles multiple device models', function (): void
test('fetch device models job handles empty data array', function (): void {
Http::fake([
'usetrmnl.com/api/palettes' => Http::response(['data' => []], 200),
'usetrmnl.com/api/models' => Http::response([
config('services.trmnl.base_url').'/api/models' => Http::response([
'data' => [],
], 200),
]);
@ -158,7 +158,7 @@ test('fetch device models job handles empty data array', function (): void {
test('fetch device models job handles missing data field', function (): void {
Http::fake([
'usetrmnl.com/api/palettes' => Http::response(['data' => []], 200),
'usetrmnl.com/api/models' => Http::response([
config('services.trmnl.base_url').'/api/models' => Http::response([
'message' => 'No data available',
], 200),
]);
@ -180,7 +180,7 @@ test('fetch device models job handles missing data field', function (): void {
test('fetch device models job handles non-array data', function (): void {
Http::fake([
'usetrmnl.com/api/palettes' => Http::response(['data' => []], 200),
'usetrmnl.com/api/models' => Http::response([
config('services.trmnl.base_url').'/api/models' => Http::response([
'data' => 'invalid-data',
], 200),
]);
@ -202,7 +202,7 @@ test('fetch device models job handles non-array data', function (): void {
test('fetch device models job handles api failure', function (): void {
Http::fake([
'usetrmnl.com/api/palettes' => Http::response(['data' => []], 200),
'usetrmnl.com/api/models' => Http::response([
config('services.trmnl.base_url').'/api/models' => Http::response([
'error' => 'Internal Server Error',
], 500),
]);
@ -227,7 +227,7 @@ test('fetch device models job handles api failure', function (): void {
test('fetch device models job handles network exception', function (): void {
Http::fake([
'usetrmnl.com/api/palettes' => Http::response(['data' => []], 200),
'usetrmnl.com/api/models' => function (): void {
config('services.trmnl.base_url').'/api/models' => function (): void {
throw new Exception('Network connection failed');
},
]);
@ -249,7 +249,7 @@ test('fetch device models job handles network exception', function (): void {
test('fetch device models job handles device model with missing name', function (): void {
Http::fake([
'usetrmnl.com/api/palettes' => Http::response(['data' => []], 200),
'usetrmnl.com/api/models' => Http::response([
config('services.trmnl.base_url').'/api/models' => Http::response([
'data' => [
[
'label' => 'Model without name',
@ -280,7 +280,7 @@ test('fetch device models job handles device model with missing name', function
test('fetch device models job handles device model with partial data', function (): void {
Http::fake([
'usetrmnl.com/api/palettes' => Http::response(['data' => []], 200),
'usetrmnl.com/api/models' => Http::response([
config('services.trmnl.base_url').'/api/models' => Http::response([
'data' => [
[
'name' => 'minimal-model',
@ -329,7 +329,7 @@ test('fetch device models job updates existing device model', function (): void
Http::fake([
'usetrmnl.com/api/palettes' => Http::response(['data' => []], 200),
'usetrmnl.com/api/models' => Http::response([
config('services.trmnl.base_url').'/api/models' => Http::response([
'data' => [
[
'name' => 'existing-model',
@ -372,7 +372,7 @@ test('fetch device models job updates existing device model', function (): void
test('fetch device models job handles processing exception for individual model', function (): void {
Http::fake([
'usetrmnl.com/api/palettes' => Http::response(['data' => []], 200),
'usetrmnl.com/api/models' => Http::response([
config('services.trmnl.base_url').'/api/models' => Http::response([
'data' => [
[
'name' => 'valid-model',

View file

@ -10,8 +10,10 @@ beforeEach(function (): void {
});
test('it creates new firmware record when polling', function (): void {
$baseUrl = config('services.trmnl.base_url');
Http::fake([
'https://usetrmnl.com/api/firmware/latest' => Http::response([
$baseUrl.'/api/firmware/latest' => Http::response([
'version' => '1.0.0',
'url' => 'https://example.com/firmware.bin',
], 200),
@ -32,8 +34,10 @@ test('it updates existing firmware record when polling', function (): void {
'latest' => true,
]);
$baseUrl = config('services.trmnl.base_url');
Http::fake([
'https://usetrmnl.com/api/firmware/latest' => Http::response([
$baseUrl.'/api/firmware/latest' => Http::response([
'version' => '1.0.0',
'url' => 'https://new-url.com/firmware.bin',
], 200),
@ -52,8 +56,10 @@ test('it marks previous firmware as not latest when new version is found', funct
'latest' => true,
]);
$baseUrl = config('services.trmnl.base_url');
Http::fake([
'https://usetrmnl.com/api/firmware/latest' => Http::response([
$baseUrl.'/api/firmware/latest' => Http::response([
'version' => '1.1.0',
'url' => 'https://example.com/firmware.bin',
], 200),
@ -66,8 +72,10 @@ test('it marks previous firmware as not latest when new version is found', funct
});
test('it handles connection exception gracefully', function (): void {
$baseUrl = config('services.trmnl.base_url');
Http::fake([
'https://usetrmnl.com/api/firmware/latest' => function (): void {
$baseUrl.'/api/firmware/latest' => function (): void {
throw new ConnectionException('Connection failed');
},
]);
@ -79,8 +87,10 @@ test('it handles connection exception gracefully', function (): void {
});
test('it handles invalid response gracefully', function (): void {
$baseUrl = config('services.trmnl.base_url');
Http::fake([
'https://usetrmnl.com/api/firmware/latest' => Http::response(null, 200),
$baseUrl.'/api/firmware/latest' => Http::response(null, 200),
]);
(new FirmwarePollJob)->handle();
@ -90,8 +100,10 @@ test('it handles invalid response gracefully', function (): void {
});
test('it handles missing version in response gracefully', function (): void {
$baseUrl = config('services.trmnl.base_url');
Http::fake([
'https://usetrmnl.com/api/firmware/latest' => Http::response([
$baseUrl.'/api/firmware/latest' => Http::response([
'url' => 'https://example.com/firmware.bin',
], 200),
]);
@ -103,8 +115,10 @@ test('it handles missing version in response gracefully', function (): void {
});
test('it handles missing url in response gracefully', function (): void {
$baseUrl = config('services.trmnl.base_url');
Http::fake([
'https://usetrmnl.com/api/firmware/latest' => Http::response([
$baseUrl.'/api/firmware/latest' => Http::response([
'version' => '1.0.0',
], 200),
]);