fix: sanitize API error text display and add time_blockers tests

Add extractErrorMessage helper for JSON error body parsing and apply sanitizeText across all toast displays. Add time_blockers test coverage for new holiday placeholder cleanup and overlapping scenarios.
This commit is contained in:
2026-08-22 00:34:48 +01:00
parent 388ac5948a
commit 3eec71a56c
30 changed files with 283 additions and 71 deletions
@@ -6,6 +6,7 @@
import { ensureBusinessInfo, getBusinessInfo } from '$lib/stores/businessInfo.svelte';
import { SvelteDate } from 'svelte/reactivity';
import { toast } from 'svelte-sonner';
import { extractErrorMessage } from '$lib/utils/toast-safe';
import * as Modal from '$lib/components/ui/dialog';
import { Button } from '$lib/components/ui/button';
import { Input } from '$lib/components/ui/input';
@@ -231,7 +232,7 @@
pendingEditRequest = editData.edit_request || null;
} else {
const text = await bookingResp.text();
toast.error('Failed to load booking: ' + text);
toast.error('Failed to load booking: ' + extractErrorMessage(text));
open = false;
}
} catch (err) {
@@ -361,7 +362,7 @@ ${hasVAT ? `<p class="warning">VAT is included at ${biz?.default_vat_rate ?? 20}
open = false;
} else {
const text = await response.text();
toast.error('Failed to cancel: ' + text);
toast.error('Failed to cancel: ' + extractErrorMessage(text));
}
} catch {
toast.error('Network error');