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

@ -17,8 +17,10 @@ test('firmware check command has correct signature', function (): void {
test('firmware check command runs without errors', function (): void {
// Mock the firmware API response
$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),
@ -33,8 +35,10 @@ test('firmware check command runs without errors', function (): void {
test('firmware check command runs with download flag', function (): void {
// Mock the firmware API response
$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),
@ -57,8 +61,10 @@ test('firmware check command runs with download flag', function (): void {
test('firmware check command can run successfully', function (): void {
// Mock the firmware API response
$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),

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),
]);

View file

@ -8,7 +8,7 @@ use Livewire\Livewire;
it('loads newest TRMNL recipes on mount', function (): void {
Http::fake([
'usetrmnl.com/recipes.json*' => Http::response([
config('services.trmnl.base_url').'/recipes.json*' => Http::response([
'data' => [
[
'id' => 123,
@ -33,7 +33,7 @@ it('loads newest TRMNL recipes on mount', function (): void {
it('shows preview button when screenshot_url is provided', function (): void {
Http::fake([
'usetrmnl.com/recipes.json*' => Http::response([
config('services.trmnl.base_url').'/recipes.json*' => Http::response([
'data' => [
[
'id' => 123,
@ -57,7 +57,7 @@ it('shows preview button when screenshot_url is provided', function (): void {
it('searches TRMNL recipes when search term is provided', function (): void {
Http::fake([
// First call (mount -> newest)
'usetrmnl.com/recipes.json?*' => Http::sequence()
config('services.trmnl.base_url').'/recipes.json?*' => Http::sequence()
->push([
'data' => [
[
@ -98,7 +98,7 @@ it('installs plugin successfully when user is authenticated', function (): void
$user = User::factory()->create();
Http::fake([
'usetrmnl.com/recipes.json*' => Http::response([
config('services.trmnl.base_url').'/recipes.json*' => Http::response([
'data' => [
[
'id' => 123,
@ -110,7 +110,7 @@ it('installs plugin successfully when user is authenticated', function (): void
],
],
], 200),
'usetrmnl.com/api/plugin_settings/123/archive*' => Http::response('fake zip content', 200),
config('services.trmnl.base_url').'/api/plugin_settings/123/archive*' => Http::response('fake zip content', 200),
]);
$this->actingAs($user);
@ -125,7 +125,7 @@ it('installs plugin successfully when user is authenticated', function (): void
it('shows error when user is not authenticated', function (): void {
Http::fake([
'usetrmnl.com/recipes.json*' => Http::response([
config('services.trmnl.base_url').'/recipes.json*' => Http::response([
'data' => [
[
'id' => 123,
@ -151,7 +151,7 @@ it('shows error when plugin installation fails', function (): void {
$user = User::factory()->create();
Http::fake([
'usetrmnl.com/recipes.json*' => Http::response([
config('services.trmnl.base_url').'/recipes.json*' => Http::response([
'data' => [
[
'id' => 123,
@ -163,7 +163,7 @@ it('shows error when plugin installation fails', function (): void {
],
],
], 200),
'usetrmnl.com/api/plugin_settings/123/archive*' => Http::response('invalid zip content', 200),
config('services.trmnl.base_url').'/api/plugin_settings/123/archive*' => Http::response('invalid zip content', 200),
]);
$this->actingAs($user);
@ -178,7 +178,7 @@ it('shows error when plugin installation fails', function (): void {
it('previews a recipe with async fetch', function (): void {
Http::fake([
'usetrmnl.com/recipes.json*' => Http::response([
config('services.trmnl.base_url').'/recipes.json*' => Http::response([
'data' => [
[
'id' => 123,
@ -190,7 +190,7 @@ it('previews a recipe with async fetch', function (): void {
],
],
], 200),
'usetrmnl.com/recipes/123.json' => Http::response([
config('services.trmnl.base_url').'/recipes/123.json' => Http::response([
'data' => [
'id' => 123,
'name' => 'Weather Chum Updated',
@ -216,7 +216,7 @@ it('previews a recipe with async fetch', function (): void {
it('supports pagination and loading more recipes', function (): void {
Http::fake([
'usetrmnl.com/recipes.json?sort-by=newest&page=1' => Http::response([
config('services.trmnl.base_url').'/recipes.json?sort-by=newest&page=1' => Http::response([
'data' => [
[
'id' => 1,
@ -229,7 +229,7 @@ it('supports pagination and loading more recipes', function (): void {
],
'next_page_url' => '/recipes.json?page=2',
], 200),
'usetrmnl.com/recipes.json?sort-by=newest&page=2' => Http::response([
config('services.trmnl.base_url').'/recipes.json?sort-by=newest&page=2' => Http::response([
'data' => [
[
'id' => 2,
@ -258,7 +258,7 @@ it('supports pagination and loading more recipes', function (): void {
it('resets pagination when search term changes', function (): void {
Http::fake([
'usetrmnl.com/recipes.json?sort-by=newest&page=1' => Http::sequence()
config('services.trmnl.base_url').'/recipes.json?sort-by=newest&page=1' => Http::sequence()
->push([
'data' => [['id' => 1, 'name' => 'Initial 1']],
'next_page_url' => '/recipes.json?page=2',
@ -267,7 +267,7 @@ it('resets pagination when search term changes', function (): void {
'data' => [['id' => 3, 'name' => 'Initial 1 Again']],
'next_page_url' => null,
]),
'usetrmnl.com/recipes.json?search=weather&sort-by=newest&page=1' => Http::response([
config('services.trmnl.base_url').'/recipes.json?search=weather&sort-by=newest&page=1' => Http::response([
'data' => [['id' => 2, 'name' => 'Weather Result']],
'next_page_url' => null,
]),

View file

@ -227,7 +227,7 @@ test('hasMissingRequiredConfigurationFields returns true when required xhrSelect
'field_type' => 'xhrSelect',
'name' => 'Baseball Team',
'description' => 'Select your team',
'endpoint' => 'https://usetrmnl.com/custom_plugin_example_xhr_select.json',
'endpoint' => config('services.trmnl.base_url').'/custom_plugin_example_xhr_select.json',
// Not marked as optional, so it's required
],
],
@ -252,7 +252,7 @@ test('hasMissingRequiredConfigurationFields returns false when required xhrSelec
'field_type' => 'xhrSelect',
'name' => 'Baseball Team',
'description' => 'Select your team',
'endpoint' => 'https://usetrmnl.com/custom_plugin_example_xhr_select.json',
'endpoint' => config('services.trmnl.base_url').'/custom_plugin_example_xhr_select.json',
// Not marked as optional, so it's required
],
],