fix(listings): 조건 로드 실패 시 무한 로딩 대신 에러 표시

리뷰 지적: getListingsCriteria 실패 시 c=null로 남아 '불러오는 중…' 가
영구 표시되고 에러 메시지가 unreachable. 가드를 loading/!c로 분리해
실패 시 에러를 렌더 + 실패 경로 테스트 추가.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UHXzpsZQxKG9hQmNRfZjRS
This commit is contained in:
2026-07-09 16:23:40 +09:00
parent 0431ae6887
commit 17b1348f5d
2 changed files with 9 additions and 1 deletions

View File

@@ -59,7 +59,8 @@ const CriteriaTab = () => {
} finally { setSaving(false); } } finally { setSaving(false); }
}; };
if (loading || !c) return <p className="lst-empty">불러오는 </p>; if (loading) return <p className="lst-empty">불러오는 </p>;
if (!c) return <p className="lst-error">{msg || '조건을 불러오지 못했습니다.'}</p>;
return ( return (
<section className="lst-panel"> <section className="lst-panel">

View File

@@ -21,4 +21,11 @@ describe('CriteriaTab', () => {
expect(screen.getByLabelText(/연소득/)).toBeInTheDocument(); expect(screen.getByLabelText(/연소득/)).toBeInTheDocument();
expect(screen.getByDisplayValue('신대방동, 상도동')).toBeInTheDocument(); expect(screen.getByDisplayValue('신대방동, 상도동')).toBeInTheDocument();
}); });
it('로드 실패 시 무한 로딩 대신 에러를 표시', async () => {
getListingsCriteria.mockRejectedValue(new Error('HTTP 500'));
render(<CriteriaTab />);
await waitFor(() => expect(screen.getByText(/불러오지 못했|HTTP 500/)).toBeInTheDocument());
expect(screen.queryByText('불러오는 중…')).not.toBeInTheDocument();
});
}); });