Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adm 793 [frontend] Reduce the time of timeout to 10 minutes #1141

Merged
merged 41 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e6b9ee1
AMD-793 [frontend] feature: add reverify logic and timeout alert
Mar 7, 2024
fc01550
AMD-793 [frontend] refactor: abstract config button component for con…
Mar 8, 2024
2354ced
Merge branch 'main' into ADM-793
Mar 8, 2024
01ab2ed
AMD-793 [frontend] refactor: abstract timeout alert component for con…
Mar 8, 2024
12f8c26
AMD-793 [frontend] feat: add timeout alert component to config page f…
Mar 11, 2024
a59dfb5
AMD-793 [frontend] fix: merge main to 793
Mar 11, 2024
f619f9c
AMD-793 [frontend] test: add test for timeout alert component
Mar 11, 2024
d38f126
AMD-793 [frontend] test: add test for config button group component
Mar 11, 2024
4e3917c
Merge branch 'main' into ADM-793
Mar 12, 2024
49ff6a8
[ADM-793] style: fix css check
Mar 12, 2024
67817c1
AMD-793 [frontend] fix: set HB timeout and timeout alert false in Sou…
Mar 12, 2024
e132606
AMD-793 [frontend] fix: fix test for PipelineToolClient.test.ts and S…
Mar 12, 2024
c6eb632
[ADM-793] style: fix border css
Mar 12, 2024
8bc183b
[ADM-793] test: fix test for useVerifyBoardEffect
Mar 12, 2024
3345b5b
AMD-793 [frontend] test: add test of isHBTimeout for useVerifySourceC…
Mar 12, 2024
4ac618e
[ADM-793] test: add test for useVerifyPipelineToolEffect
Mar 12, 2024
7b7b851
[ADM-793] test: add test for getFieldsWithNoVerifiedError
Mar 12, 2024
666654c
AMD-793 [frontend] test: remove not use mock in test file and change …
Mar 12, 2024
638dada
ADM-856:[backend]feat: update all feign clients decoder error message…
weiraneve Mar 12, 2024
c9640dd
ADM-697:[docx] docx: add docx spike the logic of calculating card rew…
Liughgood Mar 12, 2024
92ffd21
ADM-691: [frontend] feat: add feat about rework settings (#1138)
neomgb Mar 12, 2024
87265f8
ADM-856:[backend]feat: add decode default case error message (#1139)
weiraneve Mar 12, 2024
ff5045e
ADM-837:[docs] docs: spike about optimizing generate report backend l…
sqsq5566 Mar 12, 2024
5e7a7bf
add test case
guzhongren Mar 12, 2024
e3558f4
Merge branch 'main' into ADM-793
Mar 13, 2024
6fafbe2
AMD-793 [frontend] style: fix color for reverify button
Mar 13, 2024
ae3c971
[ADM-793] fix: revert httpTimeout
Mar 13, 2024
09cf8cd
Build(deps): bump softprops/action-gh-release from 1 to 2 (#1136)
dependabot[bot] Mar 13, 2024
e0dd764
Merge branch 'main' into ADM-793
lxuebing Mar 13, 2024
575e9bd
AMD-793 [frontend] fix: remove annotation in test file
Mar 13, 2024
94899f5
AMD-793 [frontend] fix: update test name for clear
Mar 13, 2024
210c6ea
AMD-793 [frontend] fix: update test name use given when then
Mar 13, 2024
e06a936
chore: extend the overall timeout of e2e 1 more minute. (#1144)
mrcuriosity-tw Mar 13, 2024
267c51a
ADM-691: [frontend] fix: add request fields (#1143)
neomgb Mar 13, 2024
7683e22
ADM-691: [frontend] fix: fix sonar issue (#1145)
neomgb Mar 13, 2024
7512069
[ADM-793] refactor: rename AXIOS_REQUEST_ERROR_CODE
Mar 13, 2024
c5f66ee
Merge branch 'main' into ADM-793
lxuebing Mar 14, 2024
9f0b012
AMD-793 [frontend] fix: update alert position to keep element still
Mar 14, 2024
5e626a8
[ADM-793] feat: enhance style for alert
Mar 14, 2024
b331d3c
[ADM-793] feat: change moduleType text
Mar 14, 2024
76df053
[ADM-793] style: enhance style
Mar 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions frontend/__tests__/client/PipelineToolClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ afterAll(() => server.close());
describe('PipelineToolClient', () => {
describe('verify pipelineTool request', () => {
it('should isPipelineVerified is true when pipelineTool verify response status 204', async () => {
const result = await pipelineToolClient.verify(MOCK_PIPELINE_VERIFY_REQUEST_PARAMS);
const result = await pipelineToolClient.verify(MOCK_PIPELINE_VERIFY_REQUEST_PARAMS, jest.fn(), jest.fn());

expect(result.code).toEqual(HttpStatusCode.NoContent);
});
Expand All @@ -45,7 +45,7 @@ describe('PipelineToolClient', () => {
it.each(errorCases)('should return error code when verify endponint returns error', async ({ code }) => {
server.use(rest.post(MOCK_PIPELINE_VERIFY_URL, (req, res, ctx) => res(ctx.status(code))));

const result = await pipelineToolClient.verify(MOCK_PIPELINE_VERIFY_REQUEST_PARAMS);
const result = await pipelineToolClient.verify(MOCK_PIPELINE_VERIFY_REQUEST_PARAMS, jest.fn(), jest.fn());

expect(result.code).toEqual(code);
});
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('PipelineToolClient', () => {

const result = await pipelineToolClient.getInfo(MOCK_PIPELINE_VERIFY_REQUEST_PARAMS);

expect(result.code).toEqual('HB_TIMEOUT');
expect(result.code).toEqual('NETWORK_TIMEOUT');
expect(result.data).toBeUndefined();
});

Expand Down
12 changes: 8 additions & 4 deletions frontend/__tests__/client/SourceControlClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ describe('verify sourceControl request', () => {
afterAll(() => server.close());

it('should return isSourceControlVerify true when sourceControl verify response status is 204', async () => {
const result = await sourceControlClient.verifyToken(MOCK_SOURCE_CONTROL_VERIFY_REQUEST_PARAMS);
const result = await sourceControlClient.verifyToken(
MOCK_SOURCE_CONTROL_VERIFY_REQUEST_PARAMS,
jest.fn(),
jest.fn(),
);

expect(result.code).toEqual(204);
});
Expand All @@ -27,7 +31,7 @@ describe('verify sourceControl request', () => {
),
);

sourceControlClient.verifyToken(MOCK_SOURCE_CONTROL_VERIFY_REQUEST_PARAMS).catch((e) => {
sourceControlClient.verifyToken(MOCK_SOURCE_CONTROL_VERIFY_REQUEST_PARAMS, jest.fn(), jest.fn()).catch((e) => {
expect(e).toBeInstanceOf(Error);
expect((e as Error).message).toMatch(VERIFY_ERROR_MESSAGE.BAD_REQUEST);
});
Expand All @@ -40,7 +44,7 @@ describe('verify sourceControl request', () => {
),
);

sourceControlClient.verifyToken(MOCK_SOURCE_CONTROL_VERIFY_REQUEST_PARAMS).catch((e) => {
sourceControlClient.verifyToken(MOCK_SOURCE_CONTROL_VERIFY_REQUEST_PARAMS, jest.fn(), jest.fn()).catch((e) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要用catch接,用reject.throw接错误

expect(e).toBeInstanceOf(Error);
expect((e as Error).message).toMatch(VERIFY_ERROR_MESSAGE.NOT_FOUND);
});
Expand All @@ -58,7 +62,7 @@ describe('verify sourceControl request', () => {
),
);

sourceControlClient.verifyToken(MOCK_SOURCE_CONTROL_VERIFY_REQUEST_PARAMS).catch((e) => {
sourceControlClient.verifyToken(MOCK_SOURCE_CONTROL_VERIFY_REQUEST_PARAMS, jest.fn(), jest.fn()).catch((e) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一样的问题

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原则:测试不要出现类似try catch的代码

expect(e).toBeInstanceOf(Error);
expect((e as Error).message).toMatch(VERIFY_ERROR_MESSAGE.INTERNAL_SERVER_ERROR);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { ConfigButtonGrop } from '@src/containers/ConfigStep/ConfigButton';
import { render, screen } from '@testing-library/react';
import React from 'react';

describe('ConfigButtonGroup', () => {
const setup = (isVerified: boolean, isLoading: boolean, isVerifyTimeOut: boolean, isDisableVerifyButton: boolean) => {
return render(
<ConfigButtonGrop
isVerifyTimeOut={isVerifyTimeOut}
isVerified={isVerified}
isLoading={isLoading}
isDisableVerifyButton={isDisableVerifyButton}
/>,
);
};

it('should render a verified and rest button given isVerified is true and isLoading is false', () => {
setup(true, false, false, false);

expect(screen.getByText('Verified')).toBeInTheDocument();
expect(screen.getByText('Reset')).toBeInTheDocument();
expect(screen.getByText('Verified')).toBeDisabled();
});
it('should render a Reverify button given isVerifyTimeOut is true', () => {
setup(false, false, true, false);

expect(screen.getByText('Reverify')).toBeInTheDocument();
expect(screen.getByText('Reverify')).toHaveAttribute('type', 'submit');
});
});
53 changes: 53 additions & 0 deletions frontend/__tests__/containers/ConfigStep/TimeoutAlet.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { TimeoutAlert } from '@src/containers/ConfigStep/TimeoutAlert';
import { act, render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';

describe('TimeoutAlert', () => {
const setIsShowAlert = jest.fn();
const setup = (
setIsShowAlert: (value: boolean) => void,
isShowAlert: boolean,
isVerifyTimeOut: boolean,
moduleType: string,
) => {
return render(
<TimeoutAlert
setIsShowAlert={setIsShowAlert}
isShowAlert={isShowAlert}
isVerifyTimeOut={isVerifyTimeOut}
moduleType={moduleType}
/>,
);
};

it('should render board message given moduleType is board', () => {
setup(setIsShowAlert, true, true, 'Board');
const message = screen.getByText('Board');

expect(message).toBeInTheDocument();
});
it('should not render the alert given isVerifyTimeOut or isShowAlert is false', () => {
setup(setIsShowAlert, false, true, 'Board');

expect(screen.queryByText('Board')).not.toBeInTheDocument();

setup(setIsShowAlert, true, false, 'Board');

expect(screen.queryByText('Board')).not.toBeInTheDocument();
});

it('should call setIsShowAlert with false when click the close icon given init value', async () => {
setup(setIsShowAlert, true, true, 'any');
const closeIcon = screen.getByTestId('CloseIcon');

act(() => {
userEvent.click(closeIcon);
});

await waitFor(() => {
expect(setIsShowAlert).toHaveBeenCalledTimes(1);
expect(setIsShowAlert).toHaveBeenCalledWith(false);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('<PresentationForErrorCases />', () => {
it('should display "try again" when error code is axios predefined error: $code', async () => {
const retrySpy = jest.fn();
const mockTimeoutError = {
code: 'HB_TIMEOUT',
code: 'NETWORK_TIMEOUT',
errorTitle: 'Service Unavailable!',
errorMessage: 'Data loading failed, please try again',
isLoading: false,
Expand All @@ -63,7 +63,7 @@ describe('<PresentationForErrorCases />', () => {
it('should not fire duplicated retry behavior when retry func is loading', async () => {
const retrySpy = jest.fn();
const mockTimeoutErrorProps = {
code: 'HB_TIMEOUT',
code: 'NETWORK_TIMEOUT',
errorTitle: 'Service Unavailable!',
errorMessage: 'Data loading failed, please try again',
isLoading: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,13 @@ describe('MetricsStep', () => {
await waitFor(() => {
expect(screen.getByText(/crew settings/i)).toBeInTheDocument();
});
expect(screen.getByText(/board mapping/i)).toBeInTheDocument();
expect(screen.getByText(/board mappings/i)).toBeInTheDocument();
});

it('should show retry button when call get info timeout', async () => {
server.use(
rest.post(MOCK_BOARD_INFO_URL, (_, res) => {
return res.networkError('HB_TIMEOUT');
return res.networkError('NETWORK_TIMEOUT');
}),
);
setup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ describe('Report Step', () => {

describe('export board data', () => {
it('should not show export board button when not selecting board metrics', () => {
const { queryByText } = setup([REQUIRED_DATA_LIST[4]]);
const { queryByText } = setup([REQUIRED_DATA_LIST[5]]);

const exportPipelineButton = queryByText(EXPORT_BOARD_DATA);

Expand Down
23 changes: 22 additions & 1 deletion frontend/__tests__/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ export const MOCK_GENERATE_REPORT_REQUEST_PARAMS: ReportRequestDTO = {
targetFields: [{ key: 'parent', name: 'Parent', flag: false }],
doneColumn: ['Done'],
overrideFields: [{ key: '123', name: 'Story Point', flag: true }],
reworkTimesSetting: {
reworkState: 'Done',
excludedStates: [],
},
},
};

Expand Down Expand Up @@ -339,7 +343,7 @@ export const MOCK_GITHUB_VERIFY_RESPONSE = {
};

export const CREWS_SETTING = 'Crew settings';
export const BOARD_MAPPING = 'Board mapping';
export const BOARD_MAPPING = 'Board mappings';
export const CLASSIFICATION_SETTING = 'Classification setting';
export const REAL_DONE = 'Real done setting';
export const DEPLOYMENT_FREQUENCY_SETTINGS = 'Pipeline settings';
Expand Down Expand Up @@ -404,6 +408,19 @@ export const MOCK_REPORT_RESPONSE: ReportResponseDTO = {
},
],
},
rework: {
totalReworkTimes: 111,
reworkState: 'Done',
fromToDo: 111,
fromInDev: 111,
fromBlock: 111,
fromWaitingForTesting: 111,
fromTesting: 111,
fromReview: 111,
fromDone: 111,
totalReworkCards: 111,
reworkCardsRatio: 111,
},
deploymentFrequency: {
avgDeploymentFrequency: {
name: 'Average',
Expand Down Expand Up @@ -651,6 +668,7 @@ export const EMPTY_REPORT_VALUES: ReportResponseDTO = {
velocity: null,
classificationList: null,
cycleTime: null,
rework: null,
deploymentFrequency: null,
changeFailureRate: null,
meanTimeToRecovery: null,
Expand Down Expand Up @@ -747,6 +765,9 @@ export const CYCLE_TIME_SETTINGS_SECTION = 'Cycle time settings section';
export const REAL_DONE_SETTING_SECTION = 'Real done setting section';
export const SELECT_CONSIDER_AS_DONE_MESSAGE = 'Must select which you want to consider as Done';
export const MOCK_SOURCE_CONTROL_VERIFY_ERROR_CASE_TEXT = 'Token is incorrect!';
export const MOCK_PIPELINE_VERIFY_UNAUTHORIZED_TEXT = 'Token is incorrect!';
export const MOCK_PIPELINE_VERIFY_FORBIDDEN_ERROR_TEXT =
'Forbidden request, please change your token with correct access permission.';

export const FAKE_TOKEN = 'fake-token';

Expand Down
Loading
Loading