Skip to content

Commit

Permalink
ADM-747: [frontend] feat: handle error (#968)
Browse files Browse the repository at this point in the history
* ADM-747: [frontend] refactor: refactor notification

* ADM-747: [frontend] refactor: set default title for notification

* ADM-747: [frontend] feat: handle timeout error

* ADM-747: [frontend] feat: handle report error

* ADM-747: [frontend] refactor: rename reportMetricsError

* ADM-747: [frontend] refactor: replace enum with object

* ADM-747: [frontend] feat: handle report error

* ADM-747: [frontend] feat: handle export error

* ADM-747: [frontend] test: add tests for error notifications

* ADM-747: [frontend] refactor: refactor report useEffect

* ADM-747: [frontend] refactor: refactor TimeoutException

* ADM-747: [frontend] refactor: delete useless isServerError

* ADM-747: [frontend] test: add e2e tests for date picker

* ADM-747: [frontend] fix: fix import
  • Loading branch information
JiangRu1 authored and Kai Zhou committed Jan 24, 2024
1 parent cb0f29e commit 4382ac6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jest.mock('@src/utils/util', () => ({
let store = null;
describe('Report Step', () => {
const { result: notificationHook } = renderHook(() => useNotificationLayoutEffect());
const { result: reportHook } = renderHook(() => useGenerateReportEffect());
const { result: reportHook } = renderHook(() => useGenerateReportEffect(notificationHook.current));
beforeEach(() => {
resetReportHook();
});
Expand Down
13 changes: 7 additions & 6 deletions frontend/__tests__/hooks/useGenerateReportEffect.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TimeoutException } from '@src/exceptions/TimeoutException';
import { UnknownException } from '@src/exceptions/UnknownException';
import { act, renderHook, waitFor } from '@testing-library/react';
import { reportClient } from '@src/clients/report/ReportClient';
import { MESSAGE } from '@src/constants/resources';
import { HttpStatusCode } from 'axios';
import clearAllMocks = jest.clearAllMocks;
import resetAllMocks = jest.resetAllMocks;
Expand Down Expand Up @@ -42,7 +43,7 @@ describe('use generate report effect', () => {
.fn()
.mockImplementation(async () => ({ response: MOCK_RETRIEVE_REPORT_RESPONSE }));

const { result } = renderHook(() => useGenerateReportEffect());
const { result } = renderHook(() => useGenerateReportEffect(notificationHook.current));

await waitFor(() => {
result.current.startToRequestBoardData(MOCK_GENERATE_REPORT_REQUEST_PARAMS);
Expand All @@ -64,7 +65,7 @@ describe('use generate report effect', () => {
.fn()
.mockImplementation(async () => ({ response: MOCK_RETRIEVE_REPORT_RESPONSE }));

const { result } = renderHook(() => useGenerateReportEffect());
const { result } = renderHook(() => useGenerateReportEffect(notificationHook.current));

await waitFor(() => {
result.current.startToRequestBoardData(MOCK_GENERATE_REPORT_REQUEST_PARAMS);
Expand All @@ -86,7 +87,7 @@ describe('use generate report effect', () => {
.fn()
.mockImplementation(async () => ({ response: MOCK_RETRIEVE_REPORT_RESPONSE }));

const { result } = renderHook(() => useGenerateReportEffect());
const { result } = renderHook(() => useGenerateReportEffect(notificationHook.current));

await waitFor(() => {
result.current.startToRequestDoraData(MOCK_GENERATE_REPORT_REQUEST_PARAMS);
Expand Down Expand Up @@ -120,7 +121,7 @@ describe('use generate report effect', () => {
.fn()
.mockImplementation(async () => ({ response: MOCK_RETRIEVE_REPORT_RESPONSE }));

const { result } = renderHook(() => useGenerateReportEffect());
const { result } = renderHook(() => useGenerateReportEffect(notificationHook.current));

await waitFor(() => {
result.current.startToRequestDoraData(MOCK_GENERATE_REPORT_REQUEST_PARAMS);
Expand All @@ -137,7 +138,7 @@ describe('use generate report effect', () => {
.fn()
.mockImplementation(async () => ({ response: MOCK_RETRIEVE_REPORT_RESPONSE }));

const { result } = renderHook(() => useGenerateReportEffect());
const { result } = renderHook(() => useGenerateReportEffect(notificationHook.current));

await waitFor(() => {
result.current.startToRequestDoraData(MOCK_GENERATE_REPORT_REQUEST_PARAMS);
Expand All @@ -159,7 +160,7 @@ describe('use generate report effect', () => {
.fn()
.mockImplementation(async () => ({ response: MOCK_RETRIEVE_REPORT_RESPONSE }));

const { result } = renderHook(() => useGenerateReportEffect());
const { result } = renderHook(() => useGenerateReportEffect(notificationHook.current));

await waitFor(() => {
result.current.startToRequestBoardData(MOCK_GENERATE_REPORT_REQUEST_PARAMS);
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/containers/MetricsStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ const MetricsStep = ({ closeAllNotifications }: useNotificationLayoutEffectInter

useLayoutEffect(() => {
closeAllNotifications();
}, []);

useLayoutEffect(() => {
getInfo();
}, []);

Expand Down
1 change: 1 addition & 0 deletions frontend/src/hooks/useGenerateReportEffect.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useNotificationLayoutEffectInterface } from '@src/hooks/useNotificationLayoutEffect';
import { BoardReportRequestDTO, ReportRequestDTO } from '@src/clients/report/dto/request';
import { exportValidityTimeMapper } from '@src/hooks/reportMapper/exportValidityTime';
import { ReportResponseDTO } from '@src/clients/report/dto/response';
Expand Down

0 comments on commit 4382ac6

Please sign in to comment.