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:
@@ -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();
|
||||
|
||||
83
tests/Feature/SeedDemoSwitcherTenantsTest.php
Normal file
83
tests/Feature/SeedDemoSwitcherTenantsTest.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Console\Commands\SeedDemoSwitcherTenants;
|
||||
use App\Models\Event;
|
||||
use App\Models\MediaStorageTarget;
|
||||
use App\Models\Photo;
|
||||
use Illuminate\Console\OutputStyle;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SeedDemoSwitcherTenantsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_demo_seeder_records_media_assets_on_event_disk(): void
|
||||
{
|
||||
Storage::fake('local-ssd');
|
||||
|
||||
MediaStorageTarget::create([
|
||||
'key' => 'local-ssd',
|
||||
'name' => 'Local SSD',
|
||||
'driver' => 'local',
|
||||
'config' => [],
|
||||
'is_hot' => true,
|
||||
'is_default' => true,
|
||||
'is_active' => true,
|
||||
'priority' => 10,
|
||||
]);
|
||||
|
||||
$event = Event::factory()->create();
|
||||
|
||||
$originalUrl = 'https://images.test/demo-original.jpg';
|
||||
$thumbUrl = 'https://images.test/demo-thumb.jpg';
|
||||
|
||||
Http::fake([
|
||||
$originalUrl => Http::response('demo-original', 200, ['Content-Type' => 'image/jpeg']),
|
||||
$thumbUrl => Http::response('demo-thumb', 200, ['Content-Type' => 'image/jpeg']),
|
||||
]);
|
||||
|
||||
$command = app(SeedDemoSwitcherTenants::class);
|
||||
$command->setOutput(new OutputStyle(new ArrayInput([]), new NullOutput));
|
||||
$method = new \ReflectionMethod($command, 'storePhotos');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$method->invoke($command, $event, [
|
||||
[
|
||||
'src' => [
|
||||
'large2x' => $originalUrl,
|
||||
'medium' => $thumbUrl,
|
||||
],
|
||||
],
|
||||
], 1);
|
||||
|
||||
$photo = Photo::where('event_id', $event->id)->first();
|
||||
|
||||
$this->assertNotNull($photo);
|
||||
$this->assertNotNull($photo->media_asset_id);
|
||||
$this->assertSame('approved', $photo->status);
|
||||
|
||||
Storage::disk('local-ssd')->assertExists($photo->file_path);
|
||||
Storage::disk('local-ssd')->assertExists($photo->thumbnail_path);
|
||||
|
||||
$this->assertDatabaseHas('event_media_assets', [
|
||||
'photo_id' => $photo->id,
|
||||
'variant' => 'original',
|
||||
'disk' => 'local-ssd',
|
||||
'path' => $photo->file_path,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('event_media_assets', [
|
||||
'photo_id' => $photo->id,
|
||||
'variant' => 'thumbnail',
|
||||
'disk' => 'local-ssd',
|
||||
'path' => $photo->thumbnail_path,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user