iCal-Regelentwuerfe sichtbar speichern und Aktivierungsstand anzeigen
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m0s
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m0s
This commit is contained in:
1 parent
e7efb06277
commit
7d998e2b81
5 files changed
+147
-14
No files matched your search
@@ -5,18 +5,23 @@
|
||||
use App\Actions\AnalyzeChannelCalendar;
|
||||
use App\Actions\ApplyChannelRules;
|
||||
use App\Actions\ConfigureChannelExport;
|
||||
use App\Actions\ResolveChannelOccupation;
|
||||
use App\Actions\SaveChannelRules;
|
||||
use App\Actions\SyncChannel;
|
||||
use App\Availability\OccupancyOverview;
|
||||
use App\Channels\ChannelSyncException;
|
||||
use App\Channels\ICal\ICalAnalysis;
|
||||
use App\Channels\ICal\ICalFeed;
|
||||
use App\Channels\ICal\ICalParser;
|
||||
use App\Channels\ICal\ICalRuleEngine;
|
||||
use App\Enums\UserRole;
|
||||
use App\Filament\Pages\OccupancyCalendar;
|
||||
use App\Filament\Resources\Channels\Pages\ChannelRules;
|
||||
use App\Filament\Resources\PortalOccupations\PortalOccupationResource;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Guest;
|
||||
use App\Models\Property;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
@@ -178,6 +183,84 @@ public function test_unknown_portal_is_analysed_configured_and_activated_through
|
||||
Http::assertSentCount(1);
|
||||
}
|
||||
|
||||
public function test_visible_header_action_saves_repeated_rule_changes_without_activating_the_draft(): void
|
||||
{
|
||||
$channel = $this->channel();
|
||||
$this->actingAs(User::factory()->create());
|
||||
$page = Livewire::test(ChannelRules::class, ['record' => $channel->id])
|
||||
->assertActionVisible('saveDraft')->assertActionVisible('applyRules')
|
||||
->assertSee('Es sind noch keine Erkennungsregeln aktiviert.')
|
||||
->fillForm(['rules' => [self::rule()]])->callAction('saveDraft')->assertHasNoFormErrors()
|
||||
->assertNoRedirect()
|
||||
->assertNotified('Regelentwurf und Exportkonfiguration gespeichert')
|
||||
->assertSee('Gespeicherte Regeln sind noch nicht aktiv.');
|
||||
|
||||
$updated = self::rule(['name' => 'Geänderte Erkennung', 'priority' => 15]);
|
||||
$page->assertActionVisible('saveDraft')->fillForm(['rules' => [$updated]])
|
||||
->callAction('saveDraft')->assertHasNoFormErrors()->assertNoRedirect();
|
||||
|
||||
$this->assertSame('Geänderte Erkennung', $channel->fresh()->ical_rules[0]['name']);
|
||||
$this->assertSame(15, $channel->fresh()->ical_rules[0]['priority']);
|
||||
$this->assertNull($channel->fresh()->ical_active_rules);
|
||||
Livewire::test(ChannelRules::class, ['record' => $channel->id])->assertActionVisible('saveDraft')
|
||||
->assertSee('Geänderte Erkennung')->assertSee('Gespeicherte Regeln sind noch nicht aktiv.');
|
||||
}
|
||||
|
||||
public function test_applying_primary_source_rule_shows_full_guest_name_and_keeps_a_second_calendar_separate_until_confirmed(): void
|
||||
{
|
||||
$source = $this->channel();
|
||||
$source->update(['name' => 'Buchungsdatenquelle', 'export_enabled' => false]);
|
||||
$mirror = Channel::factory()->for($source->property)->create([
|
||||
'name' => 'Zweiter Kalender', 'settings' => ['import_url' => 'https://portal.example/mirror.ics'],
|
||||
]);
|
||||
$calendar = self::feed(self::event('primary-stay', 'Reservation: Nora Beispiel'));
|
||||
Http::preventStrayRequests();
|
||||
Http::fake([
|
||||
'https://portal.example/calendar.ics' => Http::response($calendar),
|
||||
'https://portal.example/mirror.ics' => Http::response(self::feed(self::event('mirror-stay', 'Blocked'))),
|
||||
]);
|
||||
Mail::fake();
|
||||
$this->assertTrue(app(SyncChannel::class)->handle($source)->successful);
|
||||
$this->assertTrue(app(SyncChannel::class)->handle($mirror)->successful);
|
||||
$source = app(AnalyzeChannelCalendar::class)->handle($source);
|
||||
$primary = $source->blockedPeriods()->sole();
|
||||
$secondary = $mirror->blockedPeriods()->sole();
|
||||
$identity = $primary->only(['id', 'external_uid', 'starts_on', 'ends_on', 'channel_id']);
|
||||
$rule = self::rule([
|
||||
'conditions' => [['field' => 'SUMMARY', 'operator' => 'starts_with', 'value' => 'Reservation: ']],
|
||||
'extractions' => [['field' => 'SUMMARY', 'target' => 'guest_full_name', 'method' => 'after', 'start' => 'Reservation: ']],
|
||||
]);
|
||||
$this->actingAs(User::factory()->create());
|
||||
$page = Livewire::test(ChannelRules::class, ['record' => $source->id])
|
||||
->fillForm(['rules' => [$rule]])->callAction('saveDraft')->assertHasNoFormErrors();
|
||||
|
||||
$this->assertSame('unknown', $primary->fresh()->occupationKind()->value);
|
||||
$this->assertNull($primary->fresh()->guestName());
|
||||
$page->assertSee(PortalOccupationResource::getUrl('view', ['record' => $secondary->id]), escape: false)
|
||||
->callAction('applyRules')->assertHasNoFormErrors()
|
||||
->assertSee('Gespeicherter Entwurf und aktive Regeln stimmen überein.');
|
||||
|
||||
$primary->refresh();
|
||||
$this->assertSame('reservation', $primary->occupationKind()->value);
|
||||
$this->assertSame('Nora Beispiel', $primary->guestName());
|
||||
$this->assertSame($source->id, $primary->origin_channel_id);
|
||||
$this->assertGreaterThan(0, $primary->leading_priority);
|
||||
$this->assertEquals($identity, $primary->only(array_keys($identity)));
|
||||
$this->assertSame('unknown', $secondary->fresh()->occupationKind()->value);
|
||||
$this->assertFalse($secondary->fresh()->is_representation);
|
||||
$this->assertSame(0, Guest::count());
|
||||
$this->assertCount(2, app(OccupancyOverview::class)->records(includeBlocks: true));
|
||||
|
||||
app(ResolveChannelOccupation::class)->handle($secondary, 'block', $primary->id, $source->id);
|
||||
|
||||
$this->assertTrue($secondary->fresh()->is_representation);
|
||||
$this->assertSame($primary->id, $secondary->fresh()->canonical_block_id);
|
||||
$this->assertCount(1, app(OccupancyOverview::class)->records(includeBlocks: true));
|
||||
Livewire::test(OccupancyCalendar::class, ['month' => '2027-05', 'propertyId' => $source->property_id])
|
||||
->assertSee('Nora Beispiel')->assertSee('Portalreservierung')->assertDontSee('occupancy-event kind-unknown', escape: false);
|
||||
Http::assertSentCount(3);
|
||||
}
|
||||
|
||||
public function test_editor_live_preview_does_not_mutate_inventory_before_explicit_application(): void
|
||||
{
|
||||
$channel = $this->channel();
|
||||
|
||||
Reference in new issue
Block a user