Add per-customer SMS and Bird Integrations for event messaging.
Deploy Ladill Events / deploy (push) Successful in 28s
Deploy Ladill Events / deploy (push) Successful in 28s
Attendee and speaker comms use encrypted tenant relay credentials and skip platform-key fallback and Bird wallet double-debit. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,12 +2,13 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\MessagingCredential;
|
||||
use App\Models\QrCode;
|
||||
use App\Models\User;
|
||||
use App\Services\Events\EventSpeakerInviteService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Tests\TestCase;
|
||||
|
||||
class EventSpeakerInviteTest extends TestCase
|
||||
@@ -20,17 +21,25 @@ class EventSpeakerInviteTest extends TestCase
|
||||
$this->withoutMiddleware(\App\Http\Middleware\EnsurePlatformSession::class);
|
||||
|
||||
config([
|
||||
'mail.from.address' => 'noreply@ladill.com',
|
||||
'mail.from.name' => 'Ladill',
|
||||
'events.service_api_keys.meet' => 'test-meet-key',
|
||||
]);
|
||||
|
||||
Mail::fake();
|
||||
|
||||
Http::fake([
|
||||
config('billing.api_url').'/balance*' => Http::response(['balance_minor' => 50000]),
|
||||
config('billing.api_url').'/can-afford*' => Http::response(['affordable' => true]),
|
||||
config('billing.api_url').'/debit' => Http::response(['success' => true]),
|
||||
'*/api/smtp/send' => Http::response(['success' => true, 'message_id' => 'x']),
|
||||
]);
|
||||
}
|
||||
|
||||
private function seedBirdCredentials(User $owner): void
|
||||
{
|
||||
$plain = 'lsk_live_'.str_repeat('f', 32);
|
||||
MessagingCredential::create([
|
||||
'owner_ref' => $owner->public_id,
|
||||
'bird_api_key_encrypted' => Crypt::encryptString($plain),
|
||||
'bird_api_key_prefix' => substr($plain, 0, 16),
|
||||
'bird_from_email' => 'events@example.test',
|
||||
'bird_from_name' => 'Events',
|
||||
'bird_status' => MessagingCredential::STATUS_VALID,
|
||||
'bird_validated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -76,6 +85,7 @@ class EventSpeakerInviteTest extends TestCase
|
||||
public function test_manual_speaker_invite_sends_email_and_records_metadata(): void
|
||||
{
|
||||
$owner = User::factory()->create(['public_id' => 'usr_sp_manual']);
|
||||
$this->seedBirdCredentials($owner);
|
||||
|
||||
$event = QrCode::create([
|
||||
'user_id' => $owner->id,
|
||||
@@ -103,7 +113,7 @@ class EventSpeakerInviteTest extends TestCase
|
||||
->assertRedirect(route('speakers.show', $event))
|
||||
->assertSessionHas('success');
|
||||
|
||||
Http::assertSent(fn ($request) => str_contains($request->url(), '/debit'));
|
||||
Http::assertSent(fn ($request) => str_contains($request->url(), '/api/smtp/send'));
|
||||
|
||||
$event->refresh();
|
||||
$speaker = $event->content()['speakers'][0];
|
||||
@@ -115,6 +125,7 @@ class EventSpeakerInviteTest extends TestCase
|
||||
public function test_programme_save_invites_assigned_speaker_hosts(): void
|
||||
{
|
||||
$owner = User::factory()->create(['public_id' => 'usr_sp_prog']);
|
||||
$this->seedBirdCredentials($owner);
|
||||
|
||||
$programme = QrCode::create([
|
||||
'user_id' => $owner->id,
|
||||
@@ -166,7 +177,7 @@ class EventSpeakerInviteTest extends TestCase
|
||||
|
||||
app(EventSpeakerInviteService::class)->inviteProgrammeHosts($programme, $owner);
|
||||
|
||||
Http::assertSent(fn ($request) => str_contains($request->url(), '/debit'));
|
||||
Http::assertSent(fn ($request) => str_contains($request->url(), '/api/smtp/send'));
|
||||
|
||||
$event->refresh();
|
||||
$speaker = $event->content()['speakers'][0];
|
||||
@@ -232,8 +243,6 @@ class EventSpeakerInviteTest extends TestCase
|
||||
|
||||
public function test_manual_speaker_invite_reports_when_email_not_configured(): void
|
||||
{
|
||||
config(['mail.from.address' => '']);
|
||||
|
||||
$owner = User::factory()->create(['public_id' => 'usr_sp_no_smtp']);
|
||||
|
||||
$event = QrCode::create([
|
||||
@@ -266,6 +275,7 @@ class EventSpeakerInviteTest extends TestCase
|
||||
public function test_manual_speaker_invite_can_be_resent_after_programme_invite(): void
|
||||
{
|
||||
$owner = User::factory()->create(['public_id' => 'usr_sp_resend']);
|
||||
$this->seedBirdCredentials($owner);
|
||||
|
||||
$event = QrCode::create([
|
||||
'user_id' => $owner->id,
|
||||
@@ -296,6 +306,6 @@ class EventSpeakerInviteTest extends TestCase
|
||||
->assertRedirect(route('speakers.show', $event))
|
||||
->assertSessionHas('success');
|
||||
|
||||
Http::assertSent(fn ($request) => str_contains($request->url(), '/debit'));
|
||||
Http::assertSent(fn ($request) => str_contains($request->url(), '/api/smtp/send'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user