-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix email notification reply to (#603)
- Loading branch information
1 parent
6bdce23
commit 08837e6
Showing
2 changed files
with
73 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
$notifiable->route('mail', '[email protected]'); | ||
$renderedMail = $mailable->toMail($notifiable); | ||
expect($renderedMail->subject)->toBe('New form submission'); | ||
expect($renderedMail->replyTo[0][0])->toBe('[email protected]'); | ||
expect(trim($renderedMail->render()))->toContain('Test body'); | ||
}); | ||
|
||
|
@@ -163,3 +164,65 @@ function (FormEmailNotification $notification, $channels, $notifiable) { | |
expect($renderedMail->subject)->toBe('Custom Subject'); | ||
expect(trim($renderedMail->render()))->toContain('Custom content'); | ||
}); | ||
|
||
it('send email with mention as reply to', function () { | ||
$user = $this->actingAsUser(); | ||
$workspace = $this->createUserWorkspace($user); | ||
$form = $this->createForm($user, $workspace); | ||
|
||
$emailProperty = collect($form->properties)->first(function ($property) { | ||
return $property['type'] == 'email'; | ||
}); | ||
|
||
$integrationData = $this->createFormIntegration('email', $form->id, [ | ||
'send_to' => '[email protected]', | ||
'sender_name' => 'OpnForm', | ||
'subject' => 'New form submission', | ||
'email_content' => 'Hello there 👋 <br>Test body', | ||
'include_submission_data' => true, | ||
'include_hidden_fields_submission_data' => false, | ||
'reply_to' => '<span mention-field-id="' . $emailProperty['id'] . '" mention-field-name="' . $emailProperty['name'] . '" mention-fallback="" contenteditable="false" mention="true">' . $emailProperty['name'] . '</span>' | ||
]); | ||
|
||
$formData = [ | ||
$emailProperty['id'] => '[email protected]', | ||
]; | ||
|
||
$event = new \App\Events\Forms\FormSubmitted($form, $formData); | ||
$mailable = new FormEmailNotification($event, $integrationData, 'mail'); | ||
$notifiable = new AnonymousNotifiable(); | ||
$notifiable->route('mail', '[email protected]'); | ||
$renderedMail = $mailable->toMail($notifiable); | ||
expect($renderedMail->replyTo[0][0])->toBe('[email protected]'); | ||
}); | ||
|
||
it('send email with empty reply to', function () { | ||
$user = $this->actingAsUser(); | ||
$workspace = $this->createUserWorkspace($user); | ||
$form = $this->createForm($user, $workspace); | ||
|
||
$emailProperty = collect($form->properties)->first(function ($property) { | ||
return $property['type'] == 'email'; | ||
}); | ||
|
||
$integrationData = $this->createFormIntegration('email', $form->id, [ | ||
'send_to' => '[email protected]', | ||
'sender_name' => 'OpnForm', | ||
'subject' => 'New form submission', | ||
'email_content' => 'Hello there 👋 <br>Test body', | ||
'include_submission_data' => true, | ||
'include_hidden_fields_submission_data' => false, | ||
'reply_to' => null, | ||
]); | ||
|
||
$formData = [ | ||
$emailProperty['id'] => '[email protected]', | ||
]; | ||
|
||
$event = new \App\Events\Forms\FormSubmitted($form, $formData); | ||
$mailable = new FormEmailNotification($event, $integrationData, 'mail'); | ||
$notifiable = new AnonymousNotifiable(); | ||
$notifiable->route('mail', '[email protected]'); | ||
$renderedMail = $mailable->toMail($notifiable); | ||
expect($renderedMail->replyTo[0][0])->toBe($form->creator->email); | ||
}); |