Skip to content

Commit dabe7b2

Browse files
authored
Merge pull request #154 from jpinsonneau/290_fix
NETOBSERV-290 fix tick race issues
2 parents 8bb14a0 + 9964885 commit dabe7b2

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

web/src/components/__tests__/netflow-traffic.spec.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@ describe('<NetflowTraffic />', () => {
3737

3838
it('should refresh on button click', async () => {
3939
const wrapper = mount(<NetflowTrafficParent />);
40-
//should show flows at first load
41-
expect(getFlowsMock).toHaveBeenCalledTimes(1);
4240
act(() => {
4341
//should have called getFlow twice after click
4442
wrapper.find('#refresh-button').at(0).simulate('click');
4543
});
4644
await waitFor(() => {
47-
expect(getFlowsMock).toHaveBeenCalledTimes(2);
45+
expect(getFlowsMock).toHaveBeenCalledTimes(1);
4846
});
4947
});
5048

web/src/components/netflow-traffic.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const NetflowTraffic: React.FC<{
150150
React.useEffect(() => {
151151
// Init state from URL
152152
if (!forcedFilters) {
153-
getFiltersFromURL(t)?.then(setFilters);
153+
getFiltersFromURL(t)?.then(updateTableFilters);
154154
}
155155
// disabling exhaustive-deps: tests hang when "t" passed as dependency (useTranslation not stable?)
156156
// eslint-disable-next-line react-hooks/exhaustive-deps

web/src/utils/poll-hook.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ export const usePoll = (callback: () => void, delay?: number, dependencies?: Rea
1414
useEffect(() => {
1515
const tick = () => (savedCallback?.current ? savedCallback.current() : null);
1616

17-
tick(); // Run first tick immediately.
18-
1917
if (delay) {
2018
// Only start interval if a delay is provided.
2119
const id = setInterval(tick, delay);

0 commit comments

Comments
 (0)