test: use faker for GenerateDefaultImagesTest, TransformDefaultImagesTest
Some checks are pending
tests / ci (push) Waiting to run

This commit is contained in:
Benjamin Nussbaum 2025-10-01 22:20:21 +02:00
parent 50318b8b9d
commit e812f56c11
2 changed files with 39 additions and 17 deletions

View file

@ -3,8 +3,20 @@
use App\Models\Device;
use App\Models\DeviceModel;
use App\Services\ImageGenerationService;
use Bnussbau\TrmnlPipeline\TrmnlPipeline;
use Illuminate\Support\Facades\Storage;
beforeEach(function (): void {
TrmnlPipeline::fake();
Storage::fake('public');
Storage::disk('public')->makeDirectory('/images/default-screens');
Storage::disk('public')->makeDirectory('/images/generated');
// Create fallback image files that the service expects
Storage::disk('public')->put('/images/setup-logo.bmp', 'fake-bmp-content');
Storage::disk('public')->put('/images/sleep.bmp', 'fake-bmp-content');
});
test('command transforms default images for all device models', function () {
// Ensure we have device models
$deviceModels = DeviceModel::all();
@ -30,20 +42,6 @@ test('command transforms default images for all device models', function () {
}
});
test('getDeviceSpecificDefaultImage returns correct path for device with model', function () {
$deviceModel = DeviceModel::first();
expect($deviceModel)->not->toBeNull();
$device = new Device();
$device->deviceModel = $deviceModel;
$setupImage = ImageGenerationService::getDeviceSpecificDefaultImage($device, 'setup-logo');
$sleepImage = ImageGenerationService::getDeviceSpecificDefaultImage($device, 'sleep');
expect($setupImage)->toContain('images/default-screens/setup-logo_');
expect($sleepImage)->toContain('images/default-screens/sleep_');
});
test('getDeviceSpecificDefaultImage falls back to original images for device without model', function () {
$device = new Device();
$device->deviceModel = null;