mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
fix(#76): rotate back preview image
Some checks are pending
tests / ci (push) Waiting to run
Some checks are pending
tests / ci (push) Waiting to run
This commit is contained in:
parent
0503be65c2
commit
a88e72b75e
4 changed files with 96 additions and 2 deletions
|
|
@ -95,7 +95,11 @@ new class extends Component {
|
||||||
</flux:callout>
|
</flux:callout>
|
||||||
@elseif($current_image_path)
|
@elseif($current_image_path)
|
||||||
<flux:separator class="mt-2 mb-4"/>
|
<flux:separator class="mt-2 mb-4"/>
|
||||||
<img src="{{ asset($current_image_path) }}" class="max-h-[480px]" alt="Current Image"/>
|
<div class="flex justify-center">
|
||||||
|
<div class="relative origin-center -rotate-[{{ $device->rotate ?? 0 }}deg]">
|
||||||
|
<img src="{{ asset($current_image_path) }}" class="max-h-[480px]" alt="Current Image"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,11 @@ new class extends Component {
|
||||||
@if(!$device->mirror_device_id)
|
@if(!$device->mirror_device_id)
|
||||||
@if($current_image_path)
|
@if($current_image_path)
|
||||||
<flux:separator class="mt-6 mb-6" text="Screen"/>
|
<flux:separator class="mt-6 mb-6" text="Screen"/>
|
||||||
<img src="{{ asset($current_image_path) }}" class="max-h-[480px]" alt="Next Image"/>
|
<div class="flex justify-center">
|
||||||
|
<div class="relative origin-center -rotate-[{{ $device->rotate ?? 0 }}deg]">
|
||||||
|
<img src="{{ asset($current_image_path) }}" class="max-h-[480px]" alt="Next Image"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<flux:separator class="mt-6 mb-6" text="Playlists"/>
|
<flux:separator class="mt-6 mb-6" text="Playlists"/>
|
||||||
|
|
|
||||||
86
tests/Feature/Devices/DeviceRotationTest.php
Normal file
86
tests/Feature/Devices/DeviceRotationTest.php
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use App\Models\{Device, User};
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
test('dashboard shows device image with correct rotation', function () {
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$device = Device::factory()->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'rotate' => 90,
|
||||||
|
'current_screen_image' => 'test-image-uuid',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Mock the file existence check
|
||||||
|
\Illuminate\Support\Facades\Storage::fake('public');
|
||||||
|
\Illuminate\Support\Facades\Storage::disk('public')->put('images/generated/test-image-uuid.png', 'fake-image-content');
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)
|
||||||
|
->get(route('dashboard'));
|
||||||
|
|
||||||
|
$response->assertSuccessful();
|
||||||
|
$response->assertSee('-rotate-[90deg]');
|
||||||
|
$response->assertSee('origin-center');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('device configure page shows device image with correct rotation', function () {
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$device = Device::factory()->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'rotate' => 90,
|
||||||
|
'current_screen_image' => 'test-image-uuid',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Mock the file existence check
|
||||||
|
\Illuminate\Support\Facades\Storage::fake('public');
|
||||||
|
\Illuminate\Support\Facades\Storage::disk('public')->put('images/generated/test-image-uuid.png', 'fake-image-content');
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)
|
||||||
|
->get(route('devices.configure', $device));
|
||||||
|
|
||||||
|
$response->assertSuccessful();
|
||||||
|
$response->assertSee('-rotate-[90deg]');
|
||||||
|
$response->assertSee('origin-center');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('device with no rotation shows no transform style', function () {
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$device = Device::factory()->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'rotate' => 0,
|
||||||
|
'current_screen_image' => 'test-image-uuid',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Mock the file existence check
|
||||||
|
\Illuminate\Support\Facades\Storage::fake('public');
|
||||||
|
\Illuminate\Support\Facades\Storage::disk('public')->put('images/generated/test-image-uuid.png', 'fake-image-content');
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)
|
||||||
|
->get(route('dashboard'));
|
||||||
|
|
||||||
|
$response->assertSuccessful();
|
||||||
|
$response->assertSee('-rotate-[0deg]');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('device with null rotation defaults to 0', function () {
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$device = Device::factory()->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'rotate' => null,
|
||||||
|
'current_screen_image' => 'test-image-uuid',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Mock the file existence check
|
||||||
|
\Illuminate\Support\Facades\Storage::fake('public');
|
||||||
|
\Illuminate\Support\Facades\Storage::disk('public')->put('images/generated/test-image-uuid.png', 'fake-image-content');
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)
|
||||||
|
->get(route('dashboard'));
|
||||||
|
|
||||||
|
$response->assertSuccessful();
|
||||||
|
$response->assertSee('-rotate-[0deg]');
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue