From a3b86245aa82deaabda2ba6324eaf4dac5e6b122 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 6 Apr 2024 07:25:30 -0400 Subject: [PATCH 1/4] feat(settings): show account hostname --- src/__mocks__/mock-state.ts | 1 + src/context/App.tsx | 1 + src/routes/Notifications.tsx | 6 ++++-- src/routes/Settings.test.tsx | 28 ++++++++++++++++++++++++++++ src/routes/Settings.tsx | 8 ++++++++ src/types.ts | 1 + 6 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/__mocks__/mock-state.ts b/src/__mocks__/mock-state.ts index 59b9fcbcb..bb71f3574 100644 --- a/src/__mocks__/mock-state.ts +++ b/src/__mocks__/mock-state.ts @@ -17,4 +17,5 @@ export const mockSettings: SettingsState = { theme: Theme.SYSTEM, colors: false, markAsDoneOnOpen: false, + showAccountHostname: false, }; diff --git a/src/context/App.tsx b/src/context/App.tsx index b600889db..9b785fb08 100644 --- a/src/context/App.tsx +++ b/src/context/App.tsx @@ -41,6 +41,7 @@ export const defaultSettings: SettingsState = { theme: Theme.SYSTEM, colors: null, markAsDoneOnOpen: false, + showAccountHostname: false, }; interface AppContextState { diff --git a/src/routes/Notifications.tsx b/src/routes/Notifications.tsx index 478f549a4..75b794ca4 100644 --- a/src/routes/Notifications.tsx +++ b/src/routes/Notifications.tsx @@ -7,7 +7,7 @@ import { Oops } from '../components/Oops'; import { getNotificationCount } from '../utils/notifications'; export const NotificationsRoute: React.FC = (props) => { - const { notifications, requestFailed } = useContext(AppContext); + const { notifications, requestFailed, settings } = useContext(AppContext); const hasMultipleAccounts = useMemo( () => notifications.length > 1, @@ -37,7 +37,9 @@ export const NotificationsRoute: React.FC = (props) => { key={account.hostname} hostname={account.hostname} notifications={account.notifications} - showAccountHostname={hasMultipleAccounts} + showAccountHostname={ + hasMultipleAccounts || settings.showAccountHostname + } /> ))} diff --git a/src/routes/Settings.test.tsx b/src/routes/Settings.test.tsx index e8b608b9e..35703d262 100644 --- a/src/routes/Settings.test.tsx +++ b/src/routes/Settings.test.tsx @@ -156,6 +156,34 @@ describe('routes/Settings.tsx', () => { expect(updateSetting).toHaveBeenCalledWith('showBots', false); }); + it('should toggle the showAccountHostname checkbox', async () => { + let getByLabelText; + + await act(async () => { + const { getByLabelText: getByLabelTextLocal } = render( + + + + + , + ); + getByLabelText = getByLabelTextLocal; + }); + + fireEvent.click(getByLabelText('Show account hostname'), { + target: { checked: true }, + }); + + expect(updateSetting).toHaveBeenCalledTimes(1); + expect(updateSetting).toHaveBeenCalledWith('showAccountHostname', false); + }); + it('should toggle the showNotificationsCountInTray checkbox', async () => { let getByLabelText; diff --git a/src/routes/Settings.tsx b/src/routes/Settings.tsx index 3017d2941..6bbf66560 100644 --- a/src/routes/Settings.tsx +++ b/src/routes/Settings.tsx @@ -139,6 +139,14 @@ export const SettingsRoute: React.FC = () => { } disabled={!colorScope} /> + + updateSetting('showAccountHostname', evt.target.checked) + } + />
diff --git a/src/types.ts b/src/types.ts index f1a752847..6504ab9ee 100644 --- a/src/types.ts +++ b/src/types.ts @@ -13,6 +13,7 @@ export type SettingsState = AppearanceSettingsState & interface AppearanceSettingsState { theme: Theme; colors: boolean | null; + showAccountHostname: boolean; } interface NotificationSettingsState { From a56458ed6b996d814fd7cf6f0067fdd8b3c3539b Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 6 Apr 2024 07:34:28 -0400 Subject: [PATCH 2/4] feat(settings): show account hostname --- src/context/App.test.tsx | 2 ++ .../__snapshots__/Settings.test.tsx.snap | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/context/App.test.tsx b/src/context/App.test.tsx index 24ca1f099..76ff5c25c 100644 --- a/src/context/App.test.tsx +++ b/src/context/App.test.tsx @@ -300,6 +300,7 @@ describe('context/App.tsx', () => { theme: 'SYSTEM', colors: null, markAsDoneOnOpen: false, + showAccountHostname: false, }, ); }); @@ -340,6 +341,7 @@ describe('context/App.tsx', () => { theme: 'SYSTEM', colors: null, markAsDoneOnOpen: false, + showAccountHostname: false, }, ); }); diff --git a/src/routes/__snapshots__/Settings.test.tsx.snap b/src/routes/__snapshots__/Settings.test.tsx.snap index 2ceb4023d..ad921cb29 100644 --- a/src/routes/__snapshots__/Settings.test.tsx.snap +++ b/src/routes/__snapshots__/Settings.test.tsx.snap @@ -170,6 +170,29 @@ exports[`routes/Settings.tsx should render itself & its children 1`] = ` +
+
+ +
+
+ +
+
Date: Sat, 6 Apr 2024 08:13:08 -0400 Subject: [PATCH 3/4] feat(settings): show account hostname --- src/routes/Notifications.test.tsx | 15 +++++++++++++++ .../__snapshots__/Notifications.test.tsx.snap | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/routes/Notifications.test.tsx b/src/routes/Notifications.test.tsx index 9f7f8ee65..0b4762454 100644 --- a/src/routes/Notifications.test.tsx +++ b/src/routes/Notifications.test.tsx @@ -4,6 +4,7 @@ import TestRenderer from 'react-test-renderer'; import { AppContext } from '../context/App'; import { mockedAccountNotifications } from '../__mocks__/mockedData'; import { NotificationsRoute } from './Notifications'; +import { mockSettings } from '../__mocks__/mock-state'; jest.mock('../components/AccountNotifications', () => ({ AccountNotifications: 'AccountNotifications', @@ -39,6 +40,20 @@ describe('routes/Notifications.tsx', () => { expect(tree).toMatchSnapshot(); }); + it('should render itself & its children (show account hostname)', () => { + const tree = TestRenderer.create( + + + , + ); + expect(tree).toMatchSnapshot(); + }); + it('should render itself & its children (error page - oops)', () => { const tree = TestRenderer.create( diff --git a/src/routes/__snapshots__/Notifications.test.tsx.snap b/src/routes/__snapshots__/Notifications.test.tsx.snap index 7ca8cdc41..df45cf72c 100644 --- a/src/routes/__snapshots__/Notifications.test.tsx.snap +++ b/src/routes/__snapshots__/Notifications.test.tsx.snap @@ -4,6 +4,8 @@ exports[`routes/Notifications.tsx should render itself & its children (all read exports[`routes/Notifications.tsx should render itself & its children (error page - oops) 1`] = ``; +exports[`routes/Notifications.tsx should render itself & its children (show account hostname) 1`] = ``; + exports[`routes/Notifications.tsx should render itself & its children (with notifications) 1`] = `
Date: Sat, 6 Apr 2024 10:29:27 -0400 Subject: [PATCH 4/4] feat(settings): show account hostname --- src/routes/Notifications.test.tsx | 2 +- .../__snapshots__/Notifications.test.tsx.snap | 142 +++++++++++++++++- 2 files changed, 142 insertions(+), 2 deletions(-) diff --git a/src/routes/Notifications.test.tsx b/src/routes/Notifications.test.tsx index 0b4762454..2ad5db7e1 100644 --- a/src/routes/Notifications.test.tsx +++ b/src/routes/Notifications.test.tsx @@ -44,7 +44,7 @@ describe('routes/Notifications.tsx', () => { const tree = TestRenderer.create( diff --git a/src/routes/__snapshots__/Notifications.test.tsx.snap b/src/routes/__snapshots__/Notifications.test.tsx.snap index df45cf72c..8c42ddd1c 100644 --- a/src/routes/__snapshots__/Notifications.test.tsx.snap +++ b/src/routes/__snapshots__/Notifications.test.tsx.snap @@ -4,7 +4,147 @@ exports[`routes/Notifications.tsx should render itself & its children (all read exports[`routes/Notifications.tsx should render itself & its children (error page - oops) 1`] = ``; -exports[`routes/Notifications.tsx should render itself & its children (show account hostname) 1`] = ``; +exports[`routes/Notifications.tsx should render itself & its children (show account hostname) 1`] = ` +
+ +
+`; exports[`routes/Notifications.tsx should render itself & its children (with notifications) 1`] = `