Adjust watermark permissions and transparency
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Models\EventType;
|
||||
use App\Models\Package;
|
||||
use App\Models\PackagePurchase;
|
||||
use App\Models\TenantPackage;
|
||||
use App\Models\WatermarkSetting;
|
||||
use App\Services\EventJoinTokenService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -369,7 +370,14 @@ class EventControllerTest extends TenantTestCase
|
||||
{
|
||||
Storage::fake('public');
|
||||
|
||||
config(['watermark.base.asset' => 'branding/watermarks/base-watermark.png']);
|
||||
$setting = WatermarkSetting::query()->create([
|
||||
'asset' => 'branding/watermarks/base-watermark.png',
|
||||
'position' => 'bottom-right',
|
||||
'opacity' => 0.25,
|
||||
'scale' => 0.2,
|
||||
'padding' => 16,
|
||||
]);
|
||||
|
||||
Storage::disk('public')->put('branding/watermarks/base-watermark.png', 'asset');
|
||||
|
||||
$eventType = EventType::factory()->create();
|
||||
@@ -389,6 +397,83 @@ class EventControllerTest extends TenantTestCase
|
||||
$this->assertNotSame('', $url);
|
||||
$this->assertStringContainsString('/api/v1/branding/asset/branding/watermarks/base-watermark.png', $url);
|
||||
$this->assertStringContainsString('signature=', $url);
|
||||
$this->assertSame($setting->asset, $response->json('data.settings.watermark.asset'));
|
||||
}
|
||||
|
||||
public function test_update_event_allows_disabling_watermark_when_removal_is_enabled(): void
|
||||
{
|
||||
$package = Package::factory()->create([
|
||||
'watermark_allowed' => true,
|
||||
'branding_allowed' => true,
|
||||
'features' => ['no_watermark'],
|
||||
]);
|
||||
|
||||
$eventType = EventType::factory()->create();
|
||||
$event = Event::factory()->for($this->tenant)->create([
|
||||
'event_type_id' => $eventType->id,
|
||||
'name' => 'Removal Allowed Event',
|
||||
'slug' => 'removal-allowed',
|
||||
'date' => now()->addDays(2),
|
||||
]);
|
||||
|
||||
EventPackage::create([
|
||||
'event_id' => $event->id,
|
||||
'package_id' => $package->id,
|
||||
'purchased_price' => $package->price ?? 0,
|
||||
'used_photos' => 0,
|
||||
]);
|
||||
|
||||
$response = $this->authenticatedRequest('PUT', "/api/v1/tenant/events/{$event->slug}", [
|
||||
'settings' => [
|
||||
'watermark' => [
|
||||
'mode' => 'off',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
$event->refresh();
|
||||
$this->assertSame('off', data_get($event->settings, 'watermark.mode'));
|
||||
$this->assertTrue((bool) data_get($event->settings, 'watermark_removal_allowed'));
|
||||
}
|
||||
|
||||
public function test_update_event_forces_base_watermark_when_removal_is_disabled(): void
|
||||
{
|
||||
$package = Package::factory()->create([
|
||||
'watermark_allowed' => true,
|
||||
'branding_allowed' => true,
|
||||
'features' => [],
|
||||
]);
|
||||
|
||||
$eventType = EventType::factory()->create();
|
||||
$event = Event::factory()->for($this->tenant)->create([
|
||||
'event_type_id' => $eventType->id,
|
||||
'name' => 'Removal Disabled Event',
|
||||
'slug' => 'removal-disabled',
|
||||
'date' => now()->addDays(2),
|
||||
]);
|
||||
|
||||
EventPackage::create([
|
||||
'event_id' => $event->id,
|
||||
'package_id' => $package->id,
|
||||
'purchased_price' => $package->price ?? 0,
|
||||
'used_photos' => 0,
|
||||
]);
|
||||
|
||||
$response = $this->authenticatedRequest('PUT', "/api/v1/tenant/events/{$event->slug}", [
|
||||
'settings' => [
|
||||
'watermark' => [
|
||||
'mode' => 'off',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
$event->refresh();
|
||||
$this->assertSame('base', data_get($event->settings, 'watermark.mode'));
|
||||
$this->assertFalse((bool) data_get($event->settings, 'watermark_removal_allowed'));
|
||||
}
|
||||
|
||||
public function test_update_event_uploads_branding_logo_data_url(): void
|
||||
|
||||
Reference in New Issue
Block a user