all system emails look fresh now, plus added paddle portal debugging

This commit is contained in:
Codex Agent
2025-12-23 14:31:42 +01:00
parent 207725d460
commit 1d2c2da915
11 changed files with 394 additions and 12 deletions

View File

@@ -0,0 +1,103 @@
<?php
namespace Tests\Feature;
use App\Mail\ContactRequest;
use App\Models\PackagePurchase;
use App\Models\Tenant;
use App\Models\User;
use App\Notifications\Customer\RefundReceipt;
use App\Notifications\InactiveTenantDeletionWarning;
use App\Notifications\Ops\PurchaseCreated;
use App\Notifications\ResetPasswordNotification;
use App\Notifications\UploadPipelineFailed;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Mail;
use Tests\TestCase;
class BrandedMailableEmailsTest extends TestCase
{
use RefreshDatabase;
public function test_upload_pipeline_failed_uses_branded_view(): void
{
$notification = new UploadPipelineFailed([
'job' => 'UploadJob',
'queue' => 'uploads',
'event_id' => 123,
'photo_id' => 456,
'exception' => 'ExampleException',
]);
$mailMessage = $notification->toMail((object) []);
$this->assertInstanceOf(MailMessage::class, $mailMessage);
$this->assertSame('emails.notifications.basic', $mailMessage->view);
$this->assertArrayHasKey('lines', $mailMessage->viewData);
}
public function test_inactive_tenant_deletion_warning_uses_branded_view(): void
{
$tenant = Tenant::factory()->create([
'name' => 'Demo Tenant',
]);
$notification = new InactiveTenantDeletionWarning($tenant, Carbon::now()->addDays(10));
$mailMessage = $notification->toMail((object) []);
$this->assertInstanceOf(MailMessage::class, $mailMessage);
$this->assertSame('emails.notifications.basic', $mailMessage->view);
$this->assertArrayHasKey('cta', $mailMessage->viewData);
}
public function test_refund_receipt_uses_branded_view(): void
{
$purchase = PackagePurchase::factory()->create();
$notification = new RefundReceipt($purchase);
$mailMessage = $notification->toMail((object) []);
$this->assertInstanceOf(MailMessage::class, $mailMessage);
$this->assertSame('emails.notifications.basic', $mailMessage->view);
$this->assertArrayHasKey('footer', $mailMessage->viewData);
}
public function test_ops_purchase_created_uses_branded_view(): void
{
$purchase = PackagePurchase::factory()->create();
$notification = new PurchaseCreated($purchase);
$mailMessage = $notification->toMail((object) []);
$this->assertInstanceOf(MailMessage::class, $mailMessage);
$this->assertSame('emails.notifications.basic', $mailMessage->view);
}
public function test_reset_password_notification_uses_branded_view(): void
{
$user = User::factory()->create();
$notification = new ResetPasswordNotification('token-123');
$mailMessage = $notification->toMail($user);
$this->assertInstanceOf(MailMessage::class, $mailMessage);
$this->assertSame('emails.reset-password', $mailMessage->view);
$this->assertArrayHasKey('resetUrl', $mailMessage->viewData);
}
public function test_contact_request_email_uses_branded_layout(): void
{
Mail::fake();
$mail = new ContactRequest(
name: 'Alex',
email: 'alex@example.test',
messageBody: 'Hello from the contact form.',
);
Mail::to('support@example.test')->send($mail);
Mail::assertSent(ContactRequest::class, function (ContactRequest $sent) {
return $sent->content()->view === 'emails.contact-request';
});
}
}