Skip to content

Commit

Permalink
Merge pull request #259 from actiontech/bugfix/syncDataSource-router
Browse files Browse the repository at this point in the history
[fix]: (SyncDataSrouce) Adjust the routing structure and remove unused import.
  • Loading branch information
Rain-1214 authored Apr 27, 2023
2 parents 3e01d1b + cba8889 commit 54664b2
Show file tree
Hide file tree
Showing 26 changed files with 189 additions and 242 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"build": "craco build",
"test": "craco test",
"test:c": "craco test --watchAll=false --coverage",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"eslint": "eslint ./.eslintrc src/",
"ts-check": "tsc --noEmit"
},
"browserslist": {
"production": [
Expand Down
2 changes: 1 addition & 1 deletion src/components/BackendForm/BackendForm.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { fireEvent, render, screen } from '@testing-library/react';
import { renderHook } from '@testing-library/react-hooks';
import { Form } from 'antd';
import { useForm } from 'antd/lib/form/Form';
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditText/EditText.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { fireEvent, render } from '@testing-library/react';
import { getBySelector } from '../../testUtils/customQuery';
import EditText from './EditText';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import {
renderWithThemeAndRouter,
renderWithThemeAndServerRouter,
} from '../../../../../testUtils/customRender';
import { renderWithThemeAndRouter } from '../../../../../testUtils/customRender';
import HeaderMenu from '../HeaderMenu';
import { cleanup, fireEvent, screen } from '@testing-library/react';
import { DEFAULT_PROJECT_NAME } from '../../../../../page/ProjectManage/ProjectDetail';
import { SystemRole } from '../../../../../data/common';
import { mockBindProjects } from '../../../../../hooks/useCurrentUser/index.test';
import { useSelector } from 'react-redux';
import { getHrefByText } from '../../../../../testUtils/customQuery';
import useNavigate from '../../../../../hooks/useNavigate';

jest.mock('react-redux', () => ({
Expand Down
21 changes: 9 additions & 12 deletions src/hooks/useBack/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import { renderHook } from '@testing-library/react-hooks';

import { Router } from 'react-router';
import useBack from '.';
import useNavigate from '../useNavigate';

jest.mock('../useNavigate', () => jest.fn());

describe('useBack', () => {
test('should jump to last path in history when call goBack', () => {
// const history = createMemoryHistory();
// history.push('/');
// history.push('/test');
// const { result } = renderHook(() => useBack(), {
// wrapper: Router,
// initialProps: { history },
// });
// expect(history.location.pathname).toBe('/test');
// result.current.goBack();
// expect(history.location.pathname).toBe('/');
const navigateSpy = jest.fn();
(useNavigate as jest.Mock).mockImplementation(() => navigateSpy);
const { result } = renderHook(() => useBack());
result.current.goBack();
expect(navigateSpy).toBeCalledTimes(1);
expect(navigateSpy).toBeCalledWith(-1);
});
});
2 changes: 1 addition & 1 deletion src/page/Account/UserEmail/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { act, fireEvent, render, waitFor } from '@testing-library/react';
import { act, fireEvent, render } from '@testing-library/react';
import { message } from 'antd';
import { shallow } from 'enzyme';
import UserEmail from '.';
Expand Down
8 changes: 1 addition & 7 deletions src/page/Account/UserPhone/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
act,
fireEvent,
render,
screen,
waitFor,
} from '@testing-library/react';
import { act, fireEvent, render, screen } from '@testing-library/react';
import { message } from 'antd';
import { shallow } from 'enzyme';
import user from '../../../api/user';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
import { act, fireEvent, screen, waitFor } from '@testing-library/react';
import { act, fireEvent, screen } from '@testing-library/react';
import { useParams } from 'react-router-dom';
import SubscribeNotice from '..';
import audit_plan from '../../../../../../api/audit_plan';
Expand Down
2 changes: 1 addition & 1 deletion src/page/DataSource/AddDataSource/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fireEvent, waitFor, screen, act } from '@testing-library/react';
import { fireEvent, screen, act } from '@testing-library/react';
import { useParams } from 'react-router-dom';
import AddDataSource from '.';
import instance from '../../../api/instance';
Expand Down
7 changes: 2 additions & 5 deletions src/page/Home/CommonTable/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { fireEvent, render, screen } from '@testing-library/react';
import { render, screen } from '@testing-library/react';
import { IWorkflowDetailResV1 } from '../../../api/common';
import CommonTable, { CommonTableInfoType, genTabPaneTitle } from './index';
import {
renderWithRouter,
renderWithServerRouter,
} from '../../../testUtils/customRender';
import { renderWithRouter } from '../../../testUtils/customRender';
import { TableColumn } from '../../../types/common.type';
import { getHrefByText } from '../../../testUtils/customQuery';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { fireEvent, render, screen } from '@testing-library/react';
import { act } from 'react-dom/test-utils';
import { useParams } from 'react-router-dom';
import EmitterKey from '../../../../data/EmitterKey';
Expand Down
2 changes: 1 addition & 1 deletion src/page/Member/MemberList/__test__/FilterForm.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { fireEvent, render, screen } from '@testing-library/react';
import { act } from 'react-dom/test-utils';
import { useParams } from 'react-router-dom';
import EmitterKey from '../../../../data/EmitterKey';
Expand Down
2 changes: 1 addition & 1 deletion src/page/Order/AuditResult/AuditResultCollection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { ResponseCode } from '../../../data/common';
import ScheduleTimeModal from './ScheduleTimeModal';
import { useBoolean, useRequest } from 'ahooks';
import { useEffect, useMemo, useState } from 'react';
import { useEffect, useState } from 'react';
import { IGetWorkflowTasksItemV2 } from '../../../api/common';
import { useSelector } from 'react-redux';
import { IReduxState } from '../../../store';
Expand Down
12 changes: 5 additions & 7 deletions src/page/Order/AuditResult/__test__/ScheduleTimeModal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
act,
fireEvent,
getByLabelText,
render,
screen,
} from '@testing-library/react';
import { act, fireEvent, render, screen } from '@testing-library/react';
import moment from 'moment';
import { IMaintenanceTimeResV1 } from '../../../../api/common';
import { getBySelector } from '../../../../testUtils/customQuery';
Expand Down Expand Up @@ -121,6 +115,9 @@ describe('Order/AuditResult/ScheduleTimeModal', () => {
});

test('only can select maintenance time when user want to set schedule time', async () => {
const nowSpy = jest
.spyOn(Date, 'now')
.mockImplementation(() => new Date('2022-06-29').getTime());
render(
<ScheduleTimeModal
visible={true}
Expand All @@ -144,6 +141,7 @@ describe('Order/AuditResult/ScheduleTimeModal', () => {
await act(async () => jest.advanceTimersByTime(0));

expect(getBySelector('.ant-picker-datetime-panel')).toMatchSnapshot();
nowSpy.mockRestore();
});

test('user should set any time when maintenanceTime is empty', async () => {
Expand Down
Loading

0 comments on commit 54664b2

Please sign in to comment.