diff --git a/src/renderer/components/Oops.test.tsx b/src/renderer/components/Oops.test.tsx index 03d2156a8..e05a2ecdc 100644 --- a/src/renderer/components/Oops.test.tsx +++ b/src/renderer/components/Oops.test.tsx @@ -2,7 +2,7 @@ import { render } from '@testing-library/react'; import { Oops } from './Oops'; describe('renderer/components/Oops.tsx', () => { - it('should render itself & its children', () => { + it('should render itself & its children - specified error', () => { const mockError = { title: 'Error title', descriptions: ['Error description'], @@ -12,4 +12,10 @@ describe('renderer/components/Oops.tsx', () => { expect(tree).toMatchSnapshot(); }); + + it('should render itself & its children - fallback to unknown error', () => { + const tree = render(); + + expect(tree).toMatchSnapshot(); + }); }); diff --git a/src/renderer/components/Oops.tsx b/src/renderer/components/Oops.tsx index c23c44cd8..c6352b3da 100644 --- a/src/renderer/components/Oops.tsx +++ b/src/renderer/components/Oops.tsx @@ -1,6 +1,7 @@ import { type FC, useMemo } from 'react'; import type { GitifyError } from '../types'; +import { Errors } from '../utils/errors'; import { EmojiSplash } from './layout/EmojiSplash'; interface IOops { @@ -9,16 +10,18 @@ interface IOops { } export const Oops: FC = ({ error, fullHeight = true }: IOops) => { + const err = error ?? Errors.UNKNOWN; + const emoji = useMemo( - () => error.emojis[Math.floor(Math.random() * error.emojis.length)], - [error], + () => err.emojis[Math.floor(Math.random() * err.emojis.length)], + [err], ); return ( ); diff --git a/src/renderer/components/__snapshots__/Oops.test.tsx.snap b/src/renderer/components/__snapshots__/Oops.test.tsx.snap index efaba1bd1..4f2df114b 100644 --- a/src/renderer/components/__snapshots__/Oops.test.tsx.snap +++ b/src/renderer/components/__snapshots__/Oops.test.tsx.snap @@ -1,6 +1,167 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`renderer/components/Oops.tsx should render itself & its children 1`] = ` +exports[`renderer/components/Oops.tsx should render itself & its children - fallback to unknown error 1`] = ` +{ + "asFragment": [Function], + "baseElement": + + + + + + + + + Oops! Something went wrong + + + + Please try again later. + + + + + , + "container": + + + + + + + + Oops! Something went wrong + + + + Please try again later. + + + + , + "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/Oops.tsx should render itself & its children - specified error 1`] = ` { "asFragment": [Function], "baseElement": diff --git a/src/renderer/routes/Notifications.tsx b/src/renderer/routes/Notifications.tsx index d9cfb473e..6b9b8b354 100644 --- a/src/renderer/routes/Notifications.tsx +++ b/src/renderer/routes/Notifications.tsx @@ -5,7 +5,6 @@ import { Oops } from '../components/Oops'; import { AccountNotifications } from '../components/notifications/AccountNotifications'; import { AppContext } from '../context/App'; import { getAccountUUID } from '../utils/auth/utils'; -import { Errors } from '../utils/errors'; import { getNotificationCount } from '../utils/notifications/notifications'; export const NotificationsRoute: FC = () => { @@ -28,7 +27,7 @@ export const NotificationsRoute: FC = () => { ); if (status === 'error') { - return ; + return ; } if (!hasNotifications && hasNoAccountErrors) {