Files
headroom/frontend/tests/unit/api-error-sanitization.spec.ts
Santhosh Janardhanan b821713cc7 fix(capacity): stabilize PTO flows and calendar consistency
Make PTO creation immediately approved, add PTO deletion, and ensure cache invalidation updates individual/team/revenue capacity consistently.

Harden holiday duplicate handling (422), support PTO-day availability overrides without disabling edits, and align tests plus OpenSpec artifacts with the new behavior.
2026-02-19 22:47:39 -05:00

20 lines
849 B
TypeScript

import { describe, expect, it } from 'vitest';
import { GENERIC_SERVER_ERROR_MESSAGE, sanitizeApiErrorMessage } from '$lib/services/api';
describe('sanitizeApiErrorMessage', () => {
it('replaces HTML payloads with the generic server error message', () => {
const htmlMessage = '<!DOCTYPE html><html><body>SQL error</body></html>';
expect(sanitizeApiErrorMessage(htmlMessage)).toBe(GENERIC_SERVER_ERROR_MESSAGE);
});
it('replaces SQLSTATE content with the generic server error message', () => {
const sqlMessage = 'SQLSTATE[HY000]: General error: 1 Unknown column';
expect(sanitizeApiErrorMessage(sqlMessage)).toBe(GENERIC_SERVER_ERROR_MESSAGE);
});
it('returns short API messages unchanged', () => {
const userMessage = 'User not found';
expect(sanitizeApiErrorMessage(userMessage)).toBe(userMessage);
});
});