mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 17:41:51 +00:00
70 lines
3.2 KiB
TypeScript
70 lines
3.2 KiB
TypeScript
import {
|
|
bookingConfirmationFrom,
|
|
bookingEntryIntent,
|
|
isStandaloneBookingRequest,
|
|
withBookingConfirmation,
|
|
} from '../../../../src/nest/assistant/assistant-booking-intent';
|
|
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
describe('bookingEntryIntent', () => {
|
|
it.each([
|
|
['Kannst du mir zur Udon-Kette Marugame eine Buchung zu 13 Uhr bitte anlegen?', 'booking'],
|
|
['Für diesen Ort bitte eine bestätigte Reservierung eintragen.', 'booking'],
|
|
['Record a booking at this place for 13:00.', 'booking'],
|
|
['Bitte eine Buchung eintragen und einen Ort hinzufügen.', 'combined'],
|
|
['Add this restaurant to the day and record my reservation.', 'combined'],
|
|
['Welche Buchung hat den Code ABC-12345?', null],
|
|
['Keine Buchung anlegen, sondern einen Ort.', null],
|
|
['Please do not create a reservation.', null],
|
|
['Zeig mir Orte für Tag 2.', null],
|
|
] as const)('routes %s', (text, intent) => {
|
|
expect(bookingEntryIntent(text)).toBe(intent);
|
|
});
|
|
});
|
|
|
|
describe('isStandaloneBookingRequest', () => {
|
|
it.each([
|
|
['Bitte eine Buchung zu 13 Uhr anlegen. Ist schon vom Restaurant bestätigt.', true],
|
|
['Verknüpfe die Buchung mit dem Restaurant im Tagesplan.', true],
|
|
['Link the reservation to the existing visit on day 1.', true],
|
|
['Bitte die Buchung anlegen und einen Ort hinzufügen.', false],
|
|
['Record the reservation and add an expense.', false],
|
|
['Bitte die Buchung anlegen. Verknüpfe sie mit dem Termin.', false],
|
|
['Welche Buchung hat den Code ABC-12345?', false],
|
|
] as const)('uses a receipt as the final answer for %s', (text, standalone) => {
|
|
expect(isStandaloneBookingRequest(text)).toBe(standalone);
|
|
});
|
|
});
|
|
|
|
describe('bookingConfirmationFrom', () => {
|
|
it.each([
|
|
[
|
|
'Bitte eine Buchung anlegen, ist schon vom Restaurant bestätigt. Buchungsnummer ABC-12345.',
|
|
{ reference: 'ABC-12345' },
|
|
],
|
|
['Bitte eine bestätigte Reservierung eintragen.', { reference: null }],
|
|
['Record the reservation. It has already been confirmed. Booking code 4YRT2P.', { reference: '4YRT2P' }],
|
|
['Bitte eine Buchung eintragen. Das Restaurant hat noch nicht bestätigt.', null],
|
|
['Bitte eine Buchung anlegen. Wird sie schon bestätigt?', null],
|
|
['Bitte eine Buchung anlegen, wenn sie bestätigt ist.', null],
|
|
['Please log the reservation. It will be confirmed tomorrow.', null],
|
|
['Bitte eine Buchung eintragen. Buchungsnummer ABC-12345.', null],
|
|
['Bitte zwei Buchungen eintragen. Die erste ist schon bestätigt.', null],
|
|
] as const)('reads explicit confirmation from %s', (text, confirmation) => {
|
|
expect(bookingConfirmationFrom(text)).toEqual(confirmation);
|
|
});
|
|
|
|
it('updates only the targeted booking and keeps unrelated metadata', () => {
|
|
const confirmation = { reference: 'ABC-12345' };
|
|
const args = { title: 'Dinner', notes: 'Window table', confirmation_number: 'ABC-12345' };
|
|
expect(withBookingConfirmation('create_reservation', args, confirmation, false)).toEqual({
|
|
...args,
|
|
status: 'confirmed',
|
|
});
|
|
expect(withBookingConfirmation('create_place', args, confirmation, true)).toBe(args);
|
|
const other = { ...args, confirmation_number: 'OTHER-12345' };
|
|
expect(withBookingConfirmation('create_reservation', other, confirmation, true)).toBe(other);
|
|
});
|
|
});
|