Addresses of the internal communication in the admin (notification recipients, contact/reply-to, sender)
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-23 07:14:25 +02:00
1 parent 749537342e
commit 0c98d82cf2
20 files changed
+165 -20

No files matched your search

+43
View File
@@ -2,10 +2,17 @@
namespace Tests\Feature;
use App\Actions\CreateReservation;
use App\Enums\UserRole;
use App\Filament\Pages\Operations;
use App\Mail\NewReservation;
use App\Mail\ReservationReceived;
use App\Models\Property;
use App\Models\User;
use App\Pricing\StayRequest;
use App\Support\Settings;
use Carbon\CarbonImmutable;
use Database\Seeders\PropertySeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Mail\MailManager;
use Illuminate\Support\Facades\Mail;
@@ -47,6 +54,42 @@ public function test_switched_live_mails_reach_their_real_recipients(): void
$this->assertNull(Settings::mailRedirect());
}
public function test_addresses_of_the_internal_communication_are_set_in_the_admin(): void
{
config(['fewo.mail_redirect_to' => null]);
$this->actingAs(User::factory()->create());
Livewire::test(Operations::class)
->set('data.mode', Settings::MODE_LIVE)
->set('data.notification_recipients', ['brigitte@example.com', 'lars@example.com'])
->set('data.contact_email', 'info@example.com')
->set('data.sender_name', 'FeWo Test')
->set('data.sender_email', 'versand@example.com')
->call('save')
->assertHasNoErrors();
$this->assertSame(['brigitte@example.com', 'lars@example.com'], Settings::notificationRecipients());
$this->assertSame(['info@example.com', 'versand@example.com', 'FeWo Test'], [config('fewo.owner.email'), config('mail.from.address'), config('mail.from.name')]);
Mail::fake();
$this->seed(PropertySeeder::class);
$booking = app(CreateReservation::class)->handle(Property::sole(), new StayRequest(CarbonImmutable::parse('2026-12-01'), CarbonImmutable::parse('2026-12-05'), 2), ['first_name' => 'Erika', 'last_name' => 'Muster', 'email' => 'erika@example.com']);
Mail::assertSent(NewReservation::class, fn (NewReservation $mail): bool => $mail->hasTo('brigitte@example.com') && $mail->hasTo('lars@example.com'));
Mail::assertSent(ReservationReceived::class, fn (ReservationReceived $mail): bool => $mail->hasReplyTo('info@example.com'));
$this->assertNotNull($booking);
}
public function test_invalid_notification_addresses_are_rejected(): void
{
$this->actingAs(User::factory()->create());
Livewire::test(Operations::class)
->set('data.notification_recipients', ['keine-adresse'])
->call('save')
->assertHasErrors();
}
public function test_server_override_always_wins(): void
{
config(['fewo.mail_redirect_to' => 'server@example.com']);