- Restructure field editor dialog: move Options section to bottom with divider and subheader, fix delete button with flex layout - Change tag_category (single string) to tag_categories (JSON array) supporting multiple category selection in tag picker fields - Portal tag picker now groups tags by category with subheaders - Add generic file upload endpoint (FileUploadService + UploadController) - Replace email branding logo URL text field with ImageUploadField - Update Partner crowd type default icon to tabler-affiliate - Apply changes consistently to both field and template dialogs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
333 lines
11 KiB
PHP
333 lines
11 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Feature\Api\V1;
|
|
|
|
use App\Models\CrowdType;
|
|
use App\Models\Event;
|
|
use App\Models\FestivalSection;
|
|
use App\Models\Organisation;
|
|
use App\Models\PersonTag;
|
|
use App\Models\RegistrationFormField;
|
|
use App\Models\TimeSlot;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class PublicRegistrationDataTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
private Organisation $organisation;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->organisation = Organisation::factory()->create();
|
|
}
|
|
|
|
public function test_returns_registration_data_for_open_event(): void
|
|
{
|
|
$event = Event::factory()->create([
|
|
'organisation_id' => $this->organisation->id,
|
|
'status' => 'registration_open',
|
|
'slug' => 'test-event-2026',
|
|
]);
|
|
|
|
$section = FestivalSection::factory()->create([
|
|
'event_id' => $event->id,
|
|
'type' => 'standard',
|
|
'show_in_registration' => true,
|
|
'registration_description' => 'Test description',
|
|
]);
|
|
|
|
FestivalSection::factory()->create([
|
|
'event_id' => $event->id,
|
|
'type' => 'cross_event',
|
|
'show_in_registration' => true,
|
|
]);
|
|
|
|
FestivalSection::factory()->create([
|
|
'event_id' => $event->id,
|
|
'type' => 'standard',
|
|
'show_in_registration' => false,
|
|
]);
|
|
|
|
$timeSlot = TimeSlot::factory()->create([
|
|
'event_id' => $event->id,
|
|
'person_type' => 'VOLUNTEER',
|
|
]);
|
|
|
|
TimeSlot::factory()->create([
|
|
'event_id' => $event->id,
|
|
'person_type' => 'CREW',
|
|
]);
|
|
|
|
$response = $this->getJson('/api/v1/public/events/test-event-2026/registration-data');
|
|
|
|
$response->assertOk()
|
|
->assertJsonPath('data.event.id', $event->id)
|
|
->assertJsonPath('data.event.name', $event->name)
|
|
->assertJsonCount(1, 'data.sections')
|
|
->assertJsonPath('data.sections.0.id', $section->id)
|
|
->assertJsonCount(1, 'data.time_slots')
|
|
->assertJsonPath('data.time_slots.0.id', $timeSlot->id);
|
|
}
|
|
|
|
public function test_returns_404_for_non_registration_open_event(): void
|
|
{
|
|
Event::factory()->create([
|
|
'organisation_id' => $this->organisation->id,
|
|
'status' => 'draft',
|
|
'slug' => 'draft-event',
|
|
]);
|
|
|
|
$response = $this->getJson('/api/v1/public/events/draft-event/registration-data');
|
|
|
|
$response->assertNotFound();
|
|
}
|
|
|
|
public function test_returns_404_for_nonexistent_slug(): void
|
|
{
|
|
$response = $this->getJson('/api/v1/public/events/does-not-exist/registration-data');
|
|
|
|
$response->assertNotFound();
|
|
}
|
|
|
|
public function test_includes_registration_description_in_sections(): void
|
|
{
|
|
$event = Event::factory()->create([
|
|
'organisation_id' => $this->organisation->id,
|
|
'status' => 'registration_open',
|
|
'slug' => 'desc-event',
|
|
]);
|
|
|
|
FestivalSection::factory()->create([
|
|
'event_id' => $event->id,
|
|
'type' => 'standard',
|
|
'show_in_registration' => true,
|
|
'registration_description' => 'Tap bier en drankjes',
|
|
]);
|
|
|
|
$response = $this->getJson('/api/v1/public/events/desc-event/registration-data');
|
|
|
|
$response->assertOk()
|
|
->assertJsonPath('data.sections.0.registration_description', 'Tap bier en drankjes');
|
|
}
|
|
|
|
public function test_excludes_sections_with_show_in_registration_false(): void
|
|
{
|
|
$event = Event::factory()->create([
|
|
'organisation_id' => $this->organisation->id,
|
|
'status' => 'registration_open',
|
|
'slug' => 'filter-event',
|
|
]);
|
|
|
|
FestivalSection::factory()->create([
|
|
'event_id' => $event->id,
|
|
'type' => 'standard',
|
|
'show_in_registration' => false,
|
|
]);
|
|
|
|
$response = $this->getJson('/api/v1/public/events/filter-event/registration-data');
|
|
|
|
$response->assertOk()
|
|
->assertJsonCount(0, 'data.sections');
|
|
}
|
|
|
|
public function test_festival_deduplicates_sections_by_name(): void
|
|
{
|
|
$festival = Event::factory()->festival()->create([
|
|
'organisation_id' => $this->organisation->id,
|
|
'status' => 'registration_open',
|
|
'slug' => 'dedup-festival',
|
|
]);
|
|
|
|
$sub1 = Event::factory()->subEvent($festival)->create(['status' => 'registration_open']);
|
|
$sub2 = Event::factory()->subEvent($festival)->create(['status' => 'registration_open']);
|
|
$sub3 = Event::factory()->subEvent($festival)->create(['status' => 'published']);
|
|
|
|
// Same section name across 3 sub-events
|
|
foreach ([$sub1, $sub2, $sub3] as $sub) {
|
|
FestivalSection::factory()->create([
|
|
'event_id' => $sub->id,
|
|
'name' => 'Hoofdpodium Bar',
|
|
'type' => 'standard',
|
|
'show_in_registration' => true,
|
|
'category' => 'Bar',
|
|
]);
|
|
}
|
|
|
|
TimeSlot::factory()->create(['event_id' => $sub1->id, 'person_type' => 'VOLUNTEER']);
|
|
|
|
$response = $this->getJson('/api/v1/public/events/dedup-festival/registration-data');
|
|
|
|
$response->assertOk()
|
|
->assertJsonCount(1, 'data.sections')
|
|
->assertJsonPath('data.sections.0.name', 'Hoofdpodium Bar');
|
|
}
|
|
|
|
public function test_festival_excludes_parent_operational_sections(): void
|
|
{
|
|
$festival = Event::factory()->festival()->create([
|
|
'organisation_id' => $this->organisation->id,
|
|
'status' => 'registration_open',
|
|
'slug' => 'parent-ops-festival',
|
|
]);
|
|
|
|
$sub = Event::factory()->subEvent($festival)->create(['status' => 'registration_open']);
|
|
|
|
// Parent operational section (should be excluded)
|
|
FestivalSection::factory()->create([
|
|
'event_id' => $festival->id,
|
|
'name' => 'Terreinploeg',
|
|
'type' => 'standard',
|
|
'show_in_registration' => true,
|
|
]);
|
|
|
|
// Sub-event section (should be included)
|
|
FestivalSection::factory()->create([
|
|
'event_id' => $sub->id,
|
|
'name' => 'Bar',
|
|
'type' => 'standard',
|
|
'show_in_registration' => true,
|
|
]);
|
|
|
|
TimeSlot::factory()->create(['event_id' => $sub->id, 'person_type' => 'VOLUNTEER']);
|
|
|
|
$response = $this->getJson('/api/v1/public/events/parent-ops-festival/registration-data');
|
|
|
|
$response->assertOk()
|
|
->assertJsonCount(1, 'data.sections')
|
|
->assertJsonPath('data.sections.0.name', 'Bar');
|
|
}
|
|
|
|
// ─── Registration Fields ───────────────────────────────────────────
|
|
|
|
public function test_registration_data_includes_registration_fields(): void
|
|
{
|
|
$event = Event::factory()->create([
|
|
'organisation_id' => $this->organisation->id,
|
|
'status' => 'registration_open',
|
|
'slug' => 'fields-event',
|
|
]);
|
|
|
|
$field = RegistrationFormField::factory()->selectField()->create([
|
|
'event_id' => $event->id,
|
|
'is_portal_visible' => true,
|
|
'is_admin_only' => false,
|
|
'sort_order' => 0,
|
|
]);
|
|
|
|
RegistrationFormField::factory()->textareaField()->create([
|
|
'event_id' => $event->id,
|
|
'is_portal_visible' => true,
|
|
'is_admin_only' => false,
|
|
'sort_order' => 1,
|
|
]);
|
|
|
|
$response = $this->getJson('/api/v1/public/events/fields-event/registration-data');
|
|
|
|
$response->assertOk()
|
|
->assertJsonCount(2, 'data.registration_fields')
|
|
->assertJsonPath('data.registration_fields.0.slug', $field->slug)
|
|
->assertJsonPath('data.registration_fields.0.field_type', 'select')
|
|
->assertJsonPath('data.registration_fields.0.is_required', false);
|
|
}
|
|
|
|
public function test_registration_data_excludes_admin_only_fields(): void
|
|
{
|
|
$event = Event::factory()->create([
|
|
'organisation_id' => $this->organisation->id,
|
|
'status' => 'registration_open',
|
|
'slug' => 'admin-fields-event',
|
|
]);
|
|
|
|
RegistrationFormField::factory()->create([
|
|
'event_id' => $event->id,
|
|
'label' => 'Public field',
|
|
'slug' => 'public-field',
|
|
'is_portal_visible' => true,
|
|
'is_admin_only' => false,
|
|
]);
|
|
|
|
// Admin-only field (should be excluded)
|
|
RegistrationFormField::factory()->create([
|
|
'event_id' => $event->id,
|
|
'label' => 'Admin only field',
|
|
'slug' => 'admin-only-field',
|
|
'is_portal_visible' => true,
|
|
'is_admin_only' => true,
|
|
]);
|
|
|
|
// Not portal visible (should be excluded)
|
|
RegistrationFormField::factory()->create([
|
|
'event_id' => $event->id,
|
|
'label' => 'Hidden field',
|
|
'slug' => 'hidden-field',
|
|
'is_portal_visible' => false,
|
|
'is_admin_only' => false,
|
|
]);
|
|
|
|
$response = $this->getJson('/api/v1/public/events/admin-fields-event/registration-data');
|
|
|
|
$response->assertOk()
|
|
->assertJsonCount(1, 'data.registration_fields')
|
|
->assertJsonPath('data.registration_fields.0.slug', 'public-field');
|
|
}
|
|
|
|
public function test_registration_data_includes_form_toggles(): void
|
|
{
|
|
$event = Event::factory()->create([
|
|
'organisation_id' => $this->organisation->id,
|
|
'status' => 'registration_open',
|
|
'slug' => 'toggles-event',
|
|
'registration_show_section_preferences' => true,
|
|
'registration_show_availability' => false,
|
|
]);
|
|
|
|
$response = $this->getJson('/api/v1/public/events/toggles-event/registration-data');
|
|
|
|
$response->assertOk()
|
|
->assertJsonPath('data.event.registration_show_section_preferences', true)
|
|
->assertJsonPath('data.event.registration_show_availability', false);
|
|
}
|
|
|
|
public function test_registration_data_includes_available_tags_for_tag_picker(): void
|
|
{
|
|
$event = Event::factory()->create([
|
|
'organisation_id' => $this->organisation->id,
|
|
'status' => 'registration_open',
|
|
'slug' => 'tags-event',
|
|
]);
|
|
|
|
$tag = PersonTag::factory()->create([
|
|
'organisation_id' => $this->organisation->id,
|
|
'name' => 'EHBO',
|
|
'category' => 'Certificaat',
|
|
'is_active' => true,
|
|
]);
|
|
|
|
PersonTag::factory()->create([
|
|
'organisation_id' => $this->organisation->id,
|
|
'name' => 'Barervaring',
|
|
'category' => 'Ervaring',
|
|
'is_active' => true,
|
|
]);
|
|
|
|
RegistrationFormField::factory()->tagPickerField()->create([
|
|
'event_id' => $event->id,
|
|
'tag_categories' => ['Certificaat'],
|
|
'is_portal_visible' => true,
|
|
'is_admin_only' => false,
|
|
]);
|
|
|
|
$response = $this->getJson('/api/v1/public/events/tags-event/registration-data');
|
|
|
|
$response->assertOk()
|
|
->assertJsonCount(1, 'data.registration_fields')
|
|
->assertJsonCount(1, 'data.registration_fields.0.available_tags')
|
|
->assertJsonPath('data.registration_fields.0.available_tags.0.name', 'EHBO');
|
|
}
|
|
}
|