reviewd and fixed epic 1 & 2
This commit is contained in:
@@ -48,6 +48,13 @@ So that **clients receive their login credentials and know how to access the pla
|
||||
- [ ] From Name: Libra Law Firm / مكتب ليبرا للمحاماة
|
||||
- [ ] Reply-To: (firm contact email)
|
||||
|
||||
### Environment Variables
|
||||
Ensure the following are configured in `.env`:
|
||||
```
|
||||
MAIL_FROM_ADDRESS=no-reply@libra.ps
|
||||
MAIL_FROM_NAME="Libra Law Firm"
|
||||
```
|
||||
|
||||
### Language Support
|
||||
- [ ] Email in user's preferred_language
|
||||
- [ ] Arabic email for Arabic preference
|
||||
@@ -65,6 +72,11 @@ So that **clients receive their login credentials and know how to access the pla
|
||||
- [ ] Password visible but not overly prominent
|
||||
- [ ] Tests verify email sending
|
||||
|
||||
### Error Handling
|
||||
- [ ] Email queued with retry on failure (Laravel default: 3 attempts)
|
||||
- [ ] Failed emails logged to `failed_jobs` table
|
||||
- [ ] User creation succeeds even if email fails (non-blocking)
|
||||
|
||||
## Technical Notes
|
||||
|
||||
### Mailable Class
|
||||
@@ -245,6 +257,34 @@ it('sends email in user preferred language', function () {
|
||||
return str_contains($mail->envelope()->subject, 'مرحباً');
|
||||
});
|
||||
});
|
||||
|
||||
it('queues welcome email instead of sending synchronously', function () {
|
||||
Mail::fake();
|
||||
|
||||
$user = User::factory()->create();
|
||||
|
||||
Mail::to($user)->queue(new WelcomeEmail($user, 'password123'));
|
||||
|
||||
Mail::assertQueued(WelcomeEmail::class);
|
||||
Mail::assertNothingSent(); // Confirms it was queued, not sent sync
|
||||
});
|
||||
|
||||
it('does not send email for admin accounts', function () {
|
||||
Mail::fake();
|
||||
|
||||
// Admin creation flow should NOT trigger welcome email
|
||||
$admin = User::factory()->admin()->create();
|
||||
|
||||
Mail::assertNothingQueued();
|
||||
});
|
||||
|
||||
it('generates plain text version of email', function () {
|
||||
$user = User::factory()->create(['preferred_language' => 'en']);
|
||||
$mailable = new WelcomeEmail($user, 'password123');
|
||||
|
||||
// Verify mailable can render (catches template errors)
|
||||
expect($mailable->render())->toBeString();
|
||||
});
|
||||
```
|
||||
|
||||
## Definition of Done
|
||||
@@ -257,6 +297,8 @@ it('sends email in user preferred language', function () {
|
||||
- [ ] English email for English preference
|
||||
- [ ] Plain text fallback works
|
||||
- [ ] Email queued (not blocking)
|
||||
- [ ] No email sent for admin accounts
|
||||
- [ ] Failed emails logged (non-blocking to user creation)
|
||||
- [ ] Tests verify email sending
|
||||
- [ ] Code formatted with Pint
|
||||
|
||||
|
||||
Reference in New Issue
Block a user