Skip to content

Commit 753b402

Browse files
committed
feat(settings): make fetch interval user configurable
Signed-off-by: Adam Setch <[email protected]>
1 parent e747eb7 commit 753b402

File tree

3 files changed

+219
-15
lines changed

3 files changed

+219
-15
lines changed

src/renderer/components/settings/NotificationSettings.test.tsx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,71 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => {
5555
expect(updateSetting).toHaveBeenCalledWith('fetchType', 'INACTIVITY');
5656
});
5757

58+
it('should update the fetch interval values when using the buttons', async () => {
59+
await act(async () => {
60+
render(
61+
<AppContext.Provider
62+
value={{
63+
auth: mockAuth,
64+
settings: mockSettings,
65+
updateSetting,
66+
}}
67+
>
68+
<NotificationSettings />
69+
</AppContext.Provider>,
70+
);
71+
});
72+
73+
// Increase fetch interval
74+
await act(async () => {
75+
await userEvent.click(
76+
screen.getByTestId('settings-fetch-interval-increase'),
77+
);
78+
79+
expect(updateSetting).toHaveBeenCalledTimes(1);
80+
expect(updateSetting).toHaveBeenCalledWith('fetchInterval', 120000);
81+
});
82+
83+
await act(async () => {
84+
await userEvent.click(
85+
screen.getByTestId('settings-fetch-interval-increase'),
86+
);
87+
88+
expect(updateSetting).toHaveBeenCalledTimes(2);
89+
expect(updateSetting).toHaveBeenNthCalledWith(2, 'fetchInterval', 180000);
90+
});
91+
92+
// Decrease fetch interval
93+
await act(async () => {
94+
await userEvent.click(
95+
screen.getByTestId('settings-fetch-interval-decrease'),
96+
);
97+
98+
expect(updateSetting).toHaveBeenCalledTimes(3);
99+
expect(updateSetting).toHaveBeenNthCalledWith(3, 'fetchInterval', 120000);
100+
});
101+
102+
// Fetch interval reset
103+
await act(async () => {
104+
await userEvent.click(
105+
screen.getByTestId('settings-fetch-interval-reset'),
106+
);
107+
108+
expect(updateSetting).toHaveBeenCalledTimes(4);
109+
expect(updateSetting).toHaveBeenNthCalledWith(4, 'fetchInterval', 60000);
110+
});
111+
112+
// Prevent going lower than minimum interval
113+
await act(async () => {
114+
await userEvent.click(
115+
screen.getByTestId('settings-fetch-interval-decrease'),
116+
);
117+
118+
expect(updateSetting).toHaveBeenCalledTimes(4);
119+
expect(updateSetting).toHaveBeenNthCalledWith(4, 'fetchInterval', 60000);
120+
});
121+
});
122+
58123
it('should toggle the fetchAllNotifications checkbox', async () => {
59124
await act(async () => {
60125
render(

src/renderer/components/settings/NotificationSettings.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const NotificationSettings: FC = () => {
8686
<ButtonGroup className="ml-2">
8787
<IconButton
8888
aria-label="Decrease fetch interval"
89-
data-testid="settings-decrease-fetch-interval"
89+
data-testid="settings-fetch-interval-decrease"
9090
icon={DashIcon}
9191
onClick={() => {
9292
updateSetting(
@@ -110,7 +110,7 @@ export const NotificationSettings: FC = () => {
110110

111111
<IconButton
112112
aria-label="Increase fetch interval"
113-
data-testid="settings-increase-fetch-interval"
113+
data-testid="settings-fetch-interval-increase"
114114
icon={PlusIcon}
115115
onClick={() => {
116116
updateSetting(
@@ -127,8 +127,8 @@ export const NotificationSettings: FC = () => {
127127
/>
128128

129129
<IconButton
130-
aria-label="Reset zoom"
131-
data-testid="settings-zoom-reset"
130+
aria-label="Reset fetch interval"
131+
data-testid="settings-fetch-interval-reset"
132132
icon={SyncIcon}
133133
onClick={() => {
134134
updateSetting(

src/renderer/routes/__snapshots__/Settings.test.tsx.snap

Lines changed: 150 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)