admin: Mail-Sperrliste, Markierung nicht erreichbarer Newsrooms (Roadmap 1b.6, Schritt 4)
Admin ▸ Mail-Sperrliste mit Freigabe, manueller Sperre, nicht lesbaren Rückläufern und Breaker-Zustand. Firmenseite markiert gesperrte Firmen-E-Mail und Pressekontakte. Die Claim-Seite zählt gesperrte Adressen nicht mehr als Empfänger und erklärt, warum kein Link geht. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f9c97ccf2f
commit
e7e12b9436
12 changed files with 426 additions and 9 deletions
79
tests/Feature/MailSuppressionAdminTest.php
Normal file
79
tests/Feature/MailSuppressionAdminTest.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\EmailSuppressionReason;
|
||||
use App\Models\Company;
|
||||
use App\Models\Contact;
|
||||
use App\Models\EmailSuppression;
|
||||
use App\Models\User;
|
||||
use App\Services\Mail\EmailSuppressionService;
|
||||
use Database\Seeders\RolesAndPermissionsSeeder;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Livewire\Volt\Volt as LivewireVolt;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Roadmap 1b.6, Schritt 4: nicht erreichbare Newsrooms im Admin markiert,
|
||||
* nicht beanspruchbar, Freigabe im Admin.
|
||||
*/
|
||||
beforeEach(function (): void {
|
||||
/** @var TestCase $this */
|
||||
$this->seed(RolesAndPermissionsSeeder::class);
|
||||
Mail::fake();
|
||||
});
|
||||
|
||||
function suppressionAdmin(): User
|
||||
{
|
||||
$admin = User::factory()->create(['is_active' => true]);
|
||||
$admin->assignRole('admin');
|
||||
test()->actingAs($admin);
|
||||
|
||||
return $admin;
|
||||
}
|
||||
|
||||
test('a newsroom whose only address bounced is not claimable and says why', function () {
|
||||
/** @var TestCase $this */
|
||||
Company::factory()->create(['portal' => 'businessportal24', 'slug' => 'tot-gmbh', 'email' => 'presse@tot.example', 'name' => 'Tot GmbH']);
|
||||
app(EmailSuppressionService::class)->suppress('presse@tot.example', EmailSuppressionReason::HardBounce, 'imap');
|
||||
|
||||
$this->get('https://businessportal24.test/de/newsroom/tot-gmbh/verwalten')
|
||||
->assertOk()
|
||||
->assertSeeText('nicht mehr erreichbar')
|
||||
->assertDontSeeText('Anmeldelink senden');
|
||||
|
||||
$this->post('https://businessportal24.test/de/newsroom/tot-gmbh/verwalten')->assertSessionHas('newsroom-claim-unreachable');
|
||||
Mail::assertNothingQueued();
|
||||
});
|
||||
|
||||
test('the admin company page marks unreachable company and contact addresses', function () {
|
||||
/** @var TestCase $this */
|
||||
suppressionAdmin();
|
||||
$company = Company::factory()->create(['email' => 'presse@tot.example']);
|
||||
Contact::factory()->for($company)->create(['email' => 'kontakt@tot.example', 'portal' => $company->portal->value]);
|
||||
app(EmailSuppressionService::class)->suppress('presse@tot.example', EmailSuppressionReason::HardBounce, 'imap');
|
||||
app(EmailSuppressionService::class)->suppress('kontakt@tot.example', EmailSuppressionReason::HardBounce, 'imap');
|
||||
|
||||
LivewireVolt::test('admin.companies.show', ['id' => $company->id])
|
||||
->assertSee('E-Mail nicht erreichbar')
|
||||
->call('setTab', 'contacts')
|
||||
->assertSee('kontakt@tot.example')
|
||||
->assertSeeInOrder(['nicht erreichbar', 'kontakt@tot.example']);
|
||||
});
|
||||
|
||||
test('the suppression list shows, releases and manually suppresses addresses', function () {
|
||||
/** @var TestCase $this */
|
||||
$admin = suppressionAdmin();
|
||||
app(EmailSuppressionService::class)->suppress('presse@tot.example', EmailSuppressionReason::HardBounce, 'imap');
|
||||
|
||||
$component = LivewireVolt::test('admin.mail.suppressions')
|
||||
->assertSee('presse@tot.example')
|
||||
->assertSee('Postfach existiert nicht');
|
||||
|
||||
$component->call('release', EmailSuppression::query()->firstOrFail()->id);
|
||||
expect(app(EmailSuppressionService::class)->isSuppressed('presse@tot.example'))->toBeFalse()
|
||||
->and(EmailSuppression::query()->first()->released_by_user_id)->toBe($admin->id);
|
||||
|
||||
$component->set('newEmail', 'Neu@Tot.example')->set('newNote', 'von Hand')->call('suppress')->assertHasNoErrors();
|
||||
expect(app(EmailSuppressionService::class)->isSuppressed('neu@tot.example'))->toBeTrue();
|
||||
|
||||
$this->get(route('admin.mail.suppressions'))->assertOk()->assertSeeText('Mail-Sperrliste');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue