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');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user