feat(notification): enhance password reset emails with custom templates for different scenarios
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Tests\Feature\Notification;
|
||||
|
||||
use App\Domains\Attachable\Enums\AttachmentType;
|
||||
use App\Domains\Attachable\Models\Attachment;
|
||||
use App\Domains\Auth\Models\ResetPasswordAttempt;
|
||||
use App\Domains\Auth\Models\User;
|
||||
use App\Domains\Catalog\Models\CatalogItem;
|
||||
use App\Domains\Integration\Models\Integration;
|
||||
@@ -133,15 +134,64 @@ class NotificationMailServiceTest extends TestCase
|
||||
);
|
||||
|
||||
Mail::assertSent(Mailable::class, function (Mailable $mail): bool {
|
||||
$mail->assertHasSubject('Tu cuenta de escáner está lista - Scanner Mail');
|
||||
$rendered = $mail->render();
|
||||
|
||||
return str_contains($rendered, 'https://scanner.mail.local/recuperar-contrasena/codigo')
|
||||
&& str_contains($rendered, 'Tu cuenta de escáner está lista')
|
||||
&& str_contains($rendered, 'comenzar a escanear entradas')
|
||||
&& ! str_contains($rendered, 'Recuperá tu contraseña')
|
||||
&& str_contains($rendered, 'email=ada%40example.com')
|
||||
&& str_contains($rendered, 'code=0123')
|
||||
&& str_contains($rendered, 'Crear mi');
|
||||
});
|
||||
}
|
||||
|
||||
public function test_administrator_creation_has_custom_copy_and_the_existing_code_and_link(): void
|
||||
{
|
||||
$websiteType = WebsiteType::query()->create([
|
||||
'codigo' => 'admin-mail', 'nombre' => 'Admin Mail',
|
||||
'dominio' => 'admin.mail.local', 'scanner_domain' => 'scanner.mail.local',
|
||||
]);
|
||||
$this->tenant->update(['website_type_code' => $websiteType->codigo]);
|
||||
$attempt = $this->user->resetPasswordAttempts()->create([
|
||||
'codigo' => '0456', 'reason' => ResetPasswordAttempt::REASON_ADMINISTRATOR_CREATED,
|
||||
]);
|
||||
app(NotificationMailService::class)->sendPasswordResetCode($attempt->id, $this->tenant->codigo, PasswordResetRequested::CHANNEL_ADMINAPP);
|
||||
Mail::assertSent(Mailable::class, function (Mailable $mail): bool {
|
||||
$mail->assertHasSubject('Tu cuenta de administrador está lista - Admin Mail');
|
||||
$html = $mail->render();
|
||||
|
||||
return str_contains($html, 'Tu cuenta de administrador está lista')
|
||||
&& str_contains($html, 'ingresar al panel de administración')
|
||||
&& str_contains($html, '0456')
|
||||
&& str_contains($html, 'Crear mi contraseña')
|
||||
&& str_contains($html, 'https://admin.mail.local/recuperar-contrasena/codigo?email=ada%40example.com')
|
||||
&& ! str_contains($html, 'scanner.mail.local')
|
||||
&& ! str_contains($html, 'administrator_created')
|
||||
&& ! str_contains($html, 'Recuperá tu contraseña');
|
||||
});
|
||||
}
|
||||
|
||||
public function test_locked_account_has_its_own_copy_and_the_shared_code_action(): void
|
||||
{
|
||||
$attempt = $this->user->resetPasswordAttempts()->create([
|
||||
'codigo' => '0789', 'reason' => ResetPasswordAttempt::REASON_ACCOUNT_LOCKED,
|
||||
]);
|
||||
app(NotificationMailService::class)->sendPasswordResetCode($attempt->id, $this->tenant->codigo);
|
||||
Mail::assertSent(Mailable::class, function (Mailable $mail): bool {
|
||||
$mail->assertHasSubject('Desbloqueá tu cuenta - Mail Tenant');
|
||||
$html = $mail->render();
|
||||
|
||||
return str_contains($html, 'Desbloqueá tu cuenta')
|
||||
&& str_contains($html, 'bloqueamos el acceso temporalmente')
|
||||
&& str_contains($html, '0789')
|
||||
&& str_contains($html, 'Ingresar código ahora')
|
||||
&& str_contains($html, 'https://mail.local/recuperar-contrasena/codigo')
|
||||
&& ! str_contains($html, 'account_locked');
|
||||
});
|
||||
}
|
||||
|
||||
public function test_it_sends_one_purchase_confirmation_with_generated_tickets_attached(): void
|
||||
{
|
||||
$this->useWebsiteTypeBranding();
|
||||
|
||||
Reference in New Issue
Block a user