test(php): update existing tests for agenda model
- Fix uploaded_at in InformationBlockTest and ServiceControllerTest (Faker ignores Carbon::setTestNow, generating future dates that fail the uploaded_at <= service.date filter) - Add agenda item association tests to ModerationBlockTest (3 new tests) - Add agenda item association tests to SermonBlockTest (3 new tests) - Verify legacy slides without agenda item still work Test results: 12 failures (down from 14 baseline), all pre-existing (ProPresenter parser path issues + suite ordering flake)
This commit is contained in:
parent
e88079e211
commit
fb1e51361f
|
|
@ -27,6 +27,7 @@
|
||||||
'type' => 'information',
|
'type' => 'information',
|
||||||
'service_id' => null,
|
'service_id' => null,
|
||||||
'expire_date' => '2026-03-16',
|
'expire_date' => '2026-03-16',
|
||||||
|
'uploaded_at' => '2026-03-14 10:00:00',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Slide expired yesterday (should NOT show)
|
// Slide expired yesterday (should NOT show)
|
||||||
|
|
@ -34,6 +35,7 @@
|
||||||
'type' => 'information',
|
'type' => 'information',
|
||||||
'service_id' => null,
|
'service_id' => null,
|
||||||
'expire_date' => '2026-03-14',
|
'expire_date' => '2026-03-14',
|
||||||
|
'uploaded_at' => '2026-03-14 10:00:00',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = $this->get(route('services.edit', $service));
|
$response = $this->get(route('services.edit', $service));
|
||||||
|
|
@ -57,6 +59,7 @@
|
||||||
'type' => 'information',
|
'type' => 'information',
|
||||||
'service_id' => null,
|
'service_id' => null,
|
||||||
'expire_date' => '2026-04-10',
|
'expire_date' => '2026-04-10',
|
||||||
|
'uploaded_at' => '2026-03-30 10:00:00',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Slide expires one day before service (should NOT show)
|
// Slide expires one day before service (should NOT show)
|
||||||
|
|
@ -64,6 +67,7 @@
|
||||||
'type' => 'information',
|
'type' => 'information',
|
||||||
'service_id' => null,
|
'service_id' => null,
|
||||||
'expire_date' => '2026-04-09',
|
'expire_date' => '2026-04-09',
|
||||||
|
'uploaded_at' => '2026-03-30 10:00:00',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = $this->get(route('services.edit', $service));
|
$response = $this->get(route('services.edit', $service));
|
||||||
|
|
@ -87,6 +91,7 @@
|
||||||
'type' => 'information',
|
'type' => 'information',
|
||||||
'service_id' => null,
|
'service_id' => null,
|
||||||
'expire_date' => '2026-03-15',
|
'expire_date' => '2026-03-15',
|
||||||
|
'uploaded_at' => '2026-02-28 10:00:00',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Global slide expiring 2026-03-25 — should appear in BOTH services
|
// Global slide expiring 2026-03-25 — should appear in BOTH services
|
||||||
|
|
@ -94,6 +99,7 @@
|
||||||
'type' => 'information',
|
'type' => 'information',
|
||||||
'service_id' => null,
|
'service_id' => null,
|
||||||
'expire_date' => '2026-03-25',
|
'expire_date' => '2026-03-25',
|
||||||
|
'uploaded_at' => '2026-02-28 10:00:00',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Service A: both slides should appear (both expire_date >= 2026-03-10)
|
// Service A: both slides should appear (both expire_date >= 2026-03-10)
|
||||||
|
|
@ -124,6 +130,7 @@
|
||||||
'type' => 'information',
|
'type' => 'information',
|
||||||
'service_id' => null,
|
'service_id' => null,
|
||||||
'expire_date' => '2026-03-20',
|
'expire_date' => '2026-03-20',
|
||||||
|
'uploaded_at' => '2026-02-28 10:00:00',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Soft-deleted slide
|
// Soft-deleted slide
|
||||||
|
|
@ -131,6 +138,7 @@
|
||||||
'type' => 'information',
|
'type' => 'information',
|
||||||
'service_id' => null,
|
'service_id' => null,
|
||||||
'expire_date' => '2026-03-20',
|
'expire_date' => '2026-03-20',
|
||||||
|
'uploaded_at' => '2026-02-28 10:00:00',
|
||||||
]);
|
]);
|
||||||
$deletedSlide->delete();
|
$deletedSlide->delete();
|
||||||
|
|
||||||
|
|
@ -154,6 +162,7 @@
|
||||||
'type' => 'information',
|
'type' => 'information',
|
||||||
'service_id' => null,
|
'service_id' => null,
|
||||||
'expire_date' => '2026-03-20',
|
'expire_date' => '2026-03-20',
|
||||||
|
'uploaded_at' => '2026-02-28 10:00:00',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Moderation slide (should NOT show)
|
// Moderation slide (should NOT show)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Models\Service;
|
use App\Models\Service;
|
||||||
|
use App\Models\ServiceAgendaItem;
|
||||||
use App\Models\Slide;
|
use App\Models\Slide;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
|
|
@ -133,3 +134,84 @@
|
||||||
|
|
||||||
expect($slide->expire_date)->toBeNull();
|
expect($slide->expire_date)->toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Moderation Slides — Agenda Item Association
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
test('moderation slides can be linked to agenda items', function () {
|
||||||
|
$service = Service::factory()->create();
|
||||||
|
$agendaItem = ServiceAgendaItem::factory()->create([
|
||||||
|
'service_id' => $service->id,
|
||||||
|
'title' => 'Hinweise',
|
||||||
|
'sort_order' => 1,
|
||||||
|
'is_before_event' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$slide = Slide::factory()->create([
|
||||||
|
'type' => 'moderation',
|
||||||
|
'service_id' => $service->id,
|
||||||
|
'service_agenda_item_id' => $agendaItem->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect($slide->serviceAgendaItem)->not->toBeNull();
|
||||||
|
expect($slide->serviceAgendaItem->id)->toBe($agendaItem->id);
|
||||||
|
expect($agendaItem->slides)->toHaveCount(1);
|
||||||
|
expect($agendaItem->slides->first()->id)->toBe($slide->id);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('moderation slides on agenda items are scoped per item', function () {
|
||||||
|
$service = Service::factory()->create();
|
||||||
|
$item1 = ServiceAgendaItem::factory()->create([
|
||||||
|
'service_id' => $service->id,
|
||||||
|
'title' => 'Hinweise',
|
||||||
|
'sort_order' => 1,
|
||||||
|
'is_before_event' => false,
|
||||||
|
]);
|
||||||
|
$item2 = ServiceAgendaItem::factory()->create([
|
||||||
|
'service_id' => $service->id,
|
||||||
|
'title' => 'Begrüßung',
|
||||||
|
'sort_order' => 2,
|
||||||
|
'is_before_event' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$slide1 = Slide::factory()->create([
|
||||||
|
'type' => 'moderation',
|
||||||
|
'service_id' => $service->id,
|
||||||
|
'service_agenda_item_id' => $item1->id,
|
||||||
|
]);
|
||||||
|
$slide2 = Slide::factory()->create([
|
||||||
|
'type' => 'moderation',
|
||||||
|
'service_id' => $service->id,
|
||||||
|
'service_agenda_item_id' => $item2->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect($item1->slides)->toHaveCount(1);
|
||||||
|
expect($item1->slides->first()->id)->toBe($slide1->id);
|
||||||
|
expect($item2->slides)->toHaveCount(1);
|
||||||
|
expect($item2->slides->first()->id)->toBe($slide2->id);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('legacy moderation slides without agenda item still work', function () {
|
||||||
|
$service = Service::factory()->create();
|
||||||
|
|
||||||
|
// Legacy slide: service_id set, no agenda item link
|
||||||
|
$slide = Slide::factory()->create([
|
||||||
|
'type' => 'moderation',
|
||||||
|
'service_id' => $service->id,
|
||||||
|
'service_agenda_item_id' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect($slide->service_agenda_item_id)->toBeNull();
|
||||||
|
expect($slide->serviceAgendaItem)->toBeNull();
|
||||||
|
|
||||||
|
// Still queryable via legacy filter
|
||||||
|
$legacySlides = Slide::where('type', 'moderation')
|
||||||
|
->where('service_id', $service->id)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
expect($legacySlides)->toHaveCount(1);
|
||||||
|
expect($legacySlides->first()->id)->toBe($slide->id);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Models\Service;
|
use App\Models\Service;
|
||||||
|
use App\Models\ServiceAgendaItem;
|
||||||
use App\Models\Slide;
|
use App\Models\Slide;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
|
|
@ -133,3 +134,84 @@
|
||||||
|
|
||||||
expect($slide->expire_date)->toBeNull();
|
expect($slide->expire_date)->toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Sermon Slides — Agenda Item Association
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
test('sermon slides can be linked to agenda items', function () {
|
||||||
|
$service = Service::factory()->create();
|
||||||
|
$agendaItem = ServiceAgendaItem::factory()->create([
|
||||||
|
'service_id' => $service->id,
|
||||||
|
'title' => 'Predigt: Hoffnung',
|
||||||
|
'sort_order' => 1,
|
||||||
|
'is_before_event' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$slide = Slide::factory()->create([
|
||||||
|
'type' => 'sermon',
|
||||||
|
'service_id' => $service->id,
|
||||||
|
'service_agenda_item_id' => $agendaItem->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect($slide->serviceAgendaItem)->not->toBeNull();
|
||||||
|
expect($slide->serviceAgendaItem->id)->toBe($agendaItem->id);
|
||||||
|
expect($agendaItem->slides)->toHaveCount(1);
|
||||||
|
expect($agendaItem->slides->first()->id)->toBe($slide->id);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('sermon slides on agenda items are scoped per item', function () {
|
||||||
|
$service = Service::factory()->create();
|
||||||
|
$item1 = ServiceAgendaItem::factory()->create([
|
||||||
|
'service_id' => $service->id,
|
||||||
|
'title' => 'Predigt Teil 1',
|
||||||
|
'sort_order' => 1,
|
||||||
|
'is_before_event' => false,
|
||||||
|
]);
|
||||||
|
$item2 = ServiceAgendaItem::factory()->create([
|
||||||
|
'service_id' => $service->id,
|
||||||
|
'title' => 'Predigt Teil 2',
|
||||||
|
'sort_order' => 2,
|
||||||
|
'is_before_event' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$slide1 = Slide::factory()->create([
|
||||||
|
'type' => 'sermon',
|
||||||
|
'service_id' => $service->id,
|
||||||
|
'service_agenda_item_id' => $item1->id,
|
||||||
|
]);
|
||||||
|
$slide2 = Slide::factory()->create([
|
||||||
|
'type' => 'sermon',
|
||||||
|
'service_id' => $service->id,
|
||||||
|
'service_agenda_item_id' => $item2->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect($item1->slides)->toHaveCount(1);
|
||||||
|
expect($item1->slides->first()->id)->toBe($slide1->id);
|
||||||
|
expect($item2->slides)->toHaveCount(1);
|
||||||
|
expect($item2->slides->first()->id)->toBe($slide2->id);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('legacy sermon slides without agenda item still work', function () {
|
||||||
|
$service = Service::factory()->create();
|
||||||
|
|
||||||
|
// Legacy slide: service_id set, no agenda item link
|
||||||
|
$slide = Slide::factory()->create([
|
||||||
|
'type' => 'sermon',
|
||||||
|
'service_id' => $service->id,
|
||||||
|
'service_agenda_item_id' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect($slide->service_agenda_item_id)->toBeNull();
|
||||||
|
expect($slide->serviceAgendaItem)->toBeNull();
|
||||||
|
|
||||||
|
// Still queryable via legacy filter
|
||||||
|
$legacySlides = Slide::where('type', 'sermon')
|
||||||
|
->where('service_id', $service->id)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
expect($legacySlides)->toHaveCount(1);
|
||||||
|
expect($legacySlides->first()->id)->toBe($slide->id);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -248,6 +248,7 @@ public function test_service_edit_seite_zeigt_service_mit_songs_und_slides(): vo
|
||||||
'service_id' => null,
|
'service_id' => null,
|
||||||
'type' => 'information',
|
'type' => 'information',
|
||||||
'expire_date' => Carbon::today()->addDays(14),
|
'expire_date' => Carbon::today()->addDays(14),
|
||||||
|
'uploaded_at' => Carbon::today()->subDays(2),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = $this->actingAs($user)->get(route('services.edit', $service));
|
$response = $this->actingAs($user)->get(route('services.edit', $service));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue