v0.11 U1: Kanalmanager mit eigener Webseite und neuen Prozessparametern
- Eigene Webseite als Kanal eigener Art (channels.kind = website), nur zur Konfiguration: Webseiten-Anfragen bleiben direkt (A1) ohne Kanalbezug; der Eintrag nimmt an Sync, Export, Überwachung und Sperraufgaben nicht teil (active()/Property::channels() nur Portale, Feed nur für Portale). - Neue Einstellungen im bestehenden ProcessSetting: Klärungsreservierung automatisch/Freigabe (15/180 min, 0 = keine), Rückfragemodus, Erinnerungen, Folgefragen, Erinnerungsabstand, Linkgültigkeit, Anschrift im Webformular verlangen (Standard: nein). - „Kanäle“ in der einfachen Ansicht: Webseite und Portale an einer Stelle, Verweis auf „Ihre Standards“; „Wirksame Einstellungen“ mit Spalte „Eigene Webseite“ und Herkunft „Webseite“. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bfccfe7eed
commit
799869c6a4
27 files changed
+559
-106
No files matched your search
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Actions\CreateReservation;
|
||||
use App\Enums\CaseType;
|
||||
use App\Enums\DataRequestMode;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Filament\Pages\EffectiveSettings;
|
||||
use App\Filament\Resources\Channels\Pages\EditChannel;
|
||||
use App\Filament\Resources\Channels\Pages\ListChannels;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Models\User;
|
||||
use App\Pricing\StayRequest;
|
||||
use App\Process\ProcessProfile;
|
||||
use App\Process\ProcessSettings;
|
||||
use App\Support\Settings;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Database\Seeders\PropertySeeder;
|
||||
use Database\Seeders\SiteSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* v0.11 package U1: the channel manager keeps the own website and the portals in one place (E-037, M12). The website
|
||||
* entry only carries settings – website requests stay direct (A1) – and never takes part in synchronisation, export,
|
||||
* monitoring or blocking tasks. The new v0.11 parameters live in the existing settings hierarchy.
|
||||
*/
|
||||
class ChannelManagerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private Property $property;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->travelTo(CarbonImmutable::parse('2026-10-22 10:00'));
|
||||
$this->seed([PropertySeeder::class, SiteSeeder::class]);
|
||||
$this->property = Property::sole();
|
||||
Mail::fake();
|
||||
}
|
||||
|
||||
public function test_the_website_entry_overrides_the_landlord_default_for_website_requests_and_the_case_stays_direct(): void
|
||||
{
|
||||
Settings::tenant()->update(['process_defaults' => ['hold_hours' => 48]]);
|
||||
Channel::websiteOf($this->property)->update(['process_overrides' => ['inquiry' => ['hold_hours' => 24]]]);
|
||||
|
||||
$website = $this->request(source: 'website');
|
||||
$phone = $this->request(email: 'telefon@example.org', arrival: '2026-11-20', departure: '2026-11-23', source: 'phone');
|
||||
|
||||
$this->assertTrue($website->hold_expires_at->equalTo(now()->addHours(24)));
|
||||
$this->assertSame(ProcessProfile::WEBSITE, $website->process()->source(ProcessSetting::HoldHours));
|
||||
$this->assertSame(CaseType::A1, $website->case_type);
|
||||
$this->assertNull($website->origin_channel_id);
|
||||
$this->assertTrue($website->isDirect());
|
||||
$this->assertSame('Eigene Webseite', $website->bookingChannelLabel());
|
||||
|
||||
$this->assertTrue($phone->hold_expires_at->equalTo(now()->addHours(48)), 'phone and e-mail keep the landlord default');
|
||||
$this->assertSame(CaseType::A1, $phone->case_type);
|
||||
}
|
||||
|
||||
public function test_the_website_entry_is_never_treated_as_a_portal(): void
|
||||
{
|
||||
$website = Channel::websiteOf($this->property);
|
||||
$portal = Channel::factory()->for($this->property)->create(['name' => 'FeWo-direkt', 'status' => 'active']);
|
||||
|
||||
$this->assertSame([$portal->id], Channel::query()->active()->pluck('id')->all());
|
||||
$this->assertSame([$portal->id], $this->property->channels()->pluck('id')->all());
|
||||
$this->assertSame([$portal->id], Channel::query()->portals()->pluck('id')->all());
|
||||
$this->assertTrue($website->isWebsite());
|
||||
$this->get(route('channels.feed', ['token' => $website->export_token]))->assertNotFound();
|
||||
$this->assertSame($website->id, Channel::websiteOf($this->property)->id, 'one entry per property');
|
||||
}
|
||||
|
||||
public function test_new_parameters_inherit_and_zero_is_a_value_of_its_own(): void
|
||||
{
|
||||
Settings::tenant()->update(['process_defaults' => ['data_request_mode' => DataRequestMode::Automatic->value, 'clarification_hold_auto_minutes' => 0]]);
|
||||
$settings = app(ProcessSettings::class);
|
||||
|
||||
$landlord = $settings->forWebsite($this->property);
|
||||
$this->assertSame(0, $landlord->clarificationHoldMinutes());
|
||||
$this->assertSame('tenant', $landlord->source(ProcessSetting::ClarificationHoldAutoMinutes));
|
||||
$this->assertSame(2, $landlord->remindersMax());
|
||||
$this->assertFalse($landlord->formRequiresAddress());
|
||||
|
||||
Channel::websiteOf($this->property)->update(['process_overrides' => ['inquiry' => ['data_request_mode' => DataRequestMode::Manual->value, 'form_requires_address' => '1', 'clarification_hold_auto_minutes' => null]]]);
|
||||
$website = $settings->forWebsite($this->property);
|
||||
$this->assertSame(DataRequestMode::Manual, $website->dataRequestMode());
|
||||
$this->assertSame(180, $website->clarificationHoldMinutes(), 'manual requests use their own default');
|
||||
$this->assertTrue($website->formRequiresAddress());
|
||||
|
||||
$portal = Channel::factory()->for($this->property)->create(['process_overrides' => ['booking' => ['data_request_mode' => DataRequestMode::Manual->value, 'clarification_hold_auto_minutes' => 30]]]);
|
||||
$booking = $settings->resolve($this->property, $portal, IntakeKind::Booking);
|
||||
$this->assertSame(DataRequestMode::Manual, $booking->dataRequestMode());
|
||||
$this->assertSame('tenant', $booking->source(ProcessSetting::ClarificationHoldAutoMinutes), 'a portal cannot set the clarification hold for bookings');
|
||||
}
|
||||
|
||||
public function test_the_channel_manager_lists_the_website_and_saves_its_settings(): void
|
||||
{
|
||||
$this->actingAs(User::factory()->create());
|
||||
Channel::query()->withoutGlobalScopes()->where('kind', Channel::KIND_WEBSITE)->delete();
|
||||
$portal = Channel::factory()->for($this->property)->create(['name' => 'FeWo-direkt']);
|
||||
|
||||
Livewire::test(ListChannels::class)->assertCanSeeTableRecords([$portal])->assertSee('Eigene Webseite');
|
||||
$website = Channel::websiteOf($this->property);
|
||||
|
||||
Livewire::test(EditChannel::class, ['record' => $website->getRouteKey()])
|
||||
->assertSee('Anfragen über die eigene Webseite')
|
||||
->assertDontSee('Eigener iCal-Exportlink')
|
||||
->fillForm(['process_overrides' => ['inquiry' => ['clarification_hold_manual_minutes' => '0', 'form_requires_address' => '1']]])
|
||||
->call('save')
|
||||
->assertHasNoFormErrors();
|
||||
|
||||
$profile = app(ProcessSettings::class)->forWebsite($this->property);
|
||||
$this->assertSame(0, $profile->clarificationHoldMinutes());
|
||||
$this->assertTrue($profile->formRequiresAddress());
|
||||
$this->assertSame(ProcessProfile::WEBSITE, $profile->source(ProcessSetting::FormRequiresAddress));
|
||||
}
|
||||
|
||||
public function test_effective_settings_show_the_website_column(): void
|
||||
{
|
||||
$this->actingAs(User::factory()->create());
|
||||
Channel::websiteOf($this->property)->update(['process_overrides' => ['inquiry' => ['clarification_hold_auto_minutes' => 0]]]);
|
||||
|
||||
Livewire::test(EffectiveSettings::class)
|
||||
->assertSee('Eigene Webseite – Anfrage')
|
||||
->assertSee('Direkte Anfrage (Telefon, E-Mail)')
|
||||
->assertSee('Webseite');
|
||||
}
|
||||
|
||||
private function request(string $email = 'gast@example.org', string $arrival = '2026-11-07', string $departure = '2026-11-10', string $source = 'website'): Booking
|
||||
{
|
||||
return app(CreateReservation::class)->handle(
|
||||
$this->property->fresh(),
|
||||
new StayRequest(CarbonImmutable::parse($arrival), CarbonImmutable::parse($departure), 2),
|
||||
['first_name' => 'Gesa', 'last_name' => 'Gast', 'email' => $email, 'street' => 'Strandweg 1', 'postal_code' => '18225', 'city' => 'Kühlungsborn', 'country' => 'DE'],
|
||||
source: $source,
|
||||
sendMails: false,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user