From 8c95916081c92d1b7ce5a9e41e4a2ed0bddb7927 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Wed, 12 Nov 2025 16:25:48 -0500 Subject: [PATCH] fix: error for multiple accounts Signed-off-by: Adam Setch --- .../AccountNotifications.test.tsx | 35 +- .../notifications/AccountNotifications.tsx | 7 +- .../AccountNotifications.test.tsx.snap | 559 +++++++++++++++++- 3 files changed, 582 insertions(+), 19 deletions(-) diff --git a/src/renderer/components/notifications/AccountNotifications.test.tsx b/src/renderer/components/notifications/AccountNotifications.test.tsx index 8e7712194..0c848f588 100644 --- a/src/renderer/components/notifications/AccountNotifications.test.tsx +++ b/src/renderer/components/notifications/AccountNotifications.test.tsx @@ -2,6 +2,7 @@ import { act, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { + mockAuth, mockGitHubCloudAccount, mockSettings, } from '../../__mocks__/state-mocks'; @@ -80,7 +81,7 @@ describe('renderer/components/notifications/AccountNotifications.tsx', () => { expect(tree).toMatchSnapshot(); }); - it('should render itself - account error', async () => { + it('should render itself - account error for single account', async () => { const props = { account: mockGitHubCloudAccount, notifications: [], @@ -96,7 +97,37 @@ describe('renderer/components/notifications/AccountNotifications.tsx', () => { await act(async () => { tree = render( - + + + , + ); + }); + + expect(tree).toMatchSnapshot(); + }); + + it('should render itself - account error for multiple accounts', async () => { + const props = { + account: mockGitHubCloudAccount, + notifications: [], + error: { + title: 'Error title', + descriptions: ['Error description'], + emojis: ['🔥'], + }, + showAccountHeader: true, + }; + + let tree: ReturnType | null = null; + + await act(async () => { + tree = render( + , ); diff --git a/src/renderer/components/notifications/AccountNotifications.tsx b/src/renderer/components/notifications/AccountNotifications.tsx index 3115f171c..147d441dc 100644 --- a/src/renderer/components/notifications/AccountNotifications.tsx +++ b/src/renderer/components/notifications/AccountNotifications.tsx @@ -6,6 +6,7 @@ import { Button, Stack } from '@primer/react'; import { AppContext } from '../../context/App'; import { type Account, type GitifyError, Size } from '../../types'; import type { Notification } from '../../typesGitHub'; +import { hasMultipleAccounts } from '../../utils/auth/utils'; import { cn } from '../../utils/cn'; import { getChevronDetails } from '../../utils/helpers'; import { @@ -37,7 +38,7 @@ export const AccountNotifications: FC = ( ) => { const { account, showAccountHeader, notifications } = props; - const { settings } = useContext(AppContext); + const { auth, settings } = useContext(AppContext); const [showAccountNotifications, setShowAccountNotifications] = useState(true); @@ -126,7 +127,9 @@ export const AccountNotifications: FC = ( {showAccountNotifications && ( <> - {props.error && } + {props.error && ( + + )} {!hasNotifications && !props.error && } diff --git a/src/renderer/components/notifications/__snapshots__/AccountNotifications.test.tsx.snap b/src/renderer/components/notifications/__snapshots__/AccountNotifications.test.tsx.snap index 09649cc82..077b72c9f 100644 --- a/src/renderer/components/notifications/__snapshots__/AccountNotifications.test.tsx.snap +++ b/src/renderer/components/notifications/__snapshots__/AccountNotifications.test.tsx.snap @@ -1,6 +1,535 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing -exports[`renderer/components/notifications/AccountNotifications.tsx should render itself - account error 1`] = ` +exports[`renderer/components/notifications/AccountNotifications.tsx should render itself - account error for multiple accounts 1`] = ` +{ + "asFragment": [Function], + "baseElement": +
+ +
+
+
+
+ 🔥 +
+
+ Error title +
+
+
+ Error description +
+
+
+
+ , + "container":
+ +
+
+
+
+ 🔥 +
+
+ Error title +
+
+
+ Error description +
+
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`renderer/components/notifications/AccountNotifications.tsx should render itself - account error for single account 1`] = ` { "asFragment": [Function], "baseElement": @@ -190,7 +719,7 @@ exports[`renderer/components/notifications/AccountNotifications.tsx should rende