🔥 Remove unused tests, update factories, and introduce recurrence features

- **Removed:** Unused feature and component tests to clean up the codebase.
- **Added:** `RecurrenceType` enum for handling event recurrence modes.
- **Introduced:** City, Country, and Meetup factories for test data generation.
- **Implemented:** Migration to support recurring event fields in `meetup_events` table.
- **Enhanced:** Livewire meetup events creation with recurrence validation and preview logic.
- **Updated:** PHPUnit test suite configuration and composer dependencies for `pestphp/pest@v4.3`.
- **Refined:** SEO configuration (`favicon`) to standardize icon format.
This commit is contained in:
HolgerHatGarKeineNode
2026-01-17 21:00:46 +01:00
parent 74263a4581
commit 7f92e77684
28 changed files with 632 additions and 473 deletions

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Enums;
enum RecurrenceType: string
{
case Daily = 'daily';
case Weekly = 'weekly';
case Monthly = 'monthly';
case Yearly = 'yearly';
case Custom = 'custom';
public function getLabel(): string
{
return match ($this) {
self::Daily => __('Täglich'),
self::Weekly => __('Wöchentlich'),
self::Monthly => __('Monatlich'),
self::Yearly => __('Jährlich'),
self::Custom => __('Benutzerdefiniert'),
};
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Models; namespace App\Models;
use App\Enums\RecurrenceType;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -26,14 +27,24 @@ class MeetupEvent extends Model
'id' => 'integer', 'id' => 'integer',
'meetup_id' => 'integer', 'meetup_id' => 'integer',
'start' => 'datetime', 'start' => 'datetime',
'recurrence_end_date' => 'datetime',
'attendees' => 'array', 'attendees' => 'array',
'might_attendees' => 'array', 'might_attendees' => 'array',
]; ];
/**
* The attributes that should be cast to enums.
*
* @var array
*/
protected $enumCasts = [
'recurrence_type' => RecurrenceType::class,
];
protected static function booted() protected static function booted()
{ {
static::creating(function ($model) { static::creating(function ($model) {
if (!$model->created_by) { if (! $model->created_by) {
$model->created_by = auth()->id(); $model->created_by = auth()->id();
} }
}); });

View File

@@ -58,7 +58,7 @@
"laravel/sail": "^1.43", "laravel/sail": "^1.43",
"mockery/mockery": "^1.6", "mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6", "nunomaduro/collision": "^8.6",
"pestphp/pest": "^3.8", "pestphp/pest": "^4.3",
"pestphp/pest-plugin-laravel": "^3.2" "pestphp/pest-plugin-laravel": "^3.2"
}, },
"autoload": { "autoload": {

View File

@@ -59,7 +59,7 @@ return [
* *
* You can use the following filetypes: ico, png, gif, jpeg, svg. * You can use the following filetypes: ico, png, gif, jpeg, svg.
*/ */
'favicon' => '/img/favicon.svg', 'favicon' => '/favicon.ico',
'title' => [ 'title' => [
/** /**

View File

@@ -0,0 +1,27 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\City>
*/
class CityFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->city(),
'country_id' => 1,
'longitude' => fake()->longitude(),
'latitude' => fake()->latitude(),
'created_by' => \App\Models\User::factory(),
];
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Country>
*/
class CountryFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->country(),
'code' => fake()->countryCode(),
'language_codes' => ['en'],
];
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Meetup>
*/
class MeetupFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$name = fake()->company();
return [
'name' => $name,
'slug' => \Illuminate\Support\Str::slug($name),
'github_data' => [],
'created_by' => \App\Models\User::factory(),
];
}
}

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('meetup_events', function (Blueprint $table) {
$table->string('recurrence_type')->nullable()->after('start');
$table->string('recurrence_day_of_week')->nullable()->after('recurrence_type');
$table->string('recurrence_day_position')->nullable()->after('recurrence_day_of_week');
$table->unsignedInteger('recurrence_interval')->default(1)->after('recurrence_day_position');
$table->dateTime('recurrence_end_date')->nullable()->after('recurrence_interval');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('meetup_events', function (Blueprint $table) {
$table->dropColumn([
'recurrence_type',
'recurrence_day_of_week',
'recurrence_day_position',
'recurrence_interval',
'recurrence_end_date',
]);
});
}
};

View File

@@ -11,6 +11,9 @@
<testsuite name="Feature"> <testsuite name="Feature">
<directory>tests/Feature</directory> <directory>tests/Feature</directory>
</testsuite> </testsuite>
<testsuite name="Components">
<directory suffix=".test.php">resources/views</directory>
</testsuite>
</testsuites> </testsuites>
<source> <source>
<include> <include>

View File

@@ -1,6 +1,7 @@
<?php <?php
use App\Attributes\SeoDataAttribute; use App\Attributes\SeoDataAttribute;
use App\Enums\RecurrenceType;
use App\Models\Meetup; use App\Models\Meetup;
use App\Models\MeetupEvent; use App\Models\MeetupEvent;
use App\Traits\SeoTrait; use App\Traits\SeoTrait;
@@ -20,9 +21,15 @@ class extends Component {
public string $startDate = ''; public string $startDate = '';
public string $startTime = ''; public string $startTime = '';
// Explicitly track timezone for reactivity
public string $userTimezone = '';
public bool $seriesMode = false; public bool $seriesMode = false;
public string $endDate = ''; public string $endDate = '';
public string $interval = 'monthly';
public ?RecurrenceType $recurrenceType = null;
public ?string $recurrenceDayOfWeek = null;
public ?string $recurrenceDayPosition = null;
public function getPreviewDatesProperty(): array public function getPreviewDatesProperty(): array
{ {
@@ -31,12 +38,44 @@ class extends Component {
} }
try { try {
$timezone = auth()->user()->timezone ?? 'Europe/Berlin'; // Ensure timezone is always set - use fallback if not initialized yet
$timezone = $this->userTimezone ?: (auth()->user()->timezone ?? 'Europe/Berlin');
$startDate = \Carbon\Carbon::createFromFormat('Y-m-d H:i', $this->startDate . ' ' . $this->startTime, $timezone); $startDate = \Carbon\Carbon::createFromFormat('Y-m-d H:i', $this->startDate . ' ' . $this->startTime, $timezone);
$endDate = \Carbon\Carbon::createFromFormat('Y-m-d', $this->endDate, $timezone); $endDate = \Carbon\Carbon::createFromFormat('Y-m-d', $this->endDate, $timezone);
// Use custom recurrence when dayOfWeek and dayPosition are set (e.g., "last Friday of month")
if ($this->recurrenceDayOfWeek && $this->recurrenceDayPosition) {
return $this->generateCustomRecurrenceDates($startDate, $endDate, $timezone, true);
}
// For weekly recurrence with a specific day of week (no position),
// shift start date to the next occurrence of that weekday
if ($this->recurrenceType === RecurrenceType::Weekly && $this->recurrenceDayOfWeek) {
$dayOfWeekNumber = $this->getDayOfWeekNumber($this->recurrenceDayOfWeek);
if ($dayOfWeekNumber !== null) {
$adjustedStartDate = $startDate->copy();
// Find the next occurrence of the specified weekday
while ($adjustedStartDate->dayOfWeek !== $dayOfWeekNumber) {
$adjustedStartDate->addDay();
}
// Generate weekly dates from the adjusted start
$dates = []; $dates = [];
$currentDate = $adjustedStartDate->copy();
while ($currentDate->lessThanOrEqualTo($endDate) && count($dates) < 100) {
$dates[] = [
'date' => $currentDate->copy(),
'formatted' => $currentDate->translatedFormat('l, d.m.Y'),
'time' => $currentDate->format('H:i'),
];
$currentDate->addWeek();
}
return $dates;
}
}
// Default: generate dates based on recurrence type
$currentDate = $startDate->copy(); $currentDate = $startDate->copy();
$dates = [];
while ($currentDate->lessThanOrEqualTo($endDate) && count($dates) < 100) { while ($currentDate->lessThanOrEqualTo($endDate) && count($dates) < 100) {
$dates[] = [ $dates[] = [
@@ -45,7 +84,7 @@ class extends Component {
'time' => $currentDate->format('H:i'), 'time' => $currentDate->format('H:i'),
]; ];
if ($this->interval === 'weekly') { if ($this->recurrenceType === RecurrenceType::Weekly) {
$currentDate->addWeek(); $currentDate->addWeek();
} else { } else {
$currentDate->addMonth(); $currentDate->addMonth();
@@ -58,6 +97,138 @@ class extends Component {
} }
} }
private function generateCustomRecurrenceDates(\Carbon\Carbon $startDate, \Carbon\Carbon $endDate, string $timezone, bool $formatted = false): array
{
$dates = [];
// Start from the beginning of the month containing startDate
$currentDate = $startDate->copy()->startOfMonth();
// Preserve the time from startDate for the occurrences
$time = $startDate->format('H:i:s');
while ($currentDate->lessThanOrEqualTo($endDate) && count($dates) < 100) {
$occurrenceDate = $this->findNextOccurrence($currentDate, $timezone);
if ($occurrenceDate && $occurrenceDate->lessThanOrEqualTo($endDate)) {
// Set the time from startDate, preserving the date
$occurrenceWithTime = $occurrenceDate->copy()->setTimeFrom($startDate);
// Only add if this is after or on the start date
if ($occurrenceWithTime->gte($startDate)) {
if ($formatted) {
$dates[] = [
'date' => $occurrenceWithTime,
'formatted' => $occurrenceWithTime->translatedFormat('l, d.m.Y'),
'time' => $time,
];
} else {
$dates[] = $occurrenceWithTime;
}
}
// Move to the next month
$currentDate = $currentDate->copy()->addMonth();
} else {
break;
}
}
return $dates;
}
private function findNextOccurrence(\Carbon\Carbon $currentDate, string $timezone): ?\Carbon\Carbon
{
if (!$this->recurrenceDayOfWeek || !$this->recurrenceDayPosition) {
return $currentDate;
}
$dayOfWeek = $this->getDayOfWeekNumber($this->recurrenceDayOfWeek);
$dayPosition = $this->getDayPositionNumber($this->recurrenceDayPosition);
if ($dayOfWeek === null || $dayPosition === null) {
return $currentDate;
}
// Find the Nth dayOfWeek in the current month
$date = $currentDate->copy()->startOfMonth();
if ($dayPosition === -1) {
return $date->lastOfMonth($dayOfWeek)->setTime($currentDate->hour, $currentDate->minute, $currentDate->second);
}
$count = 0;
while ($date->month === $currentDate->month) {
if ($date->dayOfWeek === $dayOfWeek) {
$count++;
if ($count === $dayPosition) {
return $date->copy()->setTime($currentDate->hour, $currentDate->minute, $currentDate->second);
}
}
$date->addDay();
}
// If we didn't find enough occurrences in this month, return null
return null;
}
private function getDayOfWeekNumber(string $day): ?int
{
return match (strtolower($day)) {
'monday', 'montag' => \Carbon\Carbon::MONDAY,
'tuesday', 'dienstag' => \Carbon\Carbon::TUESDAY,
'wednesday', 'mittwoch' => \Carbon\Carbon::WEDNESDAY,
'thursday', 'donnerstag' => \Carbon\Carbon::THURSDAY,
'friday', 'freitag' => \Carbon\Carbon::FRIDAY,
'saturday', 'samstag' => \Carbon\Carbon::SATURDAY,
'sunday', 'sonntag' => \Carbon\Carbon::SUNDAY,
default => null,
};
}
private function getDayPositionNumber(string $position): ?int
{
return match (strtolower($position)) {
'first', 'erster' => 1,
'second', 'zweiter' => 2,
'third', 'dritter' => 3,
'fourth', 'vierter' => 4,
'last', 'letzter' => -1,
default => null,
};
}
public function getRecurrenceTypesProperty(): array
{
return [
RecurrenceType::Weekly,
RecurrenceType::Monthly,
];
}
public function getDaysOfWeekProperty(): array
{
return [
'monday' => __('Montag'),
'tuesday' => __('Dienstag'),
'wednesday' => __('Mittwoch'),
'thursday' => __('Donnerstag'),
'friday' => __('Freitag'),
'saturday' => __('Samstag'),
'sunday' => __('Sonntag'),
];
}
public function getDayPositionsProperty(): array
{
return [
'first' => __('Erster'),
'second' => __('Zweiter'),
'third' => __('Dritter'),
'fourth' => __('Vierter'),
'last' => __('Letzter'),
];
}
#[Validate('required|string|max:255')] #[Validate('required|string|max:255')]
public ?string $location = null; public ?string $location = null;
@@ -70,7 +241,8 @@ class extends Component {
public function mount(): void public function mount(): void
{ {
$this->country = request()->route('country', config('app.domain_country')); $this->country = request()->route('country', config('app.domain_country'));
$timezone = auth()->user()->timezone ?? 'Europe/Berlin'; $this->userTimezone = auth()->user()->timezone ?? 'Europe/Berlin';
$timezone = $this->userTimezone;
if ($this->event) { if ($this->event) {
$localStart = $this->event->start->setTimezone($timezone); $localStart = $this->event->start->setTimezone($timezone);
@@ -79,12 +251,21 @@ class extends Component {
$this->location = $this->event->location; $this->location = $this->event->location;
$this->description = $this->event->description; $this->description = $this->event->description;
$this->link = $this->event->link; $this->link = $this->event->link;
if ($this->event->recurrence_type) {
$this->seriesMode = true;
$this->recurrenceType = $this->event->recurrence_type;
$this->recurrenceDayOfWeek = $this->event->recurrence_day_of_week;
$this->recurrenceDayPosition = $this->event->recurrence_day_position;
$this->endDate = $this->event->recurrence_end_date ? $this->event->recurrence_end_date->format('Y-m-d') : '';
}
} else { } else {
// Set default start time to next Monday at 19:00 in user's timezone // Set default start time to next Monday at 19:00 in user's timezone
$defaultStart = now($timezone)->next('Monday')->setTime(19, 0); $defaultStart = now($timezone)->next('Monday')->setTime(19, 0);
$this->startDate = $defaultStart->format('Y-m-d'); $this->startDate = $defaultStart->format('Y-m-d');
$this->startTime = $defaultStart->format('H:i'); $this->startTime = $defaultStart->format('H:i');
$this->endDate = $defaultStart->copy()->addMonths(6)->format('Y-m-d'); $this->endDate = $defaultStart->copy()->addMonths(6)->format('Y-m-d');
$this->recurrenceType = RecurrenceType::Weekly;
} }
} }
@@ -100,12 +281,12 @@ class extends Component {
if ($this->seriesMode) { if ($this->seriesMode) {
$validationRules['endDate'] = 'required|date|after:startDate'; $validationRules['endDate'] = 'required|date|after:startDate';
$validationRules['interval'] = 'required|in:weekly,monthly'; $validationRules['recurrenceType'] = 'required';
} }
$this->validate($validationRules); $this->validate($validationRules);
$timezone = auth()->user()->timezone ?? 'Europe/Berlin'; $timezone = $this->userTimezone;
if ($this->seriesMode && !$this->event) { if ($this->seriesMode && !$this->event) {
// Create series of events // Create series of events
@@ -153,11 +334,12 @@ class extends Component {
$startDate = \Carbon\Carbon::createFromFormat('Y-m-d H:i', $this->startDate . ' ' . $this->startTime, $timezone); $startDate = \Carbon\Carbon::createFromFormat('Y-m-d H:i', $this->startDate . ' ' . $this->startTime, $timezone);
$endDate = \Carbon\Carbon::createFromFormat('Y-m-d', $this->endDate, $timezone); $endDate = \Carbon\Carbon::createFromFormat('Y-m-d', $this->endDate, $timezone);
$currentDate = $startDate->copy();
$eventsCreated = 0; $eventsCreated = 0;
while ($currentDate->lessThanOrEqualTo($endDate)) { $dates = $this->generateEventDates($startDate, $endDate, $timezone);
$utcDateTime = $currentDate->copy()->setTimezone('UTC');
foreach ($dates as $date) {
$utcDateTime = $date->copy()->setTimezone('UTC');
$this->meetup->meetupEvents()->create([ $this->meetup->meetupEvents()->create([
'start' => $utcDateTime, 'start' => $utcDateTime,
@@ -170,16 +352,52 @@ class extends Component {
]); ]);
$eventsCreated++; $eventsCreated++;
}
// Move to next date based on interval session()->flash('status', __(':count Events erfolgreich erstellt!', ['count' => $eventsCreated]));
if ($this->interval === 'weekly') { }
private function generateEventDates(\Carbon\Carbon $startDate, \Carbon\Carbon $endDate, string $timezone): array
{
// Use custom recurrence when dayOfWeek and dayPosition are set (e.g., "last Friday of month")
if ($this->recurrenceDayOfWeek && $this->recurrenceDayPosition) {
return $this->generateCustomRecurrenceDates($startDate, $endDate, $timezone);
}
// For weekly recurrence with a specific day of week (no position),
// shift start date to the next occurrence of that weekday
if ($this->recurrenceType === RecurrenceType::Weekly && $this->recurrenceDayOfWeek) {
$dayOfWeekNumber = $this->getDayOfWeekNumber($this->recurrenceDayOfWeek);
if ($dayOfWeekNumber !== null) {
$adjustedStartDate = $startDate->copy();
while ($adjustedStartDate->dayOfWeek !== $dayOfWeekNumber) {
$adjustedStartDate->addDay();
}
$dates = [];
$currentDate = $adjustedStartDate->copy();
while ($currentDate->lessThanOrEqualTo($endDate)) {
$dates[] = $currentDate->copy();
$currentDate->addWeek();
}
return $dates;
}
}
// Default: generate dates based on recurrence type
$dates = [];
$currentDate = $startDate->copy();
while ($currentDate->lessThanOrEqualTo($endDate)) {
$dates[] = $currentDate->copy();
if ($this->recurrenceType === RecurrenceType::Weekly) {
$currentDate->addWeek(); $currentDate->addWeek();
} else { } else {
$currentDate->addMonth(); $currentDate->addMonth();
} }
} }
session()->flash('status', __(':count Events erfolgreich erstellt!', ['count' => $eventsCreated])); return $dates;
} }
public function delete(): void public function delete(): void
@@ -217,15 +435,15 @@ class extends Component {
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6"> <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<flux:field> <flux:field>
<flux:label>{{ $seriesMode ? __('Startdatum') : __('Datum') }} <span class="text-red-500">*</span></flux:label> <flux:label>{{ $seriesMode ? __('Startdatum') : __('Datum') }} <span class="text-red-500">*</span></flux:label>
<flux:date-picker min="today" wire:model="startDate" required locale="{{ session('lang_country', 'de-DE') }}"/> <flux:date-picker :clearable="false" min="today" wire:model.live="startDate" required locale="{{ session('lang_country', 'de-DE') }}"/>
<flux:description>{{ $seriesMode ? __('Datum des ersten Termins') : __('An welchem Tag findet das Event statt?') }}</flux:description> <flux:description>{{ $seriesMode ? __('Datum des ersten Termins') : __('An welchem Tag findet das Event statt?') }}</flux:description>
<flux:error name="startDate"/> <flux:error name="startDate"/>
</flux:field> </flux:field>
<flux:field> <flux:field>
<flux:label>{{ __('Uhrzeit') }} <span class="text-red-500">*</span></flux:label> <flux:label>{{ __('Uhrzeit') }} <span class="text-red-500">*</span></flux:label>
<flux:time-picker wire:model="startTime" required locale="{{ session('lang_country', 'de-DE') }}"/> <flux:time-picker :clearable="false" wire:model="startTime" required locale="{{ session('lang_country', 'de-DE') }}"/>
<flux:description>{{ __('Um wie viel Uhr startet das Event?') }} ({{ auth()->user()->timezone ?? 'Europe/Berlin' }})</flux:description> <flux:description>{{ __('Um wie viel Uhr startet das Event?') }} ({{ $this->userTimezone }})</flux:description>
<flux:error name="startTime"/> <flux:error name="startTime"/>
</flux:field> </flux:field>
</div> </div>
@@ -234,21 +452,57 @@ class extends Component {
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6"> <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<flux:field> <flux:field>
<flux:label>{{ __('Enddatum') }} <span class="text-red-500">*</span></flux:label> <flux:label>{{ __('Enddatum') }} <span class="text-red-500">*</span></flux:label>
<flux:date-picker min="today" wire:model.live="endDate" required locale="{{ session('lang_country', 'de-DE') }}"/> <flux:date-picker :clearable="false" min="today" wire:model.live="endDate" required locale="{{ session('lang_country', 'de-DE') }}"/>
<flux:description>{{ __('Datum des letzten Termins') }}</flux:description> <flux:description>{{ __('Datum des letzten Termins') }}</flux:description>
<flux:error name="endDate"/> <flux:error name="endDate"/>
</flux:field> </flux:field>
<flux:field> <flux:field>
<flux:label>{{ __('Intervall') }} <span class="text-red-500">*</span></flux:label> <flux:label>{{ __('Wiederholungstyp') }} <span class="text-red-500">*</span></flux:label>
<flux:select wire:model.live="interval" required> <flux:select wire:model.live="recurrenceType" required>
<option value="monthly">{{ __('Monatlich') }}</option> @foreach($this->recurrenceTypes as $type)
<option value="weekly">{{ __('Wöchentlich') }}</option> <flux:select.option value="{{ $type->value }}">{{ $type->getLabel() }}</flux:select.option>
@endforeach
</flux:select> </flux:select>
<flux:description>{{ __('Wie oft soll das Event wiederholt werden?') }}</flux:description> <flux:description>{{ __('Wie oft soll das Event wiederholt werden?') }}</flux:description>
<flux:error name="interval"/> <flux:error name="recurrenceType"/>
</flux:field> </flux:field>
</div> </div>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<flux:field>
<flux:label>{{ __('Wochentag') }}</flux:label>
<flux:select wire:model.live="recurrenceDayOfWeek">
<flux:select.option value="">{{ __('Automatisch (wie Startdatum)') }}</flux:select.option>
@foreach($this->daysOfWeek as $key => $label)
<flux:select.option value="{{ $key }}">{{ $label }}</flux:select.option>
@endforeach
</flux:select>
<flux:description>{{ __('An welchem Wochentag soll das Event stattfinden?') }}</flux:description>
<flux:error name="recurrenceDayOfWeek"/>
</flux:field>
<flux:field>
<flux:label>{{ __('Position im Monat') }}</flux:label>
<flux:select wire:model.live="recurrenceDayPosition">
<flux:select.option value="">{{ __('Automatisch (gleiches Datum)') }}</flux:select.option>
@foreach($this->dayPositions as $key => $label)
<flux:select.option value="{{ $key }}">{{ $label }}</flux:select.option>
@endforeach
</flux:select>
<flux:description>{{ __('Welcher Wochentag im Monat? (z.B. "letzter Freitag")') }}</flux:description>
<flux:error name="recurrenceDayPosition"/>
</flux:field>
</div>
<flux:field>
<flux:text class="text-sm text-zinc-600 dark:text-zinc-400">
{{ __('Für regelmäßige Termine wie "immer am letzten Freitag des Monats":') }}<br>
{{ __('Wiederholungstyp: Monatlich') }}<br>
{{ __('Wochentag: Freitag') }}<br>
{{ __('Position im Monat: Letzter') }}
</flux:text>
</flux:field>
@endif @endif
<flux:field> <flux:field>
@@ -287,7 +541,7 @@ class extends Component {
@foreach($this->previewDates as $index => $dateInfo) @foreach($this->previewDates as $index => $dateInfo)
<flux:card class="bg-zinc-50 dark:bg-zinc-800/50"> <flux:card class="bg-zinc-50 dark:bg-zinc-800/50">
<div class="flex items-start gap-3"> <div class="flex items-start gap-3">
<div class="flex-shrink-0 w-10 h-10 rounded-full bg-zinc-200 dark:bg-zinc-700 flex items-center justify-center"> <div class="shrink-0 w-10 h-10 rounded-full bg-zinc-200 dark:bg-zinc-700 flex items-center justify-center">
<flux:text class="font-semibold text-sm">{{ $index + 1 }}</flux:text> <flux:text class="font-semibold text-sm">{{ $index + 1 }}</flux:text>
</div> </div>
<div class="flex-1 min-w-0"> <div class="flex-1 min-w-0">
@@ -346,7 +600,7 @@ class extends Component {
</form> </form>
<!-- Confirmation Modal for Series --> <!-- Confirmation Modal for Series -->
<flux:modal name="confirm-series" class="min-w-[22rem]"> <flux:modal name="confirm-series" class="min-w-88">
<div class="space-y-6"> <div class="space-y-6">
<div> <div>
<flux:heading size="lg">{{ __('Serientermine erstellen?') }}</flux:heading> <flux:heading size="lg">{{ __('Serientermine erstellen?') }}</flux:heading>

View File

@@ -1,48 +0,0 @@
<?php
use App\Models\User;
use Livewire\Volt\Volt as LivewireVolt;
test('login screen can be rendered', function () {
$response = $this->get('/login');
$response->assertStatus(200);
});
test('users can authenticate using the login screen', function () {
$user = User::factory()->create();
$response = LivewireVolt::test('auth.login')
->set('email', $user->email)
->set('password', 'password')
->call('login');
$response
->assertHasNoErrors()
->assertRedirect(route('dashboard', absolute: false));
$this->assertAuthenticated();
});
test('users can not authenticate with invalid password', function () {
$user = User::factory()->create();
$response = LivewireVolt::test('auth.login')
->set('email', $user->email)
->set('password', 'wrong-password')
->call('login');
$response->assertHasErrors('email');
$this->assertGuest();
});
test('users can logout', function () {
$user = User::factory()->create();
$response = $this->actingAs($user)->post('/logout');
$response->assertRedirect('/');
$this->assertGuest();
});

View File

@@ -1,47 +0,0 @@
<?php
use App\Models\User;
use Illuminate\Auth\Events\Verified;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\URL;
test('email verification screen can be rendered', function () {
$user = User::factory()->unverified()->create();
$response = $this->actingAs($user)->get('/verify-email');
$response->assertStatus(200);
});
test('email can be verified', function () {
$user = User::factory()->unverified()->create();
Event::fake();
$verificationUrl = URL::temporarySignedRoute(
'verification.verify',
now()->addMinutes(60),
['id' => $user->id, 'hash' => sha1($user->email)]
);
$response = $this->actingAs($user)->get($verificationUrl);
Event::assertDispatched(Verified::class);
expect($user->fresh()->hasVerifiedEmail())->toBeTrue();
$response->assertRedirect(route('dashboard', absolute: false).'?verified=1');
});
test('email is not verified with invalid hash', function () {
$user = User::factory()->unverified()->create();
$verificationUrl = URL::temporarySignedRoute(
'verification.verify',
now()->addMinutes(60),
['id' => $user->id, 'hash' => sha1('wrong-email')]
);
$this->actingAs($user)->get($verificationUrl);
expect($user->fresh()->hasVerifiedEmail())->toBeFalse();
});

View File

@@ -1,38 +0,0 @@
<?php
use App\Models\User;
use Livewire\Volt\Volt;
test('confirm password screen can be rendered', function () {
$user = User::factory()->create();
$response = $this->actingAs($user)->get('/confirm-password');
$response->assertStatus(200);
});
test('password can be confirmed', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = Volt::test('auth.confirm-password')
->set('password', 'password')
->call('confirmPassword');
$response
->assertHasNoErrors()
->assertRedirect(route('dashboard', absolute: false));
});
test('password is not confirmed with invalid password', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = Volt::test('auth.confirm-password')
->set('password', 'wrong-password')
->call('confirmPassword');
$response->assertHasErrors(['password']);
});

View File

@@ -1,66 +0,0 @@
<?php
use App\Models\User;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Support\Facades\Notification;
use Livewire\Volt\Volt;
test('reset password link screen can be rendered', function () {
$response = $this->get('/forgot-password');
$response->assertStatus(200);
});
test('reset password link can be requested', function () {
Notification::fake();
$user = User::factory()->create();
Volt::test('auth.forgot-password')
->set('email', $user->email)
->call('sendPasswordResetLink');
Notification::assertSentTo($user, ResetPassword::class);
});
test('reset password screen can be rendered', function () {
Notification::fake();
$user = User::factory()->create();
Volt::test('auth.forgot-password')
->set('email', $user->email)
->call('sendPasswordResetLink');
Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
$response = $this->get('/reset-password/'.$notification->token);
$response->assertStatus(200);
return true;
});
});
test('password can be reset with valid token', function () {
Notification::fake();
$user = User::factory()->create();
Volt::test('auth.forgot-password')
->set('email', $user->email)
->call('sendPasswordResetLink');
Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
$response = Volt::test('auth.reset-password', ['token' => $notification->token])
->set('email', $user->email)
->set('password', 'password')
->set('password_confirmation', 'password')
->call('resetPassword');
$response
->assertHasNoErrors()
->assertRedirect(route('login', absolute: false));
return true;
});
});

View File

@@ -1,24 +0,0 @@
<?php
use Livewire\Volt\Volt;
test('registration screen can be rendered', function () {
$response = $this->get('/register');
$response->assertStatus(200);
});
test('new users can register', function () {
$response = Volt::test('auth.register')
->set('name', 'Test User')
->set('email', 'test@example.com')
->set('password', 'password')
->set('password_confirmation', 'password')
->call('register');
$response
->assertHasNoErrors()
->assertRedirect(route('dashboard', absolute: false));
$this->assertAuthenticated();
});

View File

@@ -0,0 +1,195 @@
<?php
use App\Enums\RecurrenceType;
use App\Models\City;
use App\Models\Country;
use App\Models\Meetup;
use App\Models\User;
use Livewire\Livewire;
use function Pest\Laravel\assertDatabaseCount;
beforeEach(function () {
$this->user = User::factory()->create(['timezone' => 'Europe/Berlin']);
$this->country = Country::factory()->create();
$this->city = City::factory()->for($this->country)->create();
$this->meetup = Meetup::factory()->for($this->city)->create();
});
it('creates a weekly recurring series of events', function () {
Livewire::actingAs($this->user)
->test('meetups.create-edit-events', ['meetup' => $this->meetup])
->set('seriesMode', true)
->set('startDate', '2026-01-19')
->set('startTime', '19:00')
->set('endDate', '2026-02-14')
->set('recurrenceType', RecurrenceType::Weekly)
->set('location', 'Test Location')
->set('description', 'Test Description')
->set('link', 'https://example.com')
->call('save')
->assertHasNoErrors();
assertDatabaseCount('meetup_events', 4);
});
it('creates a monthly recurring series of events', function () {
Livewire::actingAs($this->user)
->test('meetups.create-edit-events', ['meetup' => $this->meetup])
->set('seriesMode', true)
->set('startDate', '2026-01-19')
->set('startTime', '19:00')
->set('endDate', '2026-03-31')
->set('recurrenceType', RecurrenceType::Monthly)
->set('location', 'Test Location')
->set('description', 'Test Description')
->set('link', 'https://example.com')
->call('save')
->assertHasNoErrors();
assertDatabaseCount('meetup_events', 3);
});
it('creates a series for last Friday of each month', function () {
Livewire::actingAs($this->user)
->test('meetups.create-edit-events', ['meetup' => $this->meetup])
->set('seriesMode', true)
->set('startDate', '2026-01-01')
->set('startTime', '19:00')
->set('endDate', '2026-03-31')
->set('recurrenceType', RecurrenceType::Monthly)
->set('recurrenceDayOfWeek', 'friday')
->set('recurrenceDayPosition', 'last')
->set('location', 'Test Location')
->set('description', 'Test Description')
->set('link', 'https://example.com')
->call('save')
->assertHasNoErrors();
assertDatabaseCount('meetup_events', 3);
$events = $this->meetup->meetupEvents()->get();
expect($events[0]->start->format('Y-m-d'))->toBe('2026-01-30')
->and($events[1]->start->format('Y-m-d'))->toBe('2026-02-27')
->and($events[2]->start->format('Y-m-d'))->toBe('2026-03-27');
});
it('creates a series for first Monday of each month', function () {
Livewire::actingAs($this->user)
->test('meetups.create-edit-events', ['meetup' => $this->meetup])
->set('seriesMode', true)
->set('startDate', '2026-01-01')
->set('startTime', '19:00')
->set('endDate', '2026-03-31')
->set('recurrenceType', RecurrenceType::Monthly)
->set('recurrenceDayOfWeek', 'monday')
->set('recurrenceDayPosition', 'first')
->set('location', 'Test Location')
->set('description', 'Test Description')
->set('link', 'https://example.com')
->call('save')
->assertHasNoErrors();
assertDatabaseCount('meetup_events', 3);
$events = $this->meetup->meetupEvents()->get();
expect($events[0]->start->format('Y-m-d'))->toBe('2026-01-05')
->and($events[1]->start->format('Y-m-d'))->toBe('2026-02-02')
->and($events[2]->start->format('Y-m-d'))->toBe('2026-03-02');
});
it('creates first Friday series when start date is Saturday', function () {
Livewire::actingAs($this->user)
->test('meetups.create-edit-events', ['meetup' => $this->meetup])
->set('seriesMode', true)
->set('startDate', '2026-01-17') // Saturday
->set('startTime', '19:00')
->set('endDate', '2026-04-30')
->set('recurrenceType', RecurrenceType::Monthly)
->set('recurrenceDayOfWeek', 'friday')
->set('recurrenceDayPosition', 'first')
->set('location', 'Test Location')
->set('description', 'Test Description')
->set('link', 'https://example.com')
->call('save')
->assertHasNoErrors();
assertDatabaseCount('meetup_events', 3);
$events = $this->meetup->meetupEvents()->get();
expect($events[0]->start->format('Y-m-d'))->toBe('2026-02-06')
->and($events[1]->start->format('Y-m-d'))->toBe('2026-03-06')
->and($events[2]->start->format('Y-m-d'))->toBe('2026-04-03');
});
it('updates preview when recurrenceDayOfWeek is changed for weekly recurrence', function () {
$component = Livewire::actingAs($this->user)
->test('meetups.create-edit-events', ['meetup' => $this->meetup])
->set('seriesMode', true)
->set('startDate', '2026-01-19') // Monday
->set('startTime', '19:00')
->set('endDate', '2026-02-28')
->set('recurrenceType', RecurrenceType::Weekly)
->set('recurrenceDayOfWeek', 'tuesday') // Change to Tuesday
->set('location', 'Test Location')
->set('description', 'Test Description')
->set('link', 'https://example.com');
$preview = $component->get('previewDates');
expect($preview)->toHaveCount(6)
->and($preview[0]['formatted'])->toBe('Dienstag, 20.01.2026')
->and($preview[1]['formatted'])->toBe('Dienstag, 27.01.2026')
->and($preview[2]['formatted'])->toBe('Dienstag, 03.02.2026')
->and($preview[3]['formatted'])->toBe('Dienstag, 10.02.2026')
->and($preview[4]['formatted'])->toBe('Dienstag, 17.02.2026')
->and($preview[5]['formatted'])->toBe('Dienstag, 24.02.2026');
});
it('validates required fields when creating a series', function () {
Livewire::actingAs($this->user)
->test('meetups.create-edit-events', ['meetup' => $this->meetup])
->set('seriesMode', true)
->set('startDate', '')
->set('startTime', '')
->set('endDate', '')
->set('recurrenceType', null)
->set('location', '')
->set('description', '')
->set('link', '')
->call('save')
->assertHasErrors([
'startDate',
'startTime',
'endDate',
'recurrenceType',
'location',
'description',
'link',
]);
});
it('shows correct preview for first Friday when start date is Saturday', function () {
$component = Livewire::actingAs($this->user)
->test('meetups.create-edit-events', ['meetup' => $this->meetup])
->set('seriesMode', true)
->set('startDate', '2026-01-17') // Saturday
->set('startTime', '19:00')
->set('endDate', '2026-04-30')
->set('recurrenceType', RecurrenceType::Monthly)
->set('recurrenceDayOfWeek', 'friday')
->set('recurrenceDayPosition', 'first')
->set('location', 'Test Location')
->set('description', 'Test Description')
->set('link', 'https://example.com');
$preview = $component->get('previewDates');
expect($preview)->toHaveCount(3)
->and($preview[0]['formatted'])->toBe('Freitag, 06.02.2026')
->and($preview[1]['formatted'])->toBe('Freitag, 06.03.2026')
->and($preview[2]['formatted'])->toBe('Freitag, 03.04.2026');
});

View File

@@ -1,16 +0,0 @@
<?php
use App\Models\User;
test('guests are redirected to the login page', function () {
$response = $this->get('/dashboard');
$response->assertRedirect('/login');
});
test('authenticated users can visit the dashboard', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = $this->get('/dashboard');
$response->assertStatus(200);
});

View File

@@ -1,7 +0,0 @@
<?php
test('returns a successful response', function () {
$response = $this->get('/');
$response->assertStatus(200);
});

View File

@@ -1,9 +0,0 @@
<?php
use Livewire\Volt\Volt;
it('can render', function () {
$component = Volt::test('country.chooser');
$component->assertSee('');
});

View File

@@ -1,9 +0,0 @@
<?php
use Livewire\Volt\Volt;
it('can render', function () {
$component = Volt::test('meetup.index');
$component->assertSee('');
});

View File

@@ -1,9 +0,0 @@
<?php
use Livewire\Volt\Volt;
it('can render', function () {
$component = Volt::test('meetups.edit');
$component->assertSee('');
});

View File

@@ -1,9 +0,0 @@
<?php
use Livewire\Volt\Volt;
it('can render', function () {
$component = Volt::test('meetups.map');
$component->assertSee('');
});

View File

@@ -1,25 +0,0 @@
<?php
declare(strict_types=1);
use App\Enums\SelfHostedServiceType;
use App\Models\SelfHostedService;
use App\Models\User;
use Livewire\Volt\Volt;
it('creates a self hosted service', function () {
$user = User::factory()->create();
$component = Volt::test('services.create')
->actingAs($user)
->set('name', 'My Node')
->set('type', SelfHostedServiceType::Mempool->value)
->set('url_clearnet', 'https://example.com')
->set('contact', ['url' => 'https://contact.example.com'])
->call('save');
expect(SelfHostedService::where('name', 'My Node')->exists())->toBeTrue();
$service = SelfHostedService::where('name', 'My Node')->first();
expect($service->getFirstMedia('logo'))->toBeNull();
});

View File

@@ -1,15 +0,0 @@
<?php
declare(strict_types=1);
use App\Models\SelfHostedService;
use Livewire\Volt\Volt;
it('renders services index', function () {
SelfHostedService::factory()->count(2)->create();
$component = Volt::test('services.index');
$component->assertStatus(200)
->assertSee('Self Hosted Services');
});

View File

@@ -1,9 +0,0 @@
<?php
use Livewire\Volt\Volt;
it('can render', function () {
$component = Volt::test('welcome');
$component->assertSee('');
});

View File

@@ -1,39 +0,0 @@
<?php
use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Livewire\Volt\Volt;
test('password can be updated', function () {
$user = User::factory()->create([
'password' => Hash::make('password'),
]);
$this->actingAs($user);
$response = Volt::test('settings.password')
->set('current_password', 'password')
->set('password', 'new-password')
->set('password_confirmation', 'new-password')
->call('updatePassword');
$response->assertHasNoErrors();
expect(Hash::check('new-password', $user->refresh()->password))->toBeTrue();
});
test('correct password must be provided to update password', function () {
$user = User::factory()->create([
'password' => Hash::make('password'),
]);
$this->actingAs($user);
$response = Volt::test('settings.password')
->set('current_password', 'wrong-password')
->set('password', 'new-password')
->set('password_confirmation', 'new-password')
->call('updatePassword');
$response->assertHasErrors(['current_password']);
});

View File

@@ -1,75 +0,0 @@
<?php
use App\Models\User;
use Livewire\Volt\Volt;
test('profile page is displayed', function () {
$this->actingAs($user = User::factory()->create());
$this->get('/settings/profile')->assertOk();
});
test('profile information can be updated', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = Volt::test('settings.profile')
->set('name', 'Test User')
->set('email', 'test@example.com')
->call('updateProfileInformation');
$response->assertHasNoErrors();
$user->refresh();
expect($user->name)->toEqual('Test User');
expect($user->email)->toEqual('test@example.com');
expect($user->email_verified_at)->toBeNull();
});
test('email verification status is unchanged when email address is unchanged', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = Volt::test('settings.profile')
->set('name', 'Test User')
->set('email', $user->email)
->call('updateProfileInformation');
$response->assertHasNoErrors();
expect($user->refresh()->email_verified_at)->not->toBeNull();
});
test('user can delete their account', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = Volt::test('settings.delete-user-form')
->set('password', 'password')
->call('deleteUser');
$response
->assertHasNoErrors()
->assertRedirect('/');
expect($user->fresh())->toBeNull();
expect(auth()->check())->toBeFalse();
});
test('correct password must be provided to delete account', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = Volt::test('settings.delete-user-form')
->set('password', 'wrong-password')
->call('deleteUser');
$response->assertHasErrors(['password']);
expect($user->fresh())->not->toBeNull();
});

View File

@@ -13,7 +13,7 @@
pest()->extend(Tests\TestCase::class) pest()->extend(Tests\TestCase::class)
->use(Illuminate\Foundation\Testing\RefreshDatabase::class) ->use(Illuminate\Foundation\Testing\RefreshDatabase::class)
->in('Feature'); ->in('Feature', '../resources/views');
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------