Files
web-page/src/pages/infra/useNodeStatus.test.js
gahusb 6e415b3e45 feat(infra): NAS↔Windows 워커 파이프라인 관측 페이지 /infra (Three.js)
분산 워커 관측 Part C — useNodeStatus 3초 폴링 훅 + statusVisual 색/라벨 매핑
+ 2D 워커 카드 그리드 + raw three.js 파이프라인 시각화(정상=시안 파티클 흐름 /
busy=가속 / paused=앰버 정지 / degraded=주황 / down=빨강 끊김, Redis 끊김=버스 빨강).
GET /api/agent-office/nodes(Part B) 소비. r3f 대신 기설치 three 직접 사용.
WebGL 미지원 시 카드 폴백 + 3D/그리드 토글. vitest 10 passed, build OK.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019LV86jBozkNhSFXJA412fq
2026-06-30 10:39:08 +09:00

27 lines
1.1 KiB
JavaScript

import { renderHook, waitFor } from '@testing-library/react';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { useNodeStatus } from './useNodeStatus';
import { getNodeStatus } from '../../api';
vi.mock('../../api', () => ({ getNodeStatus: vi.fn() }));
describe('useNodeStatus', () => {
beforeEach(() => vi.clearAllMocks());
it('fetches node status on mount', async () => {
getNodeStatus.mockResolvedValue({ redis_ok: true, workers: [], links: [] });
const { result } = renderHook(() => useNodeStatus(100000));
await waitFor(() => expect(result.current.data).toBeTruthy());
expect(result.current.data.redis_ok).toBe(true);
expect(result.current.loading).toBe(false);
expect(result.current.error).toBeNull();
});
it('captures fetch error', async () => {
getNodeStatus.mockRejectedValue(new Error('boom'));
const { result } = renderHook(() => useNodeStatus(100000));
await waitFor(() => expect(result.current.error).toBeTruthy());
expect(result.current.error.message).toBe('boom');
});
});