File tree 2 files changed +3
-34
lines changed
2 files changed +3
-34
lines changed Original file line number Diff line number Diff line change @@ -105,39 +105,17 @@ describe('components/Sidebar.tsx', () => {
105
105
fetchNotifications . mockReset ( ) ;
106
106
107
107
const enabledRefreshButton = 'Refresh Notifications' ;
108
- const disabledRefreshButton =
109
- 'Please wait before manually refreshing again...' ;
110
-
111
- // Refresh button should be enabled
112
- expect ( screen . getByTitle ( enabledRefreshButton ) ) . toHaveProperty (
113
- 'disabled' ,
114
- false ,
115
- ) ;
116
- expect ( screen . queryByTitle ( disabledRefreshButton ) ) . toBeNull ( ) ;
117
108
118
109
fireEvent . click ( screen . getByTitle ( enabledRefreshButton ) ) ;
119
110
120
111
expect ( fetchNotifications ) . toHaveBeenCalledTimes ( 1 ) ;
121
112
122
- // Refresh button temporarily disabled
123
- expect ( screen . queryByTitle ( enabledRefreshButton ) ) . toBeNull ( ) ;
124
- expect ( screen . getByTitle ( disabledRefreshButton ) ) . toHaveProperty (
125
- 'disabled' ,
126
- true ,
127
- ) ;
128
-
129
113
act ( ( ) => {
130
114
jest . advanceTimersByTime ( Constants . FETCH_INTERVAL ) ;
131
115
return ;
132
116
} ) ;
133
- expect ( fetchNotifications ) . toHaveBeenCalledTimes ( 2 ) ;
134
117
135
- // Refresh button re-enabled
136
- expect ( screen . getByTitle ( enabledRefreshButton ) ) . toHaveProperty (
137
- 'disabled' ,
138
- false ,
139
- ) ;
140
- expect ( screen . queryByTitle ( disabledRefreshButton ) ) . toBeNull ( ) ;
118
+ expect ( fetchNotifications ) . toHaveBeenCalledTimes ( 2 ) ;
141
119
} ) ;
142
120
143
121
it ( 'go to the settings route' , ( ) => {
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ import {
13
13
useEffect ,
14
14
useMemo ,
15
15
useRef ,
16
- useState ,
17
16
} from 'react' ;
18
17
import { useLocation , useNavigate } from 'react-router-dom' ;
19
18
@@ -27,8 +26,6 @@ export const Sidebar: FC = () => {
27
26
const navigate = useNavigate ( ) ;
28
27
const location = useLocation ( ) ;
29
28
30
- const [ recentlyRefreshed , setRecentlyRefreshed ] = useState ( false ) ;
31
-
32
29
const { notifications, fetchNotifications, isLoggedIn, isFetching } =
33
30
useContext ( AppContext ) ;
34
31
@@ -60,7 +57,6 @@ export const Sidebar: FC = () => {
60
57
61
58
const { resetFetchInterval } = useFetchInterval ( ( ) => {
62
59
if ( isLoggedIn ) {
63
- setRecentlyRefreshed ( false ) ;
64
60
fetchNotifications ( ) ;
65
61
}
66
62
} , Constants . FETCH_INTERVAL ) ;
@@ -119,18 +115,13 @@ export const Sidebar: FC = () => {
119
115
< button
120
116
type = "button"
121
117
className = { sidebarButtonClasses }
122
- title = {
123
- recentlyRefreshed
124
- ? 'Please wait before manually refreshing again...'
125
- : 'Refresh Notifications'
126
- }
118
+ title = "Refresh Notifications"
127
119
onClick = { ( ) => {
128
120
navigate ( '/' , { replace : true } ) ;
129
- setRecentlyRefreshed ( true ) ;
130
121
fetchNotifications ( ) ;
131
122
resetFetchInterval ( ) ;
132
123
} }
133
- disabled = { isFetching || recentlyRefreshed }
124
+ disabled = { isFetching }
134
125
>
135
126
< SyncIcon
136
127
size = { 16 }
You can’t perform that action at this time.
0 commit comments