withoutMiddleware(EnsurePlatformSession::class); $this->owner = User::create([ 'public_id' => 'queue-brand-001', 'name' => 'Owner', 'email' => 'owner@example.com', 'password' => bcrypt('password'), ]); $this->organization = app(OrganizationResolver::class)->completeOnboarding($this->owner, [ 'organization_name' => 'Acme Queue Co', 'industry' => 'retail', 'appointment_mode' => 'hybrid', 'branch_name' => 'Main', 'timezone' => 'UTC', ]); } public function test_org_admin_can_upload_organization_logo(): void { Storage::fake('public'); $this->actingAs($this->owner) ->put(route('qms.settings.update'), [ 'name' => 'Acme Queue Co', 'timezone' => 'UTC', 'appointment_mode' => 'hybrid', 'industry' => 'retail', 'notifications_enabled' => '1', 'logo' => UploadedFile::fake()->image('company-logo.png', 400, 120), ]) ->assertRedirect(); $this->organization->refresh(); $this->assertNotNull($this->organization->logo_path); Storage::disk('public')->assertExists($this->organization->logo_path); } public function test_queue_notification_email_contains_company_branding_without_product_logo(): void { Storage::fake('public'); Mail::fake(); $path = UploadedFile::fake()->image('company-logo.png', 400, 120) ->store('queue/organizations/'.$this->organization->id, 'public'); $this->organization->update(['logo_path' => $path, 'name' => 'Acme Queue Co']); $branch = Branch::first(); $queue = ServiceQueue::create([ 'owner_ref' => $this->owner->public_id, 'organization_id' => $this->organization->id, 'branch_id' => $branch->id, 'name' => 'Reception', 'prefix' => 'A', 'strategy' => 'fifo', 'is_active' => true, 'settings' => ['notifications_enabled' => true], ]); $ticket = Ticket::create([ 'owner_ref' => $this->owner->public_id, 'organization_id' => $this->organization->id, 'branch_id' => $branch->id, 'service_queue_id' => $queue->id, 'ticket_number' => 'A001', 'status' => 'waiting', 'customer_email' => 'customer@example.com', 'issued_at' => now(), ]); app(QueueNotificationService::class)->ticketIssued($ticket); $logoUrl = OrganizationBranding::emailLogoUrl($this->organization->fresh()); Mail::assertSent(ContactMessageMail::class, function (ContactMessageMail $mail) use ($logoUrl) { $html = $mail->render(); return $mail->companyName === 'Acme Queue Co' && $mail->logoUrl === $logoUrl && str_contains($html, 'Acme Queue Co') && str_contains($html, $logoUrl) && ! str_contains($html, 'ladillqueue-logo') && ! str_contains($html, 'Sent via Ladill'); }); } public function test_queue_notification_email_shows_company_name_when_no_logo(): void { Mail::fake(); $this->organization->update(['name' => 'Plain Name Org', 'logo_path' => null]); $branch = Branch::first(); $queue = ServiceQueue::create([ 'owner_ref' => $this->owner->public_id, 'organization_id' => $this->organization->id, 'branch_id' => $branch->id, 'name' => 'Reception', 'prefix' => 'B', 'strategy' => 'fifo', 'is_active' => true, 'settings' => ['notifications_enabled' => true], ]); $ticket = Ticket::create([ 'owner_ref' => $this->owner->public_id, 'organization_id' => $this->organization->id, 'branch_id' => $branch->id, 'service_queue_id' => $queue->id, 'ticket_number' => 'B001', 'status' => 'waiting', 'customer_email' => 'customer@example.com', 'issued_at' => now(), ]); app(QueueNotificationService::class)->ticketIssued($ticket); Mail::assertSent(ContactMessageMail::class, function (ContactMessageMail $mail) { $html = $mail->render(); return $mail->companyName === 'Plain Name Org' && $mail->logoUrl === null && str_contains($html, 'Plain Name Org') && ! str_contains($html, 'ladillqueue-logo') && ! str_contains($html, 'Sent via Ladill'); }); } }