feat(notification): implement branding for emails using WebsiteType and update templates
This commit is contained in:
@@ -71,6 +71,8 @@ class NotificationMailServiceTest extends TestCase
|
||||
|
||||
public function test_it_sends_a_branded_welcome_email(): void
|
||||
{
|
||||
$this->useWebsiteTypeBranding();
|
||||
|
||||
app(NotificationMailService::class)->sendWelcome($this->user->id, $this->tenant->codigo);
|
||||
|
||||
Mail::assertSent(Mailable::class, function (Mailable $mail): bool {
|
||||
@@ -78,12 +80,15 @@ class NotificationMailServiceTest extends TestCase
|
||||
$mail->assertHasSubject('Bienvenido a Mail Tenant');
|
||||
|
||||
return str_contains($mail->render(), 'Ada Lovelace')
|
||||
&& str_contains($mail->render(), 'Mail Tenant');
|
||||
&& str_contains($mail->render(), 'Mail Tenant')
|
||||
&& str_contains($mail->render(), 'OnTicket')
|
||||
&& str_contains($mail->render(), 'border-top: 4px solid #ff7006');
|
||||
});
|
||||
}
|
||||
|
||||
public function test_it_sends_a_branded_password_reset_email(): void
|
||||
{
|
||||
$this->useWebsiteTypeBranding();
|
||||
$attempt = $this->user->resetPasswordAttempts()->create([
|
||||
'codigo' => '0123',
|
||||
]);
|
||||
@@ -101,7 +106,8 @@ class NotificationMailServiceTest extends TestCase
|
||||
return str_contains($rendered, '0123')
|
||||
&& str_contains($rendered, 'Ada Lovelace')
|
||||
&& str_contains($rendered, 'Mail Tenant')
|
||||
&& str_contains($rendered, '#112233');
|
||||
&& str_contains($rendered, '#ff7006')
|
||||
&& ! str_contains($rendered, 'border: 2px solid #112233');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -137,6 +143,7 @@ class NotificationMailServiceTest extends TestCase
|
||||
|
||||
public function test_it_sends_purchase_and_ticket_emails_to_the_purchase_recipient(): void
|
||||
{
|
||||
$this->useWebsiteTypeBranding();
|
||||
$purchase = Purchase::query()->create([
|
||||
'tenant_codigo' => $this->tenant->codigo,
|
||||
'user_id' => $this->user->id,
|
||||
@@ -180,13 +187,34 @@ class NotificationMailServiceTest extends TestCase
|
||||
$mail->assertTo('checkout@example.com');
|
||||
|
||||
return $mail->subject === "Pago confirmado - Compra #{$purchase->id}"
|
||||
&& str_contains($mail->render(), 'Total pagado');
|
||||
&& str_contains($mail->render(), 'Total pagado')
|
||||
&& str_contains($mail->render(), 'border-top: 4px solid #112233')
|
||||
&& ! str_contains($mail->render(), 'border-top: 4px solid #ff7006');
|
||||
});
|
||||
Mail::assertSent(Mailable::class, function (Mailable $mail): bool {
|
||||
$mail->assertTo('checkout@example.com');
|
||||
|
||||
return $mail->subject === 'Tus tickets ya están disponibles'
|
||||
&& str_contains($mail->render(), 'Entrada general');
|
||||
&& str_contains($mail->render(), 'Entrada general')
|
||||
&& str_contains($mail->render(), 'border-top: 4px solid #112233')
|
||||
&& ! str_contains($mail->render(), 'border-top: 4px solid #ff7006');
|
||||
});
|
||||
}
|
||||
|
||||
private function useWebsiteTypeBranding(): void
|
||||
{
|
||||
$websiteType = WebsiteType::query()->create([
|
||||
'codigo' => 'onticket',
|
||||
'nombre' => 'OnTicket',
|
||||
'dominio' => 'onticket.local',
|
||||
'primary_color' => '#ff7006',
|
||||
'body_color' => '#666666',
|
||||
'background_color' => '#f8f8f8',
|
||||
'surface_color' => '#ffffff',
|
||||
'login_header_footer_color' => '#838383',
|
||||
]);
|
||||
|
||||
$this->tenant->update(['website_type_code' => $websiteType->codigo]);
|
||||
$this->tenant->unsetRelation('websiteType');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user