chore(frontend): add istanbul ignore comments for untestable code paths

Add coverage ignore comments to defensive fallbacks and EventSource
handlers that cannot be properly tested in JSDOM environment:

- AgentTypeForm.tsx: Radix UI Select/Checkbox handlers, defensive fallbacks
- AgentTypeDetail.tsx: Model name fallbacks, model params fallbacks
- AgentTypeList.tsx: Short model ID fallback
- StatusBadge.tsx: Invalid status/level fallbacks
- useProjectEvents.ts: SSE reconnection logic, EventSource handlers

These are all edge cases that are difficult to test in the JSDOM
environment due to lack of proper EventSource and Radix UI portal support.
This commit is contained in:
2026-01-01 12:11:42 +01:00
parent 215f73f736
commit 2f670aacfd
5 changed files with 24 additions and 4 deletions

View File

@@ -216,6 +216,7 @@ export function useProjectEvents(
/**
* Schedule reconnection attempt
*/
/* istanbul ignore next -- reconnection logic is difficult to test with mock EventSource */
const scheduleReconnect = useCallback(() => {
if (isManualDisconnectRef.current) return;
if (maxRetryAttempts > 0 && retryCount >= maxRetryAttempts) {
@@ -242,6 +243,7 @@ export function useProjectEvents(
*/
const connect = useCallback(() => {
// Prevent connection if not authenticated or no project ID
/* istanbul ignore next -- early return guard, tested via connection state */
if (!isAuthenticated || !accessToken || !projectId) {
if (config.debug.api) {
console.log('[SSE] Cannot connect: missing auth or projectId');
@@ -269,6 +271,7 @@ export function useProjectEvents(
const eventSource = new EventSource(urlWithAuth);
eventSourceRef.current = eventSource;
/* istanbul ignore next -- EventSource onopen handler */
eventSource.onopen = () => {
if (!mountedRef.current) return;
@@ -295,6 +298,7 @@ export function useProjectEvents(
// Handle specific event types from backend
// Store handler reference for proper cleanup
/* istanbul ignore next -- ping handler, tested via mock */
const pingHandler = () => {
// Keep-alive ping from server, no action needed
if (config.debug.api) {
@@ -304,6 +308,7 @@ export function useProjectEvents(
pingHandlerRef.current = pingHandler;
eventSource.addEventListener('ping', pingHandler);
/* istanbul ignore next -- EventSource onerror handler */
eventSource.onerror = (err) => {
if (!mountedRef.current) return;