166 lines
6.8 KiB
PHP
166 lines
6.8 KiB
PHP
<?php
|
|
|
|
use App\Enums\Portal;
|
|
use App\Mail\ContactRequestSubmitted;
|
|
use App\Mail\GoLivePasswordReset;
|
|
use App\Mail\MagicLoginLink;
|
|
use App\Mail\PressReleaseDepublished;
|
|
use App\Mail\PressReleasePublished;
|
|
use App\Mail\PressReleaseRejected;
|
|
use App\Mail\TerminationRequestReceived;
|
|
use App\Mail\TerminationRequestSubmitted;
|
|
use App\Mail\WithdrawalRequestReceived;
|
|
use App\Mail\WithdrawalRequestSubmitted;
|
|
use App\Models\PressRelease;
|
|
use App\Models\TerminationRequest;
|
|
use App\Models\User;
|
|
use App\Models\WithdrawalRequest;
|
|
use Illuminate\Auth\Notifications\ResetPassword;
|
|
use Illuminate\Auth\Notifications\VerifyEmail;
|
|
|
|
/**
|
|
* Alle System-Mails müssen im pressekonto-CI erscheinen: Wortmarke,
|
|
* „Publisher · Hub"-Tagline und die Zugehörigkeits-Erklärung zur
|
|
* Brand-Familie (presseecho + businessportal24) aus dem zentralen
|
|
* E-Mail-Layout (components/emails/layout). Zusätzlich: Hub verlinkt,
|
|
* Rechts-Links (AGB/Impressum/Datenschutz) im Footer und keine direkte
|
|
* Service-Mailadresse im Fließtext.
|
|
*/
|
|
function assertHubEmailBranding(string $html): void
|
|
{
|
|
expect($html)
|
|
->toContain('Publisher · Hub')
|
|
->toContain('presseecho')
|
|
->toContain('businessportal24')
|
|
->toContain('ist der gemeinsame Publisher')
|
|
->toContain('#1A2540')
|
|
->toContain('#B07A3A')
|
|
// Hub ist verlinkt (Wortmarke im Header + Brand-Familien-Zeile).
|
|
->toContain('href="'.config('domains.domain_portal_url').'"')
|
|
// Rechtliche Links im Footer (alle auf dem Hub).
|
|
->toContain(config('domains.domain_portal_url').'/de/agb')
|
|
->toContain(config('domains.domain_portal_url').'/de/impressum')
|
|
->toContain(config('domains.domain_portal_url').'/de/datenschutz')
|
|
// Keine direkte Service-Mailadresse in der Mail.
|
|
->not->toContain(config('mail.from.address'));
|
|
}
|
|
|
|
test('the magic login link mail uses the hub ci layout', function () {
|
|
$user = User::factory()->make();
|
|
|
|
assertHubEmailBranding((new MagicLoginLink($user, 'https://pressekonto.test/magic-login/abc', '12.07.2026 10:00'))->render());
|
|
});
|
|
|
|
test('the go-live password reset mail uses the hub ci layout', function () {
|
|
$user = User::factory()->make();
|
|
|
|
assertHubEmailBranding((new GoLivePasswordReset($user, 'https://pressekonto.test/reset-password/abc'))->render());
|
|
});
|
|
|
|
test('the press release published and rejected mails use the hub ci layout', function () {
|
|
$pressRelease = PressRelease::factory()->published()->create();
|
|
$user = $pressRelease->user;
|
|
|
|
assertHubEmailBranding((new PressReleasePublished($user, $pressRelease))->render());
|
|
assertHubEmailBranding((new PressReleaseRejected($user, $pressRelease, 'Bitte Quellen ergänzen.'))->render());
|
|
});
|
|
|
|
test('the press release depublished mail uses the hub ci layout and explains the tombstone', function () {
|
|
$pressRelease = PressRelease::factory()->published()->create(['depublished_at' => now()]);
|
|
$user = $pressRelease->user;
|
|
|
|
$html = (new PressReleaseDepublished($user, $pressRelease))->render();
|
|
|
|
assertHubEmailBranding($html);
|
|
expect($html)
|
|
->toContain($pressRelease->title)
|
|
->toContain('Depubliziert am')
|
|
->toContain('auf Wunsch des Absenders entfernt');
|
|
});
|
|
|
|
test('the published mail names the portal with a link to the public detail page', function () {
|
|
$pressRelease = PressRelease::factory()->published()->forPortal(Portal::Presseecho)->create();
|
|
|
|
$html = (new PressReleasePublished($pressRelease->user, $pressRelease))->render();
|
|
|
|
expect($html)
|
|
->toContain('Veröffentlicht auf')
|
|
->toContain('Auf Presseecho ansehen')
|
|
->toContain(config('domains.domain_presseecho_url').'/de/press-release/'.$pressRelease->slug);
|
|
});
|
|
|
|
test('the published mail links both portals for a cross-portal press release', function () {
|
|
$pressRelease = PressRelease::factory()->published()->forPortal(Portal::Both)->create();
|
|
|
|
$html = (new PressReleasePublished($pressRelease->user, $pressRelease))->render();
|
|
|
|
expect($html)
|
|
->toContain('Auf Presseecho ansehen')
|
|
->toContain('Auf Businessportal24 ansehen')
|
|
->toContain(config('domains.domain_presseecho_url').'/de/press-release/'.$pressRelease->slug)
|
|
->toContain(config('domains.domain_businessportal_url').'/de/press-release/'.$pressRelease->slug);
|
|
});
|
|
|
|
test('the published mail links the account area below the portal links with a login hint', function () {
|
|
$pressRelease = PressRelease::factory()->published()->forPortal(Portal::Presseecho)->create();
|
|
|
|
$mailable = new PressReleasePublished($pressRelease->user, $pressRelease);
|
|
$html = $mailable->render();
|
|
|
|
$publicUrl = config('domains.domain_presseecho_url').'/de/press-release/'.$pressRelease->slug;
|
|
|
|
expect($html)
|
|
->toContain($mailable->showUrl)
|
|
->toContain('Pressemitteilung im pressekonto öffnen')
|
|
->toContain('Login-Bereich')
|
|
->toContain('mit Ihrem Passwort oder per Magic-Link');
|
|
|
|
// Reihenfolge: erst der öffentliche Portal-Link, darunter der Konto-Link.
|
|
expect(mb_strpos($html, $publicUrl))->toBeLessThan(mb_strpos($html, 'Pressemitteilung im pressekonto öffnen'));
|
|
});
|
|
|
|
test('the termination mails use the hub ci layout', function () {
|
|
$terminationRequest = TerminationRequest::factory()->create();
|
|
|
|
assertHubEmailBranding((new TerminationRequestReceived($terminationRequest))->render());
|
|
assertHubEmailBranding((new TerminationRequestSubmitted($terminationRequest))->render());
|
|
});
|
|
|
|
test('the withdrawal mails use the hub ci layout', function () {
|
|
$withdrawalRequest = WithdrawalRequest::factory()->create();
|
|
|
|
assertHubEmailBranding((new WithdrawalRequestReceived($withdrawalRequest))->render());
|
|
assertHubEmailBranding((new WithdrawalRequestSubmitted($withdrawalRequest))->render());
|
|
});
|
|
|
|
test('the contact request mail uses the hub ci layout', function () {
|
|
assertHubEmailBranding(
|
|
(new ContactRequestSubmitted('Paula Presse', 'paula@example.test', 'Eine Frage zur Plattform.', 'pressekonto.test'))->render()
|
|
);
|
|
});
|
|
|
|
test('the password reset notification renders in the hub ci layout', function () {
|
|
$user = User::factory()->create();
|
|
|
|
$mailMessage = (new ResetPassword('test-token'))->toMail($user);
|
|
|
|
expect($mailMessage->subject)->toBe('Passwort zurücksetzen für Ihr pressekonto');
|
|
|
|
$html = (string) $mailMessage->render();
|
|
|
|
assertHubEmailBranding($html);
|
|
expect($html)->toContain('/reset-password/test-token');
|
|
});
|
|
|
|
test('the email verification notification renders in the hub ci layout', function () {
|
|
$user = User::factory()->unverified()->create();
|
|
|
|
$mailMessage = (new VerifyEmail)->toMail($user);
|
|
|
|
expect($mailMessage->subject)->toBe('E-Mail-Adresse bestätigen für Ihr pressekonto');
|
|
|
|
$html = (string) $mailMessage->render();
|
|
|
|
assertHubEmailBranding($html);
|
|
expect($html)->toContain('/verify-email/');
|
|
});
|