photo visibility for demo events, hardened the demo mode. fixed dark/light mode toggle and notification bell toggle. fixed photo upload page sizes & header visibility.

This commit is contained in:
Codex Agent
2025-12-18 21:14:24 +01:00
parent 7c4067b32b
commit 53ec427e6e
25 changed files with 965 additions and 102 deletions

View File

@@ -3,6 +3,9 @@
namespace Tests\Feature;
use App\Models\Event;
use App\Models\EventPackage;
use App\Models\MediaStorageTarget;
use App\Models\Package;
use App\Models\Photo;
use App\Services\EventJoinTokenService;
use Illuminate\Foundation\Testing\RefreshDatabase;
@@ -62,11 +65,32 @@ class GuestJoinTokenFlowTest extends TestCase
Storage::fake('public');
$event = $this->createPublishedEvent();
$package = Package::factory()->endcustomer()->create([
'max_photos' => 100,
]);
EventPackage::create([
'event_id' => $event->id,
'package_id' => $package->id,
'purchased_price' => $package->price,
'purchased_at' => now(),
'used_photos' => 0,
'used_guests' => 0,
]);
MediaStorageTarget::create([
'key' => 'public',
'name' => 'Public',
'driver' => 'local',
'is_hot' => true,
'is_default' => true,
'is_active' => true,
]);
$token = $this->tokenService->createToken($event);
Mockery::mock('alias:App\Support\ImageHelper')
->shouldReceive('makeThumbnailOnDisk')
->andReturn("events/{$event->id}/photos/thumbs/generated_thumb.jpg");
->andReturn("events/{$event->id}/photos/thumbs/generated_thumb.jpg")
->shouldReceive('copyWithWatermark')
->andReturnNull();
$file = UploadedFile::fake()->image('example.jpg', 1200, 800);
@@ -76,7 +100,7 @@ class GuestJoinTokenFlowTest extends TestCase
]);
$response->assertCreated()
->assertJsonStructure(['id', 'file_path', 'thumbnail_path']);
->assertJsonStructure(['id', 'status', 'message']);
$this->assertDatabaseCount('photos', 1);
@@ -96,6 +120,41 @@ class GuestJoinTokenFlowTest extends TestCase
}
}
public function test_guest_event_response_includes_demo_read_only_flag(): void
{
$event = $this->createPublishedEvent();
$token = $this->tokenService->createToken($event, [
'metadata' => ['demo_read_only' => true],
]);
$response = $this->getJson("/api/v1/events/{$token->token}");
$response->assertOk()
->assertJsonPath('demo_read_only', true);
}
public function test_guest_cannot_upload_photo_with_demo_token(): void
{
Storage::fake('public');
$event = $this->createPublishedEvent();
$token = $this->tokenService->createToken($event, [
'metadata' => ['demo_read_only' => true],
]);
$file = UploadedFile::fake()->image('example.jpg', 1200, 800);
$response = $this->withHeader('X-Device-Id', 'token-device')
->postJson("/api/v1/events/{$token->token}/upload", [
'photo' => $file,
]);
$response->assertStatus(403)
->assertJsonPath('error.code', 'demo_read_only');
$this->assertDatabaseCount('photos', 0);
}
public function test_guest_can_like_photo_after_joining_with_token(): void
{
$event = $this->createPublishedEvent();