Konfigurator: Ablauf im Zusammenhang aus dem Plan, Nachrichtenregeln, einheitliche Anfrage-/Buchungsansicht; Abnahmetests
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
221ce8ca81
commit
b1b09a6db4
7 files changed
+616
-36
No files matched your search
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Process;
|
||||
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Models\User;
|
||||
use App\Process\Tester\ProcessSandbox;
|
||||
use App\Support\Content;
|
||||
use App\Support\Settings;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Database\Seeders\PropertySeeder;
|
||||
use Database\Seeders\SiteSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* The relevant request variants played through the isolated tester: general question without a case, information,
|
||||
* binding offer with acceptance, request with independent data collection and reservation (with and without early
|
||||
* reservation), portal request with the portal as standard sender. The report shows the templates and what waits.
|
||||
*/
|
||||
#[Group('sandbox')]
|
||||
class InquiryProcessTesterTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private Property $property;
|
||||
|
||||
private User $user;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->travelTo(CarbonImmutable::parse('2026-10-23 10:00'));
|
||||
$this->seed([PropertySeeder::class, SiteSeeder::class]);
|
||||
$this->property = Property::sole();
|
||||
Content::save(['contract.terms' => '<p>Echte Bedingungen</p>', 'stay.cancellation' => '<p>Echtes Storno</p>']);
|
||||
Settings::tenant()->update(['bank_iban' => 'DE02120300000000202051', 'test_recipient' => 'vermieter@example.org', 'process_defaults' => ['processing' => 'automatic', 'clarification_hold_auto_minutes' => 120, 'data_request_mode' => 'automatic']]);
|
||||
$this->user = User::factory()->create();
|
||||
ProcessTesterTest::template();
|
||||
}
|
||||
|
||||
public function test_a_general_question_creates_no_booking_case(): void
|
||||
{
|
||||
$report = $this->play(Channel::websiteOf($this->property), 'general_question_message', ['model' => 'inquiry.request'], 1);
|
||||
|
||||
$this->assertNull($report['aborted'] ?? null, json_encode($report));
|
||||
$this->assertNull($report['plan'], 'no case, so no plan');
|
||||
$this->assertSame([], $report['violations']);
|
||||
$this->assertSame(0, Booking::query()->count());
|
||||
}
|
||||
|
||||
public function test_the_binding_offer_is_sent_and_accepted(): void
|
||||
{
|
||||
$report = $this->play(Channel::websiteOf($this->property), 'complete_request', ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer']], 3);
|
||||
|
||||
$this->assertNull($report['aborted'] ?? null, json_encode($report));
|
||||
$this->assertContains('inquiry.binding_offer@1', array_column($report['plan']['templates'], 'reference'));
|
||||
[$sent, , $accepted] = $report['timeline'];
|
||||
$this->assertSame('Angebot gesendet', $sent['status']);
|
||||
$this->assertTrue($sent['calendar']['occupying'], 'the offer holds the dates');
|
||||
$this->assertSame('Bestätigt', $accepted['status']);
|
||||
$this->assertContains('Gast nimmt das Angebot an', $sent['waiting']);
|
||||
$this->assertSame(0, Booking::query()->count());
|
||||
}
|
||||
|
||||
public function test_the_information_reserves_nothing(): void
|
||||
{
|
||||
$report = $this->play(Channel::websiteOf($this->property), 'complete_request', ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.information']], 2);
|
||||
|
||||
$this->assertNull($report['aborted'] ?? null, json_encode($report));
|
||||
$this->assertContains('inquiry.information@1', array_column($report['plan']['templates'], 'reference'));
|
||||
$first = $report['timeline'][0];
|
||||
$this->assertFalse($first['calendar']['occupying']);
|
||||
$this->assertNull($first['calendar']['hold_until']);
|
||||
$this->assertContains('Unverbindliche Auskunft senden (automatisch)', array_column($first['activities'], 'label'));
|
||||
}
|
||||
|
||||
public function test_data_collection_and_reservation_run_independently_and_the_strategy_is_free(): void
|
||||
{
|
||||
$website = Channel::websiteOf($this->property);
|
||||
|
||||
$reserving = $this->play($website, 'missing_address', ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer']], 3);
|
||||
$early = $reserving['timeline'][0];
|
||||
$this->assertTrue($early['calendar']['occupying'], 'suggested strategy: the dates are held at once');
|
||||
$this->assertNotNull($early['calendar']['hold_until']);
|
||||
$this->assertContains('Angaben für das Angebot vervollständigen', $early['waiting'], 'the details are missing – evidence is open');
|
||||
$this->assertStringContainsString('Bitte ergänzen Sie Ihre Angaben', implode(' ', array_column($early['mails'], 'subject')), 'the data request goes out although the offer waits');
|
||||
$this->assertSame('Angebot gesendet', $reserving['timeline'][2]['status']);
|
||||
|
||||
$free = $this->play($website, 'missing_address', ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer'], 'settings' => ['pre_reservation' => '0']], 3);
|
||||
$this->assertFalse($free['timeline'][0]['calendar']['occupying'], 'same answer, other strategy: nothing held at the request');
|
||||
$this->assertStringContainsString('Bitte ergänzen Sie Ihre Angaben', implode(' ', array_column($free['timeline'][0]['mails'], 'subject')), 'the data collection does not depend on the reservation');
|
||||
$this->assertSame('Angebot gesendet', $free['timeline'][2]['status'], 'and the offer still goes out once the details are there');
|
||||
$this->assertTrue($free['timeline'][2]['calendar']['occupying'], 'the offer itself holds the dates');
|
||||
$this->assertSame(0, Booking::query()->count());
|
||||
}
|
||||
|
||||
public function test_a_portal_request_with_the_portal_as_standard_sender_shows_the_unconfirmed_capability(): void
|
||||
{
|
||||
$portal = Channel::factory()->for($this->property)->create(['name' => 'Anfrageportal', 'booking_model' => 'inquiry', 'status' => 'setup', 'is_active' => false, 'import_enabled' => false, 'settings' => ['import_url' => 'https://anfrage.example/a.ics', 'portal_profile' => 'generic']]);
|
||||
|
||||
$report = $this->play($portal, 'portal_inquiry', ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer', 'guest_communication' => 'guest_comm.portal']], 3);
|
||||
|
||||
$this->assertNull($report['aborted'] ?? null, json_encode($report));
|
||||
$communication = collect($report['plan']['templates'])->firstWhere('reference', 'guest_comm.portal@1');
|
||||
$this->assertNotNull($communication);
|
||||
$this->assertFalse($communication['capabilities'][0]['confirmed'], 'the portal writing to guests is not shown as proven');
|
||||
$sender = collect($report['plan']['configuration'])->firstWhere('question', 'Wer schickt dem Gast die Anreise-Informationen?');
|
||||
$this->assertSame(['Das Portal', 'Vorschlag der gewählten Funktionsschablone'], [$sender['value'], $sender['source']]);
|
||||
$this->assertSame(0, Booking::query()->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $draft
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function play(Channel $channel, string $scenario, array $draft, int $steps): array
|
||||
{
|
||||
return app(ProcessSandbox::class)->run($channel, IntakeKind::Inquiry, $draft, $scenario, ['arrival' => '2026-11-07', 'nights' => 3, 'guests' => 2, 'text' => 'question'], $steps, $this->user)->report;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user