mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-13 07:40:59 +00:00
2a51a1a842
The booking save helper answers a Reservation the way the dialogs' onSave does, and takes the payload the sheets read back. The export tests resolve their routing promise without non-null assertions, the autocomplete test reads its own console spy, and the Photon tally test asks its five dropped questions together instead of awaiting in a loop. The Photon address line falls back to empty when a feature has none. The repair test now expects the dashboard to place the cleared beach in Germany through the borders, as the Atlas map does since #2875. The client lint baseline follows the counts this branch lowered.
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { vi } from 'vitest';
|
|
|
|
import type { BookingSaveSteps } from '../../src/components/Planner/bookingFormModel';
|
|
import type { Reservation } from '../../src/types';
|
|
|
|
/**
|
|
* A booking save that does what the planner does (useBookingEdits): it stores the
|
|
* booking as `record`, runs the editor's follow-up (travellers, files) and answers
|
|
* nothing when that fails, keeping the failure for the test to read. The desktop
|
|
* dialogs take it as `onSave`, the phone sheets as `handleSaveReservation` or
|
|
* `handleSaveTransport`.
|
|
*/
|
|
export function plannerSave(record: { id: number }) {
|
|
const failures: Error[] = [];
|
|
const stored = record as Reservation;
|
|
const save = vi.fn(
|
|
async (
|
|
_data: Record<string, unknown> & { title: string },
|
|
steps?: BookingSaveSteps
|
|
): Promise<Reservation | undefined> => {
|
|
try {
|
|
await steps?.afterSave?.(stored);
|
|
return stored;
|
|
} catch (err) {
|
|
failures.push(err as Error);
|
|
return undefined;
|
|
}
|
|
}
|
|
);
|
|
return { save, failures };
|
|
}
|