Files
einundzwanzig-app/tests/Feature/Livewire/MeetupMountTest.php
T
HolgerHatGarKeineNode bf9654de87 🔄 **Refactor and extend meetup membership-based authorization**
- Updated `authorizeAccess` to restrict `meetups.edit` views and updates to users in "My-Meetups".
- Attached creators to `meetup_user` pivot for default membership.
- Adjusted related tests to validate membership-based edit permissions.

📱 **Improve sidebar and mobile navigation accessibility**
- Added `aria-labels` to improve screen reader support for sidebar and mobile header elements.
- Updated desktop and mobile user menus alignment for consistency.

 **Enhance Lightning login flow**
- Introduced `lightningLoginInProgress` for smoother polling synchronization with the redirect flow.
- Updated logic to dispatch `lightning-login-ready` event instead of immediate redirect, avoiding race conditions.
2026-05-17 17:28:17 +02:00

108 lines
3.7 KiB
PHP

<?php
use App\Models\City;
use App\Models\Country;
use App\Models\Meetup;
use App\Models\MeetupEvent;
use App\Models\User;
use Livewire\Livewire;
beforeEach(function () {
$this->country = Country::factory()->create(['code' => 'de']);
$this->city = City::factory()->create(['country_id' => $this->country->id]);
$this->meetup = Meetup::factory()->create(['city_id' => $this->city->id]);
$this->event = MeetupEvent::factory()->create(['meetup_id' => $this->meetup->id]);
});
it('mounts meetups.landingpage with a meetup', function () {
Livewire::test('meetups.landingpage', ['meetup' => $this->meetup])->assertStatus(200);
});
it('mounts meetups.landingpage-event with meetup and event', function () {
Livewire::test('meetups.landingpage-event', [
'meetup' => $this->meetup,
'event' => $this->event,
])->assertStatus(200);
});
it('mounts meetups.create when authenticated', function () {
actingAsUser();
Livewire::test('meetups.create')->assertStatus(200);
});
it('mounts meetups.edit when the authenticated user has added the meetup to My-Meetups', function () {
$owner = actingAsUser();
$meetup = Meetup::factory()->create(['city_id' => $this->city->id]);
$meetup->users()->attach($owner);
Livewire::test('meetups.edit', ['meetup' => $meetup])->assertStatus(200);
});
it('mounts meetups.edit for a My-Meetups member even if another user created the meetup', function () {
$creator = User::factory()->create();
$member = actingAsUser();
$meetup = Meetup::factory()->create([
'city_id' => $this->city->id,
'created_by' => $creator->id,
]);
$meetup->users()->attach($member);
Livewire::test('meetups.edit', ['meetup' => $meetup])->assertStatus(200);
});
it('aborts meetups.edit with 403 when the authenticated user has not added the meetup to My-Meetups', function () {
actingAsUser();
Livewire::test('meetups.edit', ['meetup' => $this->meetup])->assertStatus(403);
});
it('aborts meetups.edit with 403 when the authenticated user is only the creator but not in My-Meetups', function () {
$creator = actingAsUser();
$meetup = Meetup::factory()->create([
'city_id' => $this->city->id,
'created_by' => $creator->id,
]);
Livewire::test('meetups.edit', ['meetup' => $meetup])->assertStatus(403);
});
it('mounts meetups.create-edit-events for new event', function () {
actingAsUser();
Livewire::test('meetups.create-edit-events', ['meetup' => $this->meetup])->assertStatus(200);
});
it('mounts meetups.create-edit-events for existing event', function () {
actingAsUser();
Livewire::test('meetups.create-edit-events', [
'meetup' => $this->meetup,
'event' => $this->event,
])->assertStatus(200);
});
it('does not crash with PropertyNotFoundException when startDate is set to null in series mode', function () {
actingAsUser();
Livewire::test('meetups.create-edit-events', ['meetup' => $this->meetup])
->set('seriesMode', true)
->set('endDate', '2026-10-27')
->set('startDate', null)
->assertStatus(200)
->assertSet('startDate', null);
});
it('does not crash when endDate is set to null in series mode', function () {
actingAsUser();
Livewire::test('meetups.create-edit-events', ['meetup' => $this->meetup])
->set('seriesMode', true)
->set('endDate', null)
->assertStatus(200)
->assertSet('endDate', null);
});
it('does not crash when startTime is set to null', function () {
actingAsUser();
Livewire::test('meetups.create-edit-events', ['meetup' => $this->meetup])
->set('startTime', null)
->assertStatus(200)
->assertSet('startTime', null);
});