V2.1: Tester-Szenarien Portalbestätigung, Nachricht über anderes Medium, allgemeine Frage
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8026eceab4
commit
f8561fe0e5
6 files changed
+235
-2
No files matched your search
@@ -72,7 +72,7 @@ public function request(array $guest): Booking
|
||||
public function travel(int $minutes): void
|
||||
{
|
||||
Date::setTestNow(now()->addMinutes($minutes));
|
||||
foreach (['bookings:expire-holds', 'bookings:auto-offers', 'cases:data-requests'] as $command) {
|
||||
foreach (['bookings:advance-waiting', 'bookings:expire-holds', 'bookings:auto-offers', 'cases:data-requests'] as $command) {
|
||||
Artisan::call($command);
|
||||
}
|
||||
app(SendBookingReminders::class)->handle();
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Process\Tester\Scenarios\CommunicationFailure;
|
||||
use App\Process\Tester\Scenarios\CompleteRequest;
|
||||
use App\Process\Tester\Scenarios\GeneralQuestionMessage;
|
||||
use App\Process\Tester\Scenarios\MessageOtherMedium;
|
||||
use App\Process\Tester\Scenarios\MissingAddress;
|
||||
use App\Process\Tester\Scenarios\PortalBooking;
|
||||
use App\Process\Tester\Scenarios\PortalConfirmationWait;
|
||||
use App\Process\Tester\Scenarios\PortalInquiry;
|
||||
use App\Process\Tester\Scenarios\ReturningGuest;
|
||||
use App\Process\Tester\Scenarios\Scenario;
|
||||
@@ -17,7 +20,7 @@
|
||||
final class ScenarioCatalogue
|
||||
{
|
||||
/** @var list<class-string<Scenario>> */
|
||||
public const SCENARIOS = [CompleteRequest::class, MissingAddress::class, PortalInquiry::class, ReturningGuest::class, CommunicationFailure::class, PortalBooking::class];
|
||||
public const SCENARIOS = [CompleteRequest::class, MissingAddress::class, PortalInquiry::class, ReturningGuest::class, CommunicationFailure::class, PortalBooking::class, PortalConfirmationWait::class, MessageOtherMedium::class, GeneralQuestionMessage::class];
|
||||
|
||||
/**
|
||||
* @return array<string, class-string<Scenario>>
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Tester\Scenarios;
|
||||
|
||||
use App\Communication\IncomingMessage;
|
||||
use App\Communication\MessageIntake;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\Medium;
|
||||
use App\Process\Tester\SandboxContext;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* V2.1: a general question or a stay inquiry arrives by chat without any case. Shows that it is only answered or referred
|
||||
* to the inquiry path and creates no case, reservation or booking.
|
||||
*/
|
||||
final class GeneralQuestionMessage extends Scenario
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
return 'general_question_message';
|
||||
}
|
||||
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Allgemeine Frage im Chat (ohne Vorgang)';
|
||||
}
|
||||
|
||||
public static function description(): string
|
||||
{
|
||||
return 'Eine Frage oder Terminanfrage kommt ohne Vorgang im Chat an. Es entsteht kein Vorgang; die Nachricht wird nur beantwortet, auf den Anfrageweg verwiesen oder geklärt.';
|
||||
}
|
||||
|
||||
public static function intakes(): array
|
||||
{
|
||||
return [IntakeKind::Inquiry];
|
||||
}
|
||||
|
||||
public static function inputs(): array
|
||||
{
|
||||
return [
|
||||
'text' => ['label' => 'Nachricht', 'default' => 'question', 'type' => 'select', 'options' => ['question' => 'Sind Hunde erlaubt?', 'stay' => 'Ist die Wohnung im Dezember frei?', 'unclear' => 'ok danke']],
|
||||
];
|
||||
}
|
||||
|
||||
public function events(array $inputs): array
|
||||
{
|
||||
$text = match ((string) ($inputs['text'] ?? 'question')) {
|
||||
'stay' => 'Ist die Wohnung vom 12.12. bis 19.12. frei? Wir würden gern buchen.',
|
||||
'unclear' => 'ok danke',
|
||||
default => 'Sind Hunde erlaubt und gibt es einen Parkplatz?',
|
||||
};
|
||||
|
||||
return [new ScenarioEvent('Nachricht im Chat ohne Vorgang', fn (SandboxContext $context) => app(MessageIntake::class)->handle(
|
||||
new IncomingMessage(Medium::Chat, 'chat-visitor-1', $text, CarbonImmutable::now(), 'tester-'.md5($text)),
|
||||
))];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Tester\Scenarios;
|
||||
|
||||
use App\Communication\IncomingMessage;
|
||||
use App\Communication\MessageIntake;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\Medium;
|
||||
use App\Process\Tester\SandboxContext;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* V2.1: a message of a guest arrives through another medium (WhatsApp or chat; no provider, only the entry). Shows how
|
||||
* medium, reference and rules decide – assigned reply, unassignable message, contradictory reference – and that nothing
|
||||
* is taken over or created by itself.
|
||||
*/
|
||||
final class MessageOtherMedium extends Scenario
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
return 'message_other_medium';
|
||||
}
|
||||
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Nachricht über WhatsApp oder Chat';
|
||||
}
|
||||
|
||||
public static function description(): string
|
||||
{
|
||||
return 'Der Gast antwortet in einem anderen Medium – mit überprüftem Bezug, ohne Bezug oder mit widersprüchlicher Vorgangsnummer. Zeigt Zuordnung, Absicht und erlaubte Wirkung.';
|
||||
}
|
||||
|
||||
public static function intakes(): array
|
||||
{
|
||||
return [IntakeKind::Inquiry, IntakeKind::Booking];
|
||||
}
|
||||
|
||||
public static function inputs(): array
|
||||
{
|
||||
return [
|
||||
...parent::inputs(),
|
||||
'medium' => ['label' => 'Medium', 'default' => 'whatsapp', 'type' => 'select', 'options' => ['whatsapp' => 'WhatsApp', 'chat' => 'Chat']],
|
||||
'reference' => ['label' => 'Bezug', 'default' => 'verified', 'type' => 'select', 'options' => ['verified' => 'überprüfter Bezug zum Vorgang', 'none' => 'kein Bezug (nur Absender)', 'contradicting' => 'überprüfter Bezug, Text nennt andere Nummer']],
|
||||
'consent' => ['label' => 'Einwilligung des Gastes liegt vor', 'default' => true, 'type' => 'bool'],
|
||||
];
|
||||
}
|
||||
|
||||
public function events(array $inputs): array
|
||||
{
|
||||
return [
|
||||
new ScenarioEvent('Anfrage des Gastes liegt vor', fn (SandboxContext $context) => $context->request([])),
|
||||
new ScenarioEvent('Nachricht des Gastes im anderen Medium', function (SandboxContext $context) use ($inputs): void {
|
||||
$reference = (string) ($inputs['reference'] ?? 'verified');
|
||||
$text = 'Wir kommen am Anreisetag gegen 16 Uhr an.'.($reference === 'contradicting' ? ' Vorgang 2099-0001' : '');
|
||||
app(MessageIntake::class)->handle(new IncomingMessage(
|
||||
Medium::tryFrom((string) ($inputs['medium'] ?? 'whatsapp')) ?? Medium::WhatsApp, '+49170000000', $text, CarbonImmutable::now(), 'tester-'.md5($text),
|
||||
$reference === 'none' ? null : $context->booking?->id, (bool) ($inputs['consent'] ?? true),
|
||||
));
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Tester\Scenarios;
|
||||
|
||||
use App\Actions\ProcessPortalMail;
|
||||
use App\Actions\TakeOverExternalBooking;
|
||||
use App\Channels\Mail\PortalMail;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Process\Tester\SandboxContext;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* V2.1: a booking binding at the portal is known without the portal's confirmation mail (calendar or manual entry); the
|
||||
* mail comes at once, late or never. Shows what waits (documents, booking information), that the occupation does not,
|
||||
* and the escalation when the mail stays away.
|
||||
*/
|
||||
final class PortalConfirmationWait extends Scenario
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
return 'portal_confirmation_wait';
|
||||
}
|
||||
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Bestätigungsmail des Portals: sofort, verspätet oder ausbleibend';
|
||||
}
|
||||
|
||||
public static function description(): string
|
||||
{
|
||||
return 'Die Buchung ist bekannt, die Bestätigungsmail des Portals kommt sofort, nach einigen Stunden oder gar nicht. Zeigt, was wartet, was nicht, und wann Sie eine Aufgabe erhalten.';
|
||||
}
|
||||
|
||||
public static function intakes(): array
|
||||
{
|
||||
return [IntakeKind::Booking];
|
||||
}
|
||||
|
||||
public static function inputs(): array
|
||||
{
|
||||
return [
|
||||
...parent::inputs(),
|
||||
'confirmation' => ['label' => 'Bestätigungsmail', 'default' => 'late', 'type' => 'select', 'options' => ['immediate' => 'sofort', 'late' => 'nach 5 Stunden', 'missing' => 'bleibt aus']],
|
||||
];
|
||||
}
|
||||
|
||||
public function events(array $inputs): array
|
||||
{
|
||||
$known = new ScenarioEvent('Buchung ist bekannt (ohne Bestätigungsmail des Portals)', function (SandboxContext $context): void {
|
||||
$context->booking = app(TakeOverExternalBooking::class)->handle($context->property, $context->channel, $context->arrival(), $context->departure(), [
|
||||
'portal_reference' => $this->reference($context), 'portal_total' => 98000, 'guests' => $context->guests(),
|
||||
'guest' => ['first_name' => 'Testgast', 'last_name' => 'Portal', 'email' => 'portalgast@tester.invalid', 'street' => 'Teststraße 1', 'postal_code' => '18225', 'city' => 'Kühlungsborn', 'country' => 'DE'],
|
||||
]);
|
||||
});
|
||||
|
||||
return [$known, ...match ((string) ($inputs['confirmation'] ?? 'late')) {
|
||||
'immediate' => [$this->mailEvent()],
|
||||
'missing' => [new ScenarioEvent('60 Stunden vergehen – die Mail bleibt aus', fn (SandboxContext $context) => $context->travel(60 * 60))],
|
||||
default => [new ScenarioEvent('5 Stunden vergehen', fn (SandboxContext $context) => $context->travel(5 * 60)), $this->mailEvent()],
|
||||
}];
|
||||
}
|
||||
|
||||
private function mailEvent(): ScenarioEvent
|
||||
{
|
||||
return new ScenarioEvent('Bestätigungsmail des Portals kommt an', function (SandboxContext $context): void {
|
||||
$senders = array_values(array_filter(array_map('trim', explode(',', (string) ($context->channel->setting('email_senders') ?? '')))));
|
||||
$text = "Gast: Testgast Portal\nAnreise: ".$context->arrival()->format('d.m.Y')."\nAbreise: ".$context->departure()->format('d.m.Y')."\nBuchungsnummer: ".$this->reference($context);
|
||||
app(ProcessPortalMail::class)->handle(new PortalMail('<'.md5($text).'@tester.invalid>', 'buchung@'.($senders[0] ?? 'portal.invalid'), 'Neue Buchung', $text, CarbonImmutable::now()));
|
||||
});
|
||||
}
|
||||
|
||||
private function reference(SandboxContext $context): string
|
||||
{
|
||||
return 'TEST-'.$context->arrival()->format('md');
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Filament\Resources\Channels\Pages\ChannelProcess;
|
||||
use App\Filament\Resources\Channels\Pages\ChannelProcessTest;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingTask;
|
||||
use App\Models\Channel;
|
||||
use App\Models\ProcessTestRun;
|
||||
use App\Models\Property;
|
||||
@@ -132,6 +133,39 @@ public function test_a_portal_booking_scenario_with_cancellation_report(): void
|
||||
$this->assertFalse((bool) $fewo->fresh()->is_active, 'the real channel is unchanged');
|
||||
}
|
||||
|
||||
/** V2.1: waiting for the portal's confirmation – shows the wait, the protected occupation and the escalation in the tester */
|
||||
public function test_the_portal_confirmation_scenarios_show_waiting_arrival_and_escalation(): void
|
||||
{
|
||||
$portal = Channel::factory()->for($this->property)->create(['name' => 'Destination Solution', 'booking_model' => 'portal_booking', 'status' => 'setup', 'is_active' => false, 'import_enabled' => false, 'settings' => ['import_url' => 'https://ds.example/a.ics', 'email_senders' => 'ds.example']]);
|
||||
$draft = ['model' => 'a3.portal_booking', 'settings' => ['await_portal_confirmation' => '1', 'booking_notice' => 'automatic']];
|
||||
|
||||
$late = app(ProcessSandbox::class)->run($portal, IntakeKind::Booking, $draft, 'portal_confirmation_wait', ['arrival' => '2026-11-14', 'nights' => 4, 'guests' => 2, 'confirmation' => 'late'], 6, $this->user)->report;
|
||||
$missing = app(ProcessSandbox::class)->run($portal, IntakeKind::Booking, $draft, 'portal_confirmation_wait', ['arrival' => '2026-11-14', 'nights' => 4, 'guests' => 2, 'confirmation' => 'missing'], 6, $this->user)->report;
|
||||
|
||||
$this->assertNull($late['aborted'] ?? null, json_encode($late));
|
||||
$known = $late['timeline'][0];
|
||||
$this->assertStringContainsString('wartet', json_encode($known['activities'], JSON_UNESCAPED_UNICODE));
|
||||
$this->assertSame([], $known['mails'], 'nothing goes out while the confirmation is missing');
|
||||
$this->assertNotEmpty(end($late['timeline'])['mails'], 'after the confirmation the booking information goes out (sandbox only)');
|
||||
$this->assertStringContainsString('ausgeblieben', json_encode(end($missing['timeline'])['activities'], JSON_UNESCAPED_UNICODE));
|
||||
$this->assertSame(0, Booking::query()->count());
|
||||
$this->assertSame(0, BookingTask::query()->count(), 'the escalation task exists only inside the sandbox');
|
||||
}
|
||||
|
||||
/** V2.1 E/F: other media and questions without a case, through the isolated tester */
|
||||
public function test_the_message_scenarios_show_assignment_and_never_create_a_case(): void
|
||||
{
|
||||
config(['communication.media.chat.active' => true, 'communication.media.whatsapp.active' => true]);
|
||||
$website = Channel::websiteOf($this->property);
|
||||
|
||||
$question = app(ProcessSandbox::class)->run($website, IntakeKind::Inquiry, ['model' => 'a1.offer'], 'general_question_message', ['text' => 'question'], 1, $this->user)->report;
|
||||
$reply = app(ProcessSandbox::class)->run($website, IntakeKind::Inquiry, ['model' => 'a1.offer'], 'message_other_medium', ['arrival' => '2026-11-07', 'nights' => 3, 'guests' => 2, 'medium' => 'whatsapp', 'reference' => 'none', 'consent' => true], 2, $this->user)->report;
|
||||
|
||||
$this->assertNull($question['aborted'] ?? null, json_encode($question));
|
||||
$this->assertNull($reply['aborted'] ?? null, json_encode($reply));
|
||||
$this->assertSame(0, Booking::query()->count());
|
||||
}
|
||||
|
||||
/** S12/T06: a failing mail server leaves the case in a defined state */
|
||||
public function test_a_mail_failure_keeps_the_case(): void
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user