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
@@ -1,5 +1,6 @@
<script lang="ts">
import { toast } from 'svelte-sonner';
import { extractErrorMessage } from '$lib/utils/toast-safe';
import * as Dialog from '$lib/components/ui/dialog';
import { Button } from '$lib/components/ui/button';
import { Input } from '$lib/components/ui/input';
@@ -241,7 +242,7 @@
});
if (!res.ok) {
const errData = await res.text();
throw new Error(errData || 'Failed to apply loyalty discount');
throw new Error(extractErrorMessage(errData) || 'Failed to apply loyalty discount');
}
}
@@ -271,7 +272,7 @@
if (!response.ok) {
const errData = await response.text();
throw new Error(errData || 'Failed to initiate payment');
throw new Error(extractErrorMessage(errData) || 'Failed to initiate payment');
}
const data = await response.json();
@@ -412,7 +413,7 @@
if (!response.ok) {
const errData = await response.text();
throw new Error(errData || 'Failed to process payment');
throw new Error(extractErrorMessage(errData) || 'Failed to process payment');
}
const data = await response.json();
@@ -539,7 +540,7 @@
if (!response.ok) {
const errData = await response.text();
throw new Error(errData || 'Failed to process gift card');
throw new Error(extractErrorMessage(errData) || 'Failed to process gift card');
}
const data = await response.json();
@@ -614,7 +615,7 @@
if (!response.ok) {
const errData = await response.text();
throw new Error(errData || 'Failed to process saved card payment');
throw new Error(extractErrorMessage(errData) || 'Failed to process saved card payment');
}
const data = await response.json();