Skip to content

Commit

Permalink
Adm 793 [frontend] Reduce the time of timeout to 10 minutes (#1141)
Browse files Browse the repository at this point in the history
* AMD-793 [frontend] feature: add reverify logic and timeout alert

* AMD-793 [frontend] refactor: abstract config button component for config page

* AMD-793 [frontend] refactor: abstract timeout alert component for config page

* AMD-793 [frontend] feat: add timeout alert component to config page for three settings

* AMD-793 [frontend] test: add test for timeout alert component

* AMD-793 [frontend] test: add test for config button group component

* [ADM-793] style: fix css check

* AMD-793 [frontend] fix: set HB timeout and timeout alert false in SourceControlClient.ts and PipelineToolClient.ts

* AMD-793 [frontend] fix: fix test for PipelineToolClient.test.ts and SourceControlClient.test.ts

* [ADM-793] style: fix border css

* [ADM-793] test: fix test for useVerifyBoardEffect

* AMD-793 [frontend] test: add test of isHBTimeout for useVerifySourceControlTokenEffect

* [ADM-793] test: add test for useVerifyPipelineToolEffect

* [ADM-793] test: add test for getFieldsWithNoVerifiedError

* AMD-793 [frontend] test: remove not use mock in test file and change test case name

* ADM-856:[backend]feat: update all feign clients decoder error message (#1133)

* ADM-856:[backend]feat: update buildkite feign client decoder error message

* ADM-856:[backend]feat: update github feign client decoder error message

* ADM-856:[backend]feat: update jira feign client decoder error message

---------

Co-authored-by: guzhongren <guzhongren@live.cn>

* ADM-697:[docx] docx: add docx spike the logic of calculating card rework and api design (#1137)

* ADM-697:[docx] docx: add docx spike the logic of calculating card rework and api design

* ADM-697:[docx] docx: add spike export rework content when generate board csv

* ADM-697:[docx] docx: add spike calculate rework times

* ADM-697:[docx] docx: rewrite the doc of calculate rework times when don't check "Consider the 'Flag' as 'Block'

* ADM-697:[docx] docx: add logic for consider flag is block

* ADM-697:[docx] docx: fix some words

* ADM-697:[docx] docx: add logic of judge is our need rework

---------

Co-authored-by: yulongcai <yulong.cai@thoughtworks.com>

* ADM-691: [frontend] feat: add feat about rework settings (#1138)

* ADM-691: [frontend] feat: add new metrics field

* ADM-691: [frontend] feat: add rework setting title

* ADM-691: [frontend] feat: complete basic function about rework settings

* ADM-691: [frontend] feat: use redux to store fields

* ADM-691: [frontend] feat: replace undefind to null

* ADM-691: [frontend] feat: import config with rework times settings

* ADM-691: [frontend] fix: fix unit test

* ADM-691: [frontend] fix: fix unit test

* ADM-691: [frontend] fix: fix unit test

* ADM-691: [frontend] chore: refactor code after cr

* ADM-691: [frontend] fix: fix unit test

* ADM-691: [frontend] fix: fix unit test

* ADM-691: [frontend] test: improve test coverage

* ADM-691: [frontend] test: remove unused code

* ADM-691: [frontend] test: add test for rework setting

* ADM-691: [frontend] fix: fix e2e

* ADM-691: [frontend] fix: fix sonar

---------

Co-authored-by: Leiqiuhong <qiuhong.lei@thoughtworks.com>

* ADM-856:[backend]feat: add decode default case error message (#1139)

* ADM-837:[docs] docs: spike about optimizing generate report backend logic (#1140)

* ADM-837:[docs]feat: add half completed spike doc

* ADM-837: [docs] completed spike solution for export-allMetrics button polling api.

* ADM-837: [docs] completed spike design for export-allMetrics button polling api.

* ADM-837: [docs] add note to notice allMetricCompleted as true

---------

Co-authored-by: Yunlong Gan <yunlong.gan@thoughtworks.com>

* add test case

* AMD-793 [frontend] style: fix color for reverify button

* [ADM-793] fix: revert httpTimeout

* Build(deps): bump softprops/action-gh-release from 1 to 2 (#1136)

Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 1 to 2.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](softprops/action-gh-release@v1...v2)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: guzhongren <guzhongren@live.cn>

* AMD-793 [frontend] fix: remove annotation in test file

* AMD-793 [frontend] fix: update test name for clear

* AMD-793 [frontend] fix: update test name use given when then

* chore: extend the overall timeout of e2e 1 more minute. (#1144)

* chore: extend the overall timeout of e2e 1 more minute.

* distinguish local and CI for overall timeout.

* ADM-691: [frontend] fix: add request fields (#1143)

* ADM-691: [frontend] fix: add request fields

* ADM-691: [frontend] fix: fix sonar cloud

* ADM-691: [frontend] fix: fix unit test

* ADM-691: [frontend] chore: modify sytle, rename field

* ADM-691: [frontend] fix: fix sonar issue

* ADM-691: [frontend] fix: remove unused code

---------

Co-authored-by: Leiqiuhong <qiuhong.lei@thoughtworks.com>

* ADM-691: [frontend] fix: fix sonar issue (#1145)

* [ADM-793] refactor: rename AXIOS_REQUEST_ERROR_CODE

* AMD-793 [frontend] fix: update alert position to keep element still

* [ADM-793] feat: enhance style for alert

* [ADM-793] feat: change moduleType text

* [ADM-793] style: enhance style

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: yp.wu <yiping.wu@yipings-MacBook-Pro.local>
Co-authored-by: xuebing <xuebing.li@thoughtworks.com>
Co-authored-by: yp.wu <yiping.wu@192.168.10.4>
Co-authored-by: Steveay <907221539@qq.com>
Co-authored-by: guzhongren <guzhongren@live.cn>
Co-authored-by: Genhao Liu <103744663+Liughgood@users.noreply.github.com>
Co-authored-by: yulongcai <yulong.cai@thoughtworks.com>
Co-authored-by: neomgb <123063936+neomgb@users.noreply.github.com>
Co-authored-by: Leiqiuhong <qiuhong.lei@thoughtworks.com>
Co-authored-by: sqsq5566 <154306546+sqsq5566@users.noreply.github.com>
Co-authored-by: Yunlong Gan <yunlong.gan@thoughtworks.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: 李雪冰 <33832990+lxuebing@users.noreply.github.com>
Co-authored-by: Chao <89126516+mrcuriosity-tw@users.noreply.github.com>
  • Loading branch information
15 people authored Mar 14, 2024
1 parent de2b97a commit d10482c
Show file tree
Hide file tree
Showing 39 changed files with 530 additions and 189 deletions.
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) => {
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) => {
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

0 comments on commit d10482c

Please sign in to comment.