feat(mail-campaigns): sender info + resolve typed emails against customers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
54c14c41d8
commit
e1efc88fd2
@@ -7,7 +7,10 @@ namespace Tests\Feature\Api\Admin;
|
||||
use App\Jobs\Mail\SendMailCampaignRecipient;
|
||||
use App\Models\Mail;
|
||||
use App\Models\MailCampaign;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Support\MailSettings;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail as MailFacade;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
@@ -36,6 +39,41 @@ class MailCampaignBulkActionTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_index_filters_by_search_status_and_date(): void
|
||||
{
|
||||
$match = $this->campaign('completed');
|
||||
$match->update(['name' => 'Khuyến mãi Tết']);
|
||||
$this->campaign('failed')->update(['name' => 'Khuyến mãi hè']);
|
||||
$this->campaign('completed')->update(['name' => 'Bảo trì']);
|
||||
$old = $this->campaign('completed');
|
||||
$old->update(['name' => 'Khuyến mãi cũ']);
|
||||
$old->forceFill(['created_at' => now()->subMonth()])->saveQuietly();
|
||||
|
||||
$this->actingAs($this->admin, 'admin')
|
||||
->getJson('/api/v1/administrator/mail-campaigns?' . http_build_query([
|
||||
'search' => 'khuyến mãi', 'status' => ['completed'], 'date_from' => now()->subDay()->toDateString(),
|
||||
]))
|
||||
->assertOk()
|
||||
->assertJsonPath('data.total', 1)
|
||||
->assertJsonPath('data.items.0.uuid', $match->uuid);
|
||||
}
|
||||
|
||||
public function test_sender_reports_smtp_from_address(): void
|
||||
{
|
||||
Setting::updateOrCreate(['key' => 'smtp'], ['value' => json_encode([
|
||||
'host' => 'smtp.example.com', 'user' => 'u@example.com', 'from_address' => 'noreply@tgs.test', 'from_name' => 'TGS',
|
||||
])]);
|
||||
Cache::forget(MailSettings::cacheKey());
|
||||
MailSettings::apply();
|
||||
|
||||
$this->actingAs($this->admin, 'admin')
|
||||
->getJson('/api/v1/administrator/mail-campaigns/sender')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.from_address', 'noreply@tgs.test')
|
||||
->assertJsonPath('data.from_name', 'TGS')
|
||||
->assertJsonPath('data.smtp_configured', true);
|
||||
}
|
||||
|
||||
public function test_cancel_stops_pending_jobs_and_keeps_finished_campaigns(): void
|
||||
{
|
||||
MailFacade::fake();
|
||||
|
||||
Reference in New Issue
Block a user