Problem
src/components/ContractEventFeed.tsx fetches events on mount, supports live polling via setInterval, handles error and empty states, and exposes a Live/Paused toggle. None of this is tested.
The stale closure polling bug (load not in dependency array — tracked separately) makes this component especially risky to modify without tests — there is no safety net to verify correct polling behavior after a fix. Three specific untested behaviors: (1) the initial fetch fires on mount with the correct contractId; (2) the Live/Paused toggle stops and restarts the polling interval; (3) when contractId changes, the component fetches for the new ID, not the old one.
Solution
Write React Testing Library tests using vi.useFakeTimers() for polling control. Test:
- Initial fetch is called on mount with the correct
contractId prop
- Events render in a list after a successful fetch
- Empty state renders when fetch returns an empty array
- Error message renders when fetch returns an error
- Polling calls
getEvents at the configured pollInterval using fake timers
- Toggling the Live button pauses polling (no further calls after toggle)
- Changing
contractId prop triggers a new fetch for the new ID
Acceptance Criteria
Note for Contributors: If you're assigned to this issue, write a clear and detailed description for your pull request. Explain what was changed, why it was needed, how it was implemented, and include any relevant testing or screenshots where applicable.
Problem
src/components/ContractEventFeed.tsxfetches events on mount, supports live polling viasetInterval, handles error and empty states, and exposes a Live/Paused toggle. None of this is tested.The stale closure polling bug (
loadnot in dependency array — tracked separately) makes this component especially risky to modify without tests — there is no safety net to verify correct polling behavior after a fix. Three specific untested behaviors: (1) the initial fetch fires on mount with the correctcontractId; (2) the Live/Paused toggle stops and restarts the polling interval; (3) whencontractIdchanges, the component fetches for the new ID, not the old one.Solution
Write React Testing Library tests using
vi.useFakeTimers()for polling control. Test:contractIdpropgetEventsat the configuredpollIntervalusing fake timerscontractIdprop triggers a new fetch for the new IDAcceptance Criteria
contractIdcontractIdfetches for the new contractnpm test