From e52d536c5770cb1f0017e1bb6b06a8773a2cfda7 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Tue, 21 May 2024 09:29:59 -0400 Subject: [PATCH 1/2] feat(settings): default detailedNotifications on --- src/__mocks__/mock-state.ts | 2 +- src/context/App.test.tsx | 4 ++-- src/context/App.tsx | 2 +- src/hooks/useNotifications.test.ts | 20 +++++++++++++++---- src/routes/Settings.test.tsx | 7 +++++-- .../__snapshots__/Settings.test.tsx.snap | 2 -- 6 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/__mocks__/mock-state.ts b/src/__mocks__/mock-state.ts index 6594be1d0..4a930d0e7 100644 --- a/src/__mocks__/mock-state.ts +++ b/src/__mocks__/mock-state.ts @@ -15,7 +15,7 @@ export const mockSettings: SettingsState = { showNotificationsCountInTray: false, openAtStartup: false, theme: Theme.SYSTEM, - detailedNotifications: false, + detailedNotifications: true, markAsDoneOnOpen: false, showAccountHostname: false, delayNotificationState: false, diff --git a/src/context/App.test.tsx b/src/context/App.test.tsx index f687aeed8..bf8c297f7 100644 --- a/src/context/App.test.tsx +++ b/src/context/App.test.tsx @@ -330,7 +330,7 @@ describe('context/App.tsx', () => { showNotificationsCountInTray: false, openAtStartup: false, theme: 'SYSTEM', - detailedNotifications: false, + detailedNotifications: true, markAsDoneOnOpen: false, showAccountHostname: false, delayNotificationState: false, @@ -375,7 +375,7 @@ describe('context/App.tsx', () => { showNotificationsCountInTray: false, openAtStartup: true, theme: 'SYSTEM', - detailedNotifications: false, + detailedNotifications: true, markAsDoneOnOpen: false, showAccountHostname: false, delayNotificationState: false, diff --git a/src/context/App.tsx b/src/context/App.tsx index 45eacda12..77c32fe23 100644 --- a/src/context/App.tsx +++ b/src/context/App.tsx @@ -41,7 +41,7 @@ export const defaultSettings: SettingsState = { showNotificationsCountInTray: false, openAtStartup: false, theme: Theme.SYSTEM, - detailedNotifications: false, + detailedNotifications: true, markAsDoneOnOpen: false, showAccountHostname: false, delayNotificationState: false, diff --git a/src/hooks/useNotifications.test.ts b/src/hooks/useNotifications.test.ts index 11b96b296..29e4be3bd 100644 --- a/src/hooks/useNotifications.test.ts +++ b/src/hooks/useNotifications.test.ts @@ -34,7 +34,10 @@ describe('hooks/useNotifications.ts', () => { const { result } = renderHook(() => useNotifications()); act(() => { - result.current.fetchNotifications(mockAccounts, mockSettings); + result.current.fetchNotifications(mockAccounts, { + ...mockSettings, + detailedNotifications: false, + }); }); expect(result.current.status).toBe('loading'); @@ -116,7 +119,10 @@ describe('hooks/useNotifications.ts', () => { const { result } = renderHook(() => useNotifications()); act(() => { - result.current.fetchNotifications(accounts, mockSettings); + result.current.fetchNotifications(accounts, { + ...mockSettings, + detailedNotifications: false, + }); }); await waitFor(() => { @@ -179,7 +185,10 @@ describe('hooks/useNotifications.ts', () => { const { result } = renderHook(() => useNotifications()); act(() => { - result.current.fetchNotifications(accounts, mockSettings); + result.current.fetchNotifications(accounts, { + ...mockSettings, + detailedNotifications: false, + }); }); await waitFor(() => { @@ -417,7 +426,10 @@ describe('hooks/useNotifications.ts', () => { const { result } = renderHook(() => useNotifications()); act(() => { - result.current.fetchNotifications(mockAccounts, mockSettings); + result.current.fetchNotifications(mockAccounts, { + ...mockSettings, + detailedNotifications: false, + }); }); await waitFor(() => { diff --git a/src/routes/Settings.test.tsx b/src/routes/Settings.test.tsx index 22d88f833..ad6ed8d0b 100644 --- a/src/routes/Settings.test.tsx +++ b/src/routes/Settings.test.tsx @@ -91,7 +91,7 @@ describe('routes/Settings.tsx', () => { expect(updateSetting).toHaveBeenCalledWith('theme', 'LIGHT'); }); - it('should be able to enable detailed notifications', async () => { + it('should toggle detailed notifications checkbox', async () => { jest.spyOn(apiRequests, 'apiRequestAuth').mockResolvedValue({ headers: { 'x-oauth-scopes': Constants.AUTH_SCOPE.join(', '), @@ -119,7 +119,10 @@ describe('routes/Settings.tsx', () => { fireEvent.click(screen.getByLabelText('Detailed notifications')); expect(updateSetting).toHaveBeenCalledTimes(1); - expect(updateSetting).toHaveBeenCalledWith('detailedNotifications', true); + expect(updateSetting).toHaveBeenCalledWith( + 'detailedNotifications', + false, + ); }); it('should not be able to enable detailed notifications due to missing scope', async () => { diff --git a/src/routes/__snapshots__/Settings.test.tsx.snap b/src/routes/__snapshots__/Settings.test.tsx.snap index f8a185eb6..89a6bb9db 100644 --- a/src/routes/__snapshots__/Settings.test.tsx.snap +++ b/src/routes/__snapshots__/Settings.test.tsx.snap @@ -315,7 +315,6 @@ exports[`routes/Settings.tsx General should render itself & its children 1`] = ` @@ -326,7 +325,6 @@ exports[`routes/Settings.tsx General should render itself & its children 1`] = `