Skip to content

Commit

Permalink
[frontend]ADM-793: add test and change word for alter (#1182)
Browse files Browse the repository at this point in the history
* [ADM-793] test: add test for hidden alert when reset

* [ADM-793] feat: change word for alert

* [ADM-793] test: reset mock for timeout

* ADM-857:[backend]feat: add check buildkite status (#1179)

* ADM-857:[backend]feat: new Github action to see if it can check committer name

* ADM-857:[backend]feat: test getting pr username and compare

* ADM-857:[backend]feat: fix name comparison

* ADM-857:[backend]feat: completed name comparison

* ADM-857:[backend]feat: integrated name comparison into build pipeline fail check

* ADM-857:[backend]feat: add message when build pipeline was successful

* ADM-857:[backend]feat: make check build status needed by deploy infra

* ADM-857:[backend]refactor: move buildkite check logic for check.sh

* ADM-857:[backend]refactor: transfer param for check shell script

* ADM-857:[backend]refactor: update check buildkite status event name

* ADM-857:[backend]feat: add check buildkite status not contains revert

---------

Co-authored-by: PengxiWPix <pengxi.wang@thoughtworks.com>

* ADM-691:[frontend][backend] feat: calculate all card rework metrics (#1172)

* 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>
(cherry picked from commit f775626)

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

(cherry picked from commit 2bb3cdb)

* ADM-691: [frontend] fix: fix show more logic

* ADM-691: [frontend] fix: fix selecting all logic

* ADM-692:[backend] feat: init dto

* ADM-692:[backend] feat: calculate reworkTimesInfos

* ADM-692:[backend] feat: calculate rework card number and rework ratio

* ADM-692:[backend] feat: repair mock data

* ADM-692:[backend] feat: add test for get real done card rework given not consider flag as block

* ADM-692:[backend] feat: add calculate total rework time for every done card

* ADM-692:[backend] test: get real done card rework given consider flag as block

* ADM-692:[backend] fix: set treat flag card as block

* ADM-692:[backend] feat: refactor code and design request state

* ADM-692: [backend] test: modify test mock data to cover some missed code branch

* ADM-692:[backend] feat: calculate all card rework metrics

* ADM-692:[backend] test: calculate all card rework metrics

* ADM-692:[backend] fix: use get enum rework state

* ADM-692:[backend] test: throw exception when calculate rework given analyse state in rework times info list

* ADM-692:[backend] fix: lake the case of Testing in test

* ADM-692:[backend] feat: add rework metric

* ADM-692:[backend] test: add rework metric

* ADM-692:[backend] test: save report of rework info

* ADM-692:[backend] fix: use rework times

* ADM-692:[backend] fix: use word 'excluded'

* ADM-692:[backend] fix: use String to check

* ADM-692:[backend] fix: rebuild state map

* ADM-692:[backend] refactor: format code

* ADM-692:[backend] feat: set rework in response

* ADM-691: [frontend] fix: fix next button display logic

* ADM-692:[backend] feat: valid rework state not blank

* Revert "ADM-692:[backend] feat: valid rework state not blank"

This reverts commit 7a4792f.

* ADM-692:[backend] feat: refactor code for calculate cycle and rework branch

* ADM-692:[backend] refactor: format code

* ADM-692:[backend] fix: sonar issues

* ADM-692:[backend] refactor: format code

* ADM-692:[backend] feat: add test to coverage code

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

* ADM-692:[backend] refactor: format code

* ADM-692:[backend] feat:fix sonar test coverage

---------

Co-authored-by: neomgb <123063936+neomgb@users.noreply.github.com>
Co-authored-by: GuangbinMa <guangbin.ma@thoughtworks.com>
Co-authored-by: yulongcai <yulong.cai@thoughtworks.com>
Co-authored-by: Shiqi Yuan <shiqi.yuan@thoughtworks.com>
Co-authored-by: Leiqiuhong <qiuhong.lei@thoughtworks.com>
Co-authored-by: yulongcai <141199398+yulongcai@users.noreply.github.com>
Co-authored-by: guzhongren <guzhongren@live.cn>

---------

Co-authored-by: Steveay <907221539@qq.com>
Co-authored-by: PengxiWPix <pengxi.wang@thoughtworks.com>
Co-authored-by: Genhao Liu <103744663+Liughgood@users.noreply.github.com>
Co-authored-by: neomgb <123063936+neomgb@users.noreply.github.com>
Co-authored-by: GuangbinMa <guangbin.ma@thoughtworks.com>
Co-authored-by: yulongcai <yulong.cai@thoughtworks.com>
Co-authored-by: Shiqi Yuan <shiqi.yuan@thoughtworks.com>
Co-authored-by: Leiqiuhong <qiuhong.lei@thoughtworks.com>
Co-authored-by: yulongcai <141199398+yulongcai@users.noreply.github.com>
Co-authored-by: guzhongren <guzhongren@live.cn>
  • Loading branch information
11 people authored Mar 15, 2024
1 parent 079c32c commit 7be6679
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
21 changes: 21 additions & 0 deletions frontend/__tests__/containers/ConfigStep/Board.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import {
FAKE_TOKEN,
} from '../../fixtures';
import { render, screen, waitFor, within } from '@testing-library/react';
import { AXIOS_REQUEST_ERROR_CODE } from '@src/constants/resources';
import { boardClient } from '@src/clients/board/BoardClient';
import { Board } from '@src/containers/ConfigStep/Board';
import { setupStore } from '../../utils/setupStoreUtil';
import { TimeoutError } from '@src/errors/TimeoutError';
import userEvent from '@testing-library/user-event';
import { Provider } from 'react-redux';
import { setupServer } from 'msw/node';
Expand Down Expand Up @@ -42,6 +45,8 @@ const mockVerifySuccess = (delay = 0) => {
);
};

const originalGetVerifyBoard = boardClient.getVerifyBoard;

describe('Board', () => {
beforeAll(() => {
server.listen();
Expand All @@ -60,6 +65,7 @@ describe('Board', () => {

afterEach(() => {
store = null;
boardClient.getVerifyBoard = originalGetVerifyBoard;
});

it('should show board title and fields when render board component ', () => {
Expand Down Expand Up @@ -167,6 +173,21 @@ describe('Board', () => {
});
});

it('should hidden timeout alert when click reset button', async () => {
const { getByTestId, queryByTestId } = setup();
await fillBoardFieldsInformation();
const mockedError = new TimeoutError('', AXIOS_REQUEST_ERROR_CODE.TIMEOUT);
boardClient.getVerifyBoard = jest.fn().mockImplementation(() => Promise.reject(mockedError));

await userEvent.click(screen.getByText(VERIFY));

expect(getByTestId('timeoutAlert')).toBeInTheDocument();

await userEvent.click(screen.getByRole('button', { name: RESET }));

expect(queryByTestId('timeoutAlert')).not.toBeInTheDocument();
});

it('should show reset button and verified button when verify succeed ', async () => {
mockVerifySuccess();
setup();
Expand Down
19 changes: 19 additions & 0 deletions frontend/__tests__/containers/ConfigStep/PipelineTool.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {
FAKE_PIPELINE_TOKEN,
} from '../../fixtures';
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import { pipelineToolClient } from '@src/clients/pipeline/PipelineToolClient';
import { PipelineTool } from '@src/containers/ConfigStep/PipelineTool';
import { AXIOS_REQUEST_ERROR_CODE } from '@src/constants/resources';
import { setupStore } from '../../utils/setupStoreUtil';
import userEvent from '@testing-library/user-event';
import { Provider } from 'react-redux';
Expand All @@ -32,6 +34,8 @@ let store = null;

const server = setupServer(rest.post(MOCK_PIPELINE_VERIFY_URL, (req, res, ctx) => res(ctx.status(204))));

const originalVerify = pipelineToolClient.verify;

describe('PipelineTool', () => {
beforeAll(() => server.listen());
afterAll(() => server.close());
Expand All @@ -46,6 +50,7 @@ describe('PipelineTool', () => {
};
afterEach(() => {
store = null;
pipelineToolClient.verify = originalVerify;
});

it('should show pipelineTool title and fields when render pipelineTool component ', () => {
Expand Down Expand Up @@ -103,6 +108,20 @@ describe('PipelineTool', () => {
expect(queryByRole('button', { name: VERIFY })).toBeDisabled();
});

it('should hidden timeout alert when click reset button', async () => {
const { getByTestId, queryByTestId } = setup();
await fillPipelineToolFieldsInformation();
pipelineToolClient.verify = jest.fn().mockResolvedValue({ code: AXIOS_REQUEST_ERROR_CODE.TIMEOUT });

await userEvent.click(screen.getByText(VERIFY));

expect(getByTestId('timeoutAlert')).toBeInTheDocument();

await userEvent.click(screen.getByRole('button', { name: RESET }));

expect(queryByTestId('timeoutAlert')).not.toBeInTheDocument();
});

it('should show detail options when click pipelineTool fields', async () => {
const { getByRole } = setup();
await userEvent.click(screen.getByRole('button', { name: 'Pipeline Tool' }));
Expand Down
21 changes: 20 additions & 1 deletion frontend/__tests__/containers/ConfigStep/SourceControl.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import {
VERIFY,
} from '../../fixtures';
import { initDeploymentFrequencySettings, updateShouldGetPipelineConfig } from '@src/context/Metrics/metricsSlice';
import { AXIOS_REQUEST_ERROR_CODE, SOURCE_CONTROL_TYPES } from '@src/constants/resources';
import { sourceControlClient } from '@src/clients/sourceControl/SourceControlClient';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { SourceControl } from '@src/containers/ConfigStep/SourceControl';
import { SOURCE_CONTROL_TYPES } from '@src/constants/resources';
import { setupStore } from '../../utils/setupStoreUtil';
import userEvent from '@testing-library/user-event';
import { Provider } from 'react-redux';
Expand All @@ -36,6 +37,8 @@ let store = null;

const server = setupServer(rest.post(MOCK_SOURCE_CONTROL_VERIFY_TOKEN_URL, (req, res, ctx) => res(ctx.status(204))));

const originalVerifyToken = sourceControlClient.verifyToken;

jest.mock('@src/context/Metrics/metricsSlice', () => ({
...jest.requireActual('@src/context/Metrics/metricsSlice'),
updateShouldGetPipelineConfig: jest.fn().mockReturnValue({ type: 'SHOULD_UPDATE_PIPELINE_CONFIG' }),
Expand All @@ -56,6 +59,7 @@ describe('SourceControl', () => {
};
afterEach(() => {
store = null;
sourceControlClient.verifyToken = originalVerifyToken;
});

it('should show sourceControl title and fields when render sourceControl component', () => {
Expand Down Expand Up @@ -93,6 +97,21 @@ describe('SourceControl', () => {
expect(screen.getByRole('button', { name: VERIFY })).toBeDisabled();
});

it('should hidden timeout alert when click reset button', async () => {
const { getByTestId, queryByTestId } = setup();
await fillSourceControlFieldsInformation();
sourceControlClient.verifyToken = jest.fn().mockResolvedValue({
code: AXIOS_REQUEST_ERROR_CODE.TIMEOUT,
});

await userEvent.click(screen.getByText(VERIFY));
expect(getByTestId('timeoutAlert')).toBeInTheDocument();

await userEvent.click(screen.getByRole('button', { name: RESET }));

expect(queryByTestId('timeoutAlert')).not.toBeInTheDocument();
});

it('should enable verify button when all fields checked correctly given disable verify button', () => {
setup();
const verifyButton = screen.getByRole('button', { name: VERIFY });
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/containers/ConfigStep/TimeoutAlert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ export const TimeoutAlert = ({ isVerifyTimeOut, isShowAlert, setIsShowAlert, mod
<>
{isVerifyTimeOut && isShowAlert && (
<StyledAlert
data-testid='timeoutAlert'
icon={<CancelIcon fontSize='inherit' />}
severity='error'
onClose={() => {
setIsShowAlert(false);
}}
>
<EllipsisText fitContent>
Submission timeout on <StyledModuleType>{moduleType}</StyledModuleType> , please reverify!
Submission timeout on <StyledModuleType>{moduleType}</StyledModuleType>, please reverify!
</EllipsisText>
</StyledAlert>
)}
Expand Down

0 comments on commit 7be6679

Please sign in to comment.