Files
einundzwanzig-app/tests/Feature/Livewire/MeetupMountTest.php
T
BT a4cbb10604 🔥 **Cleanup:** Removed obsolete .junie guideline files and MCP configuration.
 **Tests:** Added helper function `makeSignedNostrLoginEvent` for generating NIP-42 signed login events. Updated related tests in `Feature/Auth/NostrLoginTest.php` to use this helper.
🚀 **Livewire Testing:** Enhanced authorization checks and added specific creator-based mounts for `meetups.edit`. Improved tests for `MeetupMountTest` and `EditMeetupTest`.
🎨 **Style:** Standardized `request()->route()` to lowercase country codes across multiple Blade templates for consistency.
🛠️ **Config:** Updated `vite.config.js` formatting for improved readability in ignored paths.
2026-05-03 18:36:14 +02:00

87 lines
2.9 KiB
PHP

<?php
use App\Models\City;
use App\Models\Country;
use App\Models\Meetup;
use App\Models\MeetupEvent;
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 authenticated as the meetup creator', function () {
$owner = actingAsUser();
$meetup = Meetup::factory()->create([
'city_id' => $this->city->id,
'created_by' => $owner->id,
]);
Livewire::test('meetups.edit', ['meetup' => $meetup])->assertStatus(200);
});
it('aborts meetups.edit with 403 when authenticated user is not the creator', function () {
actingAsUser();
Livewire::test('meetups.edit', ['meetup' => $this->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);
});