22-05-2026 Optimierung der User und Admin Panels
This commit is contained in:
parent
d2ba22c0cf
commit
e8c47b7553
73 changed files with 10282 additions and 1546 deletions
135
tests/Feature/CustomerPressReleaseSchedulingFormTest.php
Normal file
135
tests/Feature/CustomerPressReleaseSchedulingFormTest.php
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\Contact;
|
||||
use App\Models\PressRelease;
|
||||
use App\Models\User;
|
||||
use Database\Seeders\RolesAndPermissionsSeeder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Livewire\Volt\Volt as LivewireVolt;
|
||||
use Tests\TestCase;
|
||||
|
||||
beforeEach(function (): void {
|
||||
/** @var TestCase $this */
|
||||
$this->seed(RolesAndPermissionsSeeder::class);
|
||||
});
|
||||
|
||||
function makeSchedulingCustomer(): array
|
||||
{
|
||||
$customer = User::factory()->create(['is_active' => true]);
|
||||
$customer->assignRole('customer');
|
||||
|
||||
$company = Company::factory()->presseecho()->create();
|
||||
$customer->companies()->attach($company->id, ['role' => 'owner']);
|
||||
|
||||
$contact = Contact::factory()->for($company)->create([
|
||||
'portal' => $company->portal->value,
|
||||
]);
|
||||
$category = Category::factory()->create();
|
||||
|
||||
return compact('customer', 'company', 'contact', 'category');
|
||||
}
|
||||
|
||||
test('create form persistiert scheduled_at und embargo_at', function () {
|
||||
/** @var TestCase $this */
|
||||
Carbon::setTestNow('2026-06-01 10:00:00');
|
||||
|
||||
['customer' => $customer, 'category' => $category] = makeSchedulingCustomer();
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.press-releases.create')
|
||||
->set('title', 'Phase 7F Scheduling Demo')
|
||||
->set('text', str_repeat('Inhalt eines Tests. ', 5))
|
||||
->set('categoryId', $category->id)
|
||||
->set('publishMode', 'scheduled')
|
||||
->set('scheduledAt', '2026-06-05T14:30')
|
||||
->set('useEmbargo', true)
|
||||
->set('embargoAt', '2026-06-10T08:00')
|
||||
->call('save')
|
||||
->assertHasNoErrors();
|
||||
|
||||
$pr = PressRelease::query()->latest('id')->firstOrFail();
|
||||
|
||||
expect($pr->scheduled_at?->toDateTimeString())->toBe('2026-06-05 14:30:00');
|
||||
expect($pr->embargo_at?->toDateTimeString())->toBe('2026-06-10 08:00:00');
|
||||
});
|
||||
|
||||
test('create form lehnt scheduled_at in der Vergangenheit ab', function () {
|
||||
/** @var TestCase $this */
|
||||
Carbon::setTestNow('2026-06-01 10:00:00');
|
||||
|
||||
['customer' => $customer, 'category' => $category] = makeSchedulingCustomer();
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.press-releases.create')
|
||||
->set('title', 'Vergangene Veröffentlichung')
|
||||
->set('text', str_repeat('Inhalt eines Tests. ', 5))
|
||||
->set('categoryId', $category->id)
|
||||
->set('publishMode', 'scheduled')
|
||||
->set('scheduledAt', '2026-05-30T10:00')
|
||||
->call('save')
|
||||
->assertHasErrors(['scheduledAt']);
|
||||
});
|
||||
|
||||
test('create form lehnt embargo_at in der Vergangenheit ab', function () {
|
||||
/** @var TestCase $this */
|
||||
Carbon::setTestNow('2026-06-01 10:00:00');
|
||||
|
||||
['customer' => $customer, 'category' => $category] = makeSchedulingCustomer();
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.press-releases.create')
|
||||
->set('title', 'Vergangenes Embargo')
|
||||
->set('text', str_repeat('Inhalt eines Tests. ', 5))
|
||||
->set('categoryId', $category->id)
|
||||
->set('useEmbargo', true)
|
||||
->set('embargoAt', '2026-05-30T10:00')
|
||||
->call('save')
|
||||
->assertHasErrors(['embargoAt']);
|
||||
});
|
||||
|
||||
test('publishMode now setzt scheduled_at auf null beim Save', function () {
|
||||
/** @var TestCase $this */
|
||||
['customer' => $customer, 'category' => $category] = makeSchedulingCustomer();
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.press-releases.create')
|
||||
->set('title', 'Sofort veröffentlichen')
|
||||
->set('text', str_repeat('Inhalt eines Tests. ', 5))
|
||||
->set('categoryId', $category->id)
|
||||
->set('publishMode', 'now')
|
||||
->set('scheduledAt', '2026-12-31T12:00')
|
||||
->call('save')
|
||||
->assertHasNoErrors();
|
||||
|
||||
$pr = PressRelease::query()->latest('id')->firstOrFail();
|
||||
|
||||
expect($pr->scheduled_at)->toBeNull();
|
||||
});
|
||||
|
||||
test('edit form hydriert scheduled_at und embargo_at', function () {
|
||||
/** @var TestCase $this */
|
||||
Carbon::setTestNow('2026-06-01 10:00:00');
|
||||
|
||||
['customer' => $customer, 'company' => $company, 'contact' => $contact, 'category' => $category] = makeSchedulingCustomer();
|
||||
|
||||
$pr = PressRelease::factory()->create([
|
||||
'user_id' => $customer->id,
|
||||
'company_id' => $company->id,
|
||||
'category_id' => $category->id,
|
||||
'portal' => $company->portal->value,
|
||||
'status' => 'draft',
|
||||
'scheduled_at' => '2026-06-05 14:30:00',
|
||||
'embargo_at' => '2026-06-10 08:00:00',
|
||||
]);
|
||||
$pr->contacts()->sync([$contact->id]);
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.press-releases.edit', ['id' => $pr->id])
|
||||
->assertSet('publishMode', 'scheduled')
|
||||
->assertSet('scheduledAt', '2026-06-05T14:30')
|
||||
->assertSet('useEmbargo', true)
|
||||
->assertSet('embargoAt', '2026-06-10T08:00');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue