Backend-WIP: Kontakt-Queue, Page-Cache, Validierungs-Feedback, i18n
Gebuendelt, da ueber gemeinsame lang-/Service-Dateien verschraenkt: - Kontakt-Nachrichten: contact_messages-Tabelle + Model/Enums/Factory, Admin-Queue (livewire/admin/contact-messages), ContactController persistiert das Anliegen zusaetzlich zur Brand-Mail - Page-Data-Cache (Services/Web/*PageData) + web-archive-Indizes auf press_releases - Validierungs-Feedback + Company-Portal-Restriction (Feature-Tests) - i18n-Auslagerung lang/de|en (auth, passwords, validation, static) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ef5de54300
commit
72e6a3c210
60 changed files with 3963 additions and 327 deletions
103
tests/Feature/PressReleaseValidationFeedbackTest.php
Normal file
103
tests/Feature/PressReleaseValidationFeedbackTest.php
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\PressRelease;
|
||||
use App\Models\User;
|
||||
use Database\Seeders\RolesAndPermissionsSeeder;
|
||||
use Livewire\Volt\Volt as LivewireVolt;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Sichtbares Validierungs-Feedback der PM-Editoren (Customer):
|
||||
* persistente Fehler-Zusammenfassung bei den Speichern-Buttons statt nur
|
||||
* flüchtigem Toast, deutsche Feldnamen statt "category id", rot markierte
|
||||
* Panels für Fehlerfelder.
|
||||
*/
|
||||
beforeEach(function (): void {
|
||||
/** @var TestCase $this */
|
||||
$this->seed(RolesAndPermissionsSeeder::class);
|
||||
});
|
||||
|
||||
function makeValidationFeedbackCustomer(): User
|
||||
{
|
||||
$customer = User::factory()->create(['is_active' => true]);
|
||||
$customer->assignRole('customer');
|
||||
|
||||
$company = Company::factory()->presseecho()->create();
|
||||
$customer->companies()->attach($company->id, ['role' => 'owner']);
|
||||
|
||||
return $customer;
|
||||
}
|
||||
|
||||
test('create page shows a persistent error summary with German field names when saving without a category', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->actingAs(makeValidationFeedbackCustomer());
|
||||
|
||||
LivewireVolt::test('customer.press-releases.create')
|
||||
->set('title', 'Ein gültiger Titel für die PM')
|
||||
->set('text', str_repeat('Aussagekräftiger Fließtext. ', 5))
|
||||
->set('categoryId', null)
|
||||
->call('save', 'draft')
|
||||
->assertHasErrors(['categoryId'])
|
||||
->assertSee('Speichern nicht möglich')
|
||||
->assertSee('Kategorie muss ausgefüllt werden.')
|
||||
->assertDontSee('category id');
|
||||
});
|
||||
|
||||
test('create page error summary lists every failing field and disappears once resolved', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->actingAs(makeValidationFeedbackCustomer());
|
||||
$category = Category::factory()->create();
|
||||
|
||||
$component = LivewireVolt::test('customer.press-releases.create')
|
||||
->call('save', 'draft')
|
||||
->assertHasErrors(['categoryId', 'title', 'text'])
|
||||
->assertSee('Speichern nicht möglich')
|
||||
->assertSee('Kategorie muss ausgefüllt werden.')
|
||||
->assertSee('Titel muss ausgefüllt werden.')
|
||||
->assertSee('Text muss ausgefüllt werden.');
|
||||
|
||||
$component
|
||||
->set('categoryId', $category->id)
|
||||
->set('title', 'Ein gültiger Titel für die PM')
|
||||
->set('text', str_repeat('Aussagekräftiger Fließtext. ', 5))
|
||||
->call('save', 'draft')
|
||||
->assertHasNoErrors()
|
||||
->assertRedirect();
|
||||
});
|
||||
|
||||
test('create page marks the category panel as invalid and keeps the jump anchor', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->actingAs(makeValidationFeedbackCustomer());
|
||||
|
||||
LivewireVolt::test('customer.press-releases.create')
|
||||
->assertSeeHtml('data-error-anchor="categoryId"')
|
||||
->assertDontSeeHtml('is-invalid')
|
||||
->call('save', 'draft')
|
||||
->assertSeeHtml('is-invalid');
|
||||
});
|
||||
|
||||
test('edit page shows the error summary when saving without a category', function () {
|
||||
/** @var TestCase $this */
|
||||
$customer = makeValidationFeedbackCustomer();
|
||||
$company = $customer->companies()->first();
|
||||
$category = Category::factory()->create();
|
||||
|
||||
$pr = PressRelease::factory()->create([
|
||||
'user_id' => $customer->id,
|
||||
'company_id' => $company->id,
|
||||
'category_id' => $category->id,
|
||||
'portal' => $company->portal->value,
|
||||
'status' => 'draft',
|
||||
]);
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.press-releases.edit', ['id' => $pr->id])
|
||||
->set('categoryId', null)
|
||||
->call('save')
|
||||
->assertHasErrors(['categoryId'])
|
||||
->assertSee('Speichern nicht möglich')
|
||||
->assertSee('Kategorie muss ausgefüllt werden.');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue