seed(RolesAndPermissionsSeeder::class); }); function dsgvoPanelOwner(): User { $owner = User::factory()->create(['is_active' => true]); $owner->assignRole('customer'); return $owner; } test('the concerns modal offers all four tracks', function () { /** @var TestCase $this */ $owner = dsgvoPanelOwner(); $this->actingAs($owner); $pressRelease = PressRelease::factory()->published()->create(['user_id' => $owner->id]); Volt::test('customer.press-releases.show', ['id' => $pressRelease->id]) ->assertSee('Was möchten Sie tun?') ->assertSee('Kleine Korrektur') ->assertSee('Inhaltliche Änderung') ->assertSee('Entfernung persönlicher Daten (DSGVO)') ->assertSee('Depublizierung'); }); test('the dsgvo preview validates input and never touches the release', function () { /** @var TestCase $this */ $owner = dsgvoPanelOwner(); $this->actingAs($owner); $pressRelease = PressRelease::factory()->published()->create([ 'user_id' => $owner->id, 'title' => 'Max Mustermann übernimmt die Leitung', ]); $component = Volt::test('customer.press-releases.show', ['id' => $pressRelease->id]); // Leeres Formular → Fehler. $component->call('previewDsgvo')->assertHasErrors('dsgvo'); // Begriffe ohne Treffer → Fehler. $component->set('dsgvoTerms', 'Kommtnichtvor') ->call('previewDsgvo') ->assertHasErrors('dsgvo'); // Treffer → Vorschau, PM unverändert. $component->set('dsgvoTerms', 'Max Mustermann') ->call('previewDsgvo') ->assertHasNoErrors() ->assertSee('[entfernt] übernimmt die Leitung'); expect($pressRelease->fresh()->title)->toBe('Max Mustermann übernimmt die Leitung') ->and(LegalRequest::query()->count())->toBe(0); }); test('the confirmed dsgvo submission creates a verified open request for the admin queue', function () { /** @var TestCase $this */ Mail::fake(); $owner = dsgvoPanelOwner(); $this->actingAs($owner); $pressRelease = PressRelease::factory()->published()->create([ 'user_id' => $owner->id, 'title' => 'Max Mustermann übernimmt die Leitung', ]); Volt::test('customer.press-releases.show', ['id' => $pressRelease->id]) ->set('dsgvoTerms', "Max Mustermann\nMustermanns") ->set('dsgvoDetachContacts', true) ->set('dsgvoMessage', 'Ich bin die betroffene Person und wünsche die Entfernung.') ->call('submitDsgvo') ->assertHasErrors('dsgvo') // ohne Vorschau keine Einreichung ->call('previewDsgvo') ->assertHasNoErrors() ->call('submitDsgvo') ->assertHasNoErrors(); $request = LegalRequest::query()->sole(); expect($request->type)->toBe(LegalRequestType::Dsgvo) ->and($request->status)->toBe(LegalRequestStatus::Open) ->and($request->verification_method)->toBe(LegalRequestVerificationMethod::LoggedIn) ->and($request->requester_email)->toBe($owner->email) ->and($request->payload['redaction']['terms'])->toBe(['Max Mustermann', 'Mustermanns']) ->and($request->payload['redaction']['detach_contacts'])->toBeTrue() ->and($request->executed_at)->toBeNull() ->and($pressRelease->fresh()->title)->toBe('Max Mustermann übernimmt die Leitung'); Mail::assertQueued(LegalRequestReceived::class, fn (LegalRequestReceived $mail) => $mail->hasTo($owner->email)); Mail::assertQueued(LegalRequestSubmitted::class); }); test('a second open dsgvo request for the same release is blocked', function () { /** @var TestCase $this */ Mail::fake(); $owner = dsgvoPanelOwner(); $this->actingAs($owner); $pressRelease = PressRelease::factory()->published()->create([ 'user_id' => $owner->id, 'title' => 'Max Mustermann übernimmt die Leitung', ]); LegalRequest::factory()->type(LegalRequestType::Dsgvo)->create([ 'press_release_id' => $pressRelease->id, 'status' => LegalRequestStatus::Open, ]); Volt::test('customer.press-releases.show', ['id' => $pressRelease->id]) ->set('dsgvoTerms', 'Max Mustermann') ->set('dsgvoMessage', 'Bitte meinen Namen entfernen, danke.') ->call('previewDsgvo') ->call('submitDsgvo') ->assertHasErrors('dsgvo'); expect(LegalRequest::query()->count())->toBe(1); });