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-718[frontend][stub]feat: Display verification results of ‘board’ #985

Merged
merged 87 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
9c4f7fe
[kai.zhou][adm-718] feat: remove project key field
Jan 5, 2024
97f5e6f
[kai.zhou][adm-718]: feat: add addtional key for form field
Jan 5, 2024
3eb1c39
[kai.zhou][adm-718] fix unit test
Jan 9, 2024
4d8c641
[kai.zhou][adm-718]: fix: ignore no coverage function
Jan 9, 2024
878cd2a
[kai.zhou][adm-718]: feat: start integrate info api
Jan 11, 2024
030aec0
[kai.zhou][adm-718]: fix: fix code typo
Jan 11, 2024
cf9979c
[kai.zhou][adm-718]: feat: update error handle for verify api
Jan 16, 2024
b546f4f
[kai.zhou][adm-718]: feat: refact valid rule
Jan 18, 2024
6a84b19
[kai.zhou][adm-718]: update get info callback
Jan 18, 2024
cbf88a7
[kai.zhou][adm-718]: refact board info call in metric page
Jan 19, 2024
e55403e
[kai.zhou][adm-718]: create new empty content component
Jan 22, 2024
d452489
[kai.zhou][adm-718]: test: fix some unit test
Jan 22, 2024
f68f02d
ADM-747: [frontend] feat: handle error (#968)
JiangRu1 Jan 22, 2024
44a959e
[kai.zhou][adm-718]: refact board info call in metric page
Jan 19, 2024
82bae28
[kai.zhou][adm-718]: create new empty content component
Jan 22, 2024
e1af997
[kai.zhou][adm-718]: test: fix some unit test
Jan 22, 2024
0e93a10
[kai.zhou][adm-718]: chroe: format code
Jan 22, 2024
462151f
[kai.zhou][adm-718]: refact board info call in metric page
Jan 19, 2024
0d4cdca
[kai.zhou][adm-718]: create new empty content component
Jan 22, 2024
164962d
[kai.zhou][adm-718]: test: fix some unit test
Jan 22, 2024
c7c9404
[kai.zhou][adm-718]: refact board info call in metric page
Jan 19, 2024
ff4211d
[kai.zhou][adm-718]: test: fix some unit test
Jan 22, 2024
3b50a2a
[kai.zhou][adm-718]: chroe: format code
Jan 22, 2024
6f80293
[kai.zhou][adm-718]: fix failed unit test
Jan 23, 2024
cbfd7ba
[kai.zhou][adm-718]: add new stub for jira verify
Jan 23, 2024
6eb9016
[kai.zhou][adm-718]: fix failed unit test
Jan 23, 2024
3af99f8
[kai.zhou][adm-718]: add unit test for useVerifyBoardEffect
Jan 23, 2024
93ecd55
[kai.zhou][adm-718]: fix unit test coverage
Jan 23, 2024
64881a0
[kai.zhou][adm-718]: update e2e test
Jan 23, 2024
6cb6589
[kai.zhou][adm-718]: update e2e stub
Jan 23, 2024
7b9cd02
[kai.zhou][adm-718]: update stub data
Jan 24, 2024
128257e
ADM-718:[Frontend] Fix E2E stub data
SimonTal Jan 24, 2024
69e1412
ADM-718:[Frontend] Fix E2E stub data
SimonTal Jan 24, 2024
fb9db64
ADM-718:[Frontend] Fix E2E stub data
SimonTal Jan 24, 2024
6de2672
[kai.zhou][adm-718]: fix email fields not post and ignore some e2e sc…
Jan 24, 2024
dfb07c8
[kai.zhou][adm-718]: refact board info call in metric page
Jan 19, 2024
c447eb6
[kai.zhou][adm-718]: create new empty content component
Jan 22, 2024
e24a372
[kai.zhou][adm-718]: test: fix some unit test
Jan 22, 2024
f58fa59
ADM-747: [frontend] feat: handle error (#968)
JiangRu1 Jan 22, 2024
b5ba262
[kai.zhou][adm-718]: refact board info call in metric page
Jan 19, 2024
dafc760
[kai.zhou][adm-718]: test: fix some unit test
Jan 22, 2024
64c7f53
[kai.zhou][adm-718]: chroe: format code
Jan 22, 2024
d05421d
[ADM-740] show not show real done when cycle time by status (#972)
gabralia Jan 23, 2024
7cdf66a
[kai.zhou][adm-718]: refact board info call in metric page
Jan 19, 2024
d7196b1
[kai.zhou][adm-718]: create new empty content component
Jan 22, 2024
0b2c016
[kai.zhou][adm-718]: test: fix some unit test
Jan 22, 2024
17b9840
[kai.zhou][adm-718]: refact board info call in metric page
Jan 19, 2024
deb6193
[kai.zhou][adm-718]: test: fix some unit test
Jan 22, 2024
020009f
[kai.zhou][adm-718]: chroe: format code
Jan 22, 2024
d1d8744
[kai.zhou][adm-718]: fix failed unit test
Jan 23, 2024
c6b0a12
[kai.zhou][adm-718]: fix unit test coverage
Jan 23, 2024
6671e77
[kai.zhou][adm-718]: fix typo
Jan 24, 2024
df91e29
[kai.zhou][adm-718]: fix local conflict
Jan 24, 2024
8231147
[kai.zhou][adm-718]: fix failed test
Jan 24, 2024
c4c8dca
[kai.zhou][adm-718]: fix type
Jan 24, 2024
6ef2bad
[kai.zhou][adm-718]: fix code for review
Jan 25, 2024
3c91896
[kai.zhou][adm-718]: fix test typo
Jan 25, 2024
b86aeff
[kai.zhou][adm-718]: fix code styles
Jan 25, 2024
82829ba
[kai.zhou][adm-718]: fix failed test
Jan 25, 2024
fa119ac
[kai.zhou][adm-718]: refact email token mix
Jan 25, 2024
c766b65
[kai.zhou][adm-718]: add new test case
Jan 25, 2024
bed217c
[kai.zhou][adm-718]: fix code styles
Jan 26, 2024
d9839a5
[kai.zhou][adm-718]: skip e2e test for creat project
Jan 26, 2024
397818f
[kai.zhou][adm-718]: fix pr issue
Jan 26, 2024
00d5083
[kai.zhou][adm-718]: fix codacy issue
Jan 26, 2024
f8cb785
[kai.zhou][adm-718]: fix codacy issue
Jan 26, 2024
d4fb247
[kai.zhou][adm-718]: fix codacy issue
Jan 26, 2024
0d7d5b4
[kai.zhou][adm-718]: fix codacy issue
Jan 26, 2024
81f089a
[kai.zhou][adm-718]: fix failed test
Jan 26, 2024
ff8b1b3
[kai.zhou][adm-718]: refact unit test
Jan 29, 2024
e033db7
ADM-718:[Frontend] Fix Codacy issue
SimonTal Jan 29, 2024
f1b1a50
ADM-718:[Frontend] Fix rebase issue
SimonTal Jan 30, 2024
89a799f
ADM-718:[Frontend] Fix test case
SimonTal Jan 30, 2024
a358b60
[kai.zhou][adm-718]: fix not show form error
Jan 30, 2024
1e96503
[kai.zhou][adm-718]: fix issues about deskcheck
Jan 30, 2024
35d9121
ADM-718:[Frontend] Fix unit test case
SimonTal Jan 30, 2024
729cd14
[kai.zhou]: support reset error message when change form field
Jan 30, 2024
914144a
[kai.zhou][adm-718]: fix failed test
Jan 31, 2024
e1aa434
[kai.zhou][adm-718]: fix Classification can not update
Jan 31, 2024
d1c2eaf
[kai.zhou][adm-718]: refact unit test for classification
Feb 1, 2024
5793f11
Merge branch 'main' into feat/adm-718
Feb 1, 2024
84afc3b
[kai.zhou][adm-718]: fix failed lint
Feb 1, 2024
30fee84
[kai.zhou][adm-718]: fix lint warning
Feb 1, 2024
f26505d
Merge branch 'main' into feat/adm-718
Feb 1, 2024
757712e
ADM-718:[Frontend] Remove some comments for E2E tests
SimonTal Feb 1, 2024
8457000
[kai.zhou][adm-718]: fix form field warning
Feb 1, 2024
8c685ed
Merge branch 'main' into feat/adm-718
Feb 1, 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
12 changes: 4 additions & 8 deletions frontend/__tests__/client/BoardClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {
MOCK_BOARD_URL_FOR_CLASSIC_JIRA,
MOCK_BOARD_URL_FOR_JIRA,
MOCK_BOARD_VERIFY_REQUEST_PARAMS,
MOCK_CLASSIC_JIRA_BOARD_VERIFY_REQUEST_PARAMS,
MOCK_JIRA_BOARD_VERIFY_REQUEST_PARAMS,
VERIFY_ERROR_MESSAGE,
AXIOS_ERROR_MESSAGE,
} from '../fixtures';
Expand All @@ -11,10 +10,7 @@ import { setupServer } from 'msw/node';
import { HttpStatusCode } from 'axios';
import { rest } from 'msw';

const server = setupServer(
rest.post(MOCK_BOARD_URL_FOR_JIRA, (req, res, ctx) => res(ctx.status(HttpStatusCode.Ok))),
rest.post(MOCK_BOARD_URL_FOR_CLASSIC_JIRA, (req, res, ctx) => res(ctx.status(HttpStatusCode.Ok))),
);
const server = setupServer(rest.post(MOCK_BOARD_URL_FOR_JIRA, (req, res, ctx) => res(ctx.status(HttpStatusCode.Ok))));

describe('verify board request', () => {
beforeAll(() => server.listen());
Expand All @@ -26,8 +22,8 @@ describe('verify board request', () => {
expect(result.isBoardVerify).toEqual(true);
});

it('should isBoardVerify is true when select classic jira and board verify response status 200', async () => {
const result = await boardClient.getVerifyBoard(MOCK_CLASSIC_JIRA_BOARD_VERIFY_REQUEST_PARAMS);
it('should isBoardVerify is true when select jira and board verify response status 200', async () => {
const result = await boardClient.getVerifyBoard(MOCK_JIRA_BOARD_VERIFY_REQUEST_PARAMS);

expect(result.isBoardVerify).toEqual(true);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import DateRangeViewer from '@src/components/Common/DateRangeViewer';
import { render, screen } from '@testing-library/react';
import React from 'react';
describe('DateRangeVier', () => {
it('should show date when render component given startDate and endDate', () => {
render(<DateRangeViewer startDate={new Date('2022/1/1').toString()} endDate={new Date('2022/1/2').toString()} />);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import EmptyContent from '@src/components/Common/EmptyContent';
import { render, screen } from '@testing-library/react';

describe('EmptyContent', () => {
it('should show title and message when render EmptyContent given title and message', () => {
render(<EmptyContent title='Fake title' message='there is empty content' />);
expect(screen.getByText(/fake title/i)).toBeInTheDocument();
K-Chow marked this conversation as resolved.
Show resolved Hide resolved
expect(screen.getByText(/there is empty content/i)).toBeInTheDocument();
});
});
202 changes: 93 additions & 109 deletions frontend/__tests__/containers/ConfigStep/Board.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,48 @@ import {
CONFIG_TITLE,
ERROR_MESSAGE_COLOR,
MOCK_BOARD_URL_FOR_JIRA,
NO_CARD_ERROR_MESSAGE,
RESET,
VERIFIED,
VERIFY,
VERIFY_ERROR_MESSAGE,
VERIFY_FAILED,
FAKE_TOKEN,
} from '../../fixtures';
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import { render, screen, waitFor, within } from '@testing-library/react';
import { Board } from '@src/containers/ConfigStep/Board';
import { setupStore } from '../../utils/setupStoreUtil';
import userEvent from '@testing-library/user-event';
import { Provider } from 'react-redux';
import { setupServer } from 'msw/node';
import { HttpStatusCode } from 'axios';
import { rest } from 'msw';
import React from 'react';

export const fillBoardFieldsInformation = () => {
const fields = ['Board Id', 'Email', 'Project Key', 'Site', 'Token'];
const mockInfo = ['2', '[email protected]', 'mockKey', '1', 'mockToken'];
const fieldInputs = fields.map((label) => screen.getByTestId(label).querySelector('input') as HTMLInputElement);
fieldInputs.map((input, index) => {
fireEvent.change(input, { target: { value: mockInfo[index] } });
});
fieldInputs.map((input, index) => {
expect(input.value).toEqual(mockInfo[index]);
});

export const fillBoardFieldsInformation = async () => {
await userEvent.type(screen.getByLabelText(/board id/i), '1');
await userEvent.type(screen.getByLabelText(/email/i), '[email protected]');
await userEvent.type(screen.getByLabelText(/site/i), 'fake');
await userEvent.type(screen.getByLabelText(/token/i), FAKE_TOKEN);
};

let store = null;

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

const mockVerifySuccess = (delay = 0) => {
server.use(
rest.post(MOCK_BOARD_URL_FOR_JIRA, (_, res, ctx) =>
res(
ctx.json({
projectKey: 'FAKE',
}),
ctx.delay(delay),
),
),
);
};

describe('Board', () => {
beforeAll(() => server.listen());
beforeAll(() => {
server.listen();
});
afterAll(() => server.close());

store = setupStore();
Expand All @@ -56,7 +64,6 @@ describe('Board', () => {

it('should show board title and fields when render board component ', () => {
setup();

BOARD_FIELDS.map((field) => {
expect(screen.getByLabelText(`${field} *`)).toBeInTheDocument();
});
Expand All @@ -65,17 +72,16 @@ describe('Board', () => {

it('should show default value jira when init board component', () => {
setup();
const boardType = screen.getByText(BOARD_TYPES.JIRA);
const boardType = screen.getByRole('button', {
name: /board/i,
});

expect(boardType).toBeInTheDocument();

const option = screen.queryByText(BOARD_TYPES.CLASSIC_JIRA);
expect(option).not.toBeTruthy();
});

it('should show detail options when click board field', () => {
it('should show detail options when click board field', async () => {
setup();
fireEvent.mouseDown(screen.getByRole('button', { name: CONFIG_TITLE.BOARD }));
await userEvent.click(screen.getByRole('button', { name: /board jira/i }));
const listBox = within(screen.getByRole('listbox'));
const options = listBox.getAllByRole('option');
const optionValue = options.map((li) => li.getAttribute('data-value'));
Expand All @@ -85,149 +91,127 @@ describe('Board', () => {

it('should show board type when select board field value ', async () => {
setup();
await userEvent.click(screen.getByRole('button', { name: /board jira/i }));

fireEvent.mouseDown(screen.getByRole('button', { name: CONFIG_TITLE.BOARD }));
fireEvent.click(screen.getByText(BOARD_TYPES.CLASSIC_JIRA));
await waitFor(() => {
expect(screen.getByRole('option', { name: /jira/i })).toBeInTheDocument();
});

await userEvent.click(screen.getByRole('option', { name: /jira/i }));

await waitFor(() => {
expect(screen.getByText(BOARD_TYPES.CLASSIC_JIRA)).toBeInTheDocument();
expect(
screen.getByRole('button', {
name: /board/i,
}),
).toBeInTheDocument();
});
});

it('should show error message when input a wrong type or empty email ', async () => {
setup();
const EMAil_INVALID_ERROR_MESSAGE = 'Email is invalid!';
const emailInput = screen.getByTestId('Email').querySelector('input') as HTMLInputElement;

fireEvent.change(emailInput, { target: { value: 'wrong type email' } });

expect(screen.getByText(EMAil_INVALID_ERROR_MESSAGE)).toBeVisible();
expect(screen.getByText(EMAil_INVALID_ERROR_MESSAGE)).toHaveStyle(ERROR_MESSAGE_COLOR);
const emailInput = screen.getByRole('textbox', {
name: /email/i,
});

fireEvent.change(emailInput, { target: { value: '' } });
await userEvent.type(emailInput, 'wrong@email');

const EMAIL_REQUIRE_ERROR_MESSAGE = 'Email is required!';
expect(screen.getByText(EMAIL_REQUIRE_ERROR_MESSAGE)).toBeVisible();
});
await waitFor(() => {
expect(screen.getByText(EMAil_INVALID_ERROR_MESSAGE)).toBeVisible();
});

it('should clear other fields information when change board field selection', () => {
setup();
const boardIdInput = screen.getByRole('textbox', {
name: 'Board Id',
}) as HTMLInputElement;
const emailInput = screen.getByRole('textbox', {
name: 'Email',
}) as HTMLInputElement;
expect(screen.getByText(EMAil_INVALID_ERROR_MESSAGE)).toHaveStyle(ERROR_MESSAGE_COLOR);

fireEvent.change(boardIdInput, { target: { value: 2 } });
fireEvent.change(emailInput, { target: { value: '[email protected]' } });
fireEvent.mouseDown(screen.getByRole('button', { name: CONFIG_TITLE.BOARD }));
fireEvent.click(screen.getByText(BOARD_TYPES.CLASSIC_JIRA));
await userEvent.clear(emailInput);

expect(emailInput.value).toEqual('');
expect(boardIdInput.value).toEqual('');
await waitFor(() => {
expect(screen.getByText('Email is required!')).toBeVisible();
});
});

it('should clear all fields information when click reset button', async () => {
setup();
const fieldInputs = BOARD_FIELDS.slice(1, 5).map(
(label) =>
screen.getByRole('textbox', {
name: label,
hidden: true,
}) as HTMLInputElement,
);
fillBoardFieldsInformation();
mockVerifySuccess();
await fillBoardFieldsInformation();

fireEvent.click(screen.getByText(VERIFY));
await waitFor(() => {
fireEvent.click(screen.getByRole('button', { name: RESET }));
expect(screen.getByRole('button', { name: /verify/i })).not.toBeDisabled();
});

fieldInputs.map((input) => {
expect(input.value).toEqual('');
await userEvent.click(screen.getByText(/verify/i));

await waitFor(() => {
expect(screen.getByRole('button', { name: /reset/i })).toBeInTheDocument();
});
expect(screen.getByText(BOARD_TYPES.JIRA)).toBeInTheDocument();
expect(screen.queryByRole('button', { name: RESET })).not.toBeTruthy();
expect(screen.queryByRole('button', { name: VERIFY })).toBeDisabled();
});
expect(screen.queryByRole('button', { name: /verified/i })).toBeDisabled();

it('should enabled verify button when all fields checked correctly given disable verify button', () => {
setup();
const verifyButton = screen.getByRole('button', { name: VERIFY });
await userEvent.click(screen.getByRole('button', { name: /reset/i }));

expect(verifyButton).toBeDisabled();
await waitFor(() => {
expect(screen.getByLabelText(/board id/i)).not.toHaveValue();
});
expect(screen.getByLabelText(/email/i)).not.toHaveValue();
expect(screen.getByLabelText(/site/i)).not.toHaveValue();
expect(screen.getByLabelText(/token/i)).not.toHaveValue();

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

fillBoardFieldsInformation();
await waitFor(() => {
expect(screen.getByRole('option', { name: /jira/i })).toBeInTheDocument();
});
await userEvent.click(screen.getByRole('option', { name: /jira/i }));

expect(verifyButton).toBeEnabled();
await waitFor(() => {
expect(screen.getByRole('button', { name: /board jira/i })).toBeInTheDocument();
});
});

it('should show reset button and verified button when verify succeed ', async () => {
mockVerifySuccess();
setup();
fillBoardFieldsInformation();
await fillBoardFieldsInformation();

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

await waitFor(() => {
expect(screen.getByText(RESET)).toBeVisible();
});

await waitFor(() => {
expect(screen.getByText(VERIFIED)).toBeTruthy();
});
expect(screen.getByText(VERIFIED)).toBeInTheDocument();
});

it('should called verifyBoard method once when click verify button', async () => {
mockVerifySuccess();
setup();
fillBoardFieldsInformation();
fireEvent.click(screen.getByRole('button', { name: VERIFY }));
await fillBoardFieldsInformation();
await userEvent.click(screen.getByRole('button', { name: /verify/i }));

await waitFor(() => {
expect(screen.getByText('Verified')).toBeInTheDocument();
});
});

it('should check loading animation when click verify button', async () => {
const { container } = setup();
fillBoardFieldsInformation();
fireEvent.click(screen.getByRole('button', { name: VERIFY }));

await waitFor(() => {
expect(container.getElementsByTagName('span')[0].getAttribute('role')).toEqual('progressbar');
});
});

it('should check noCardPop show and disappear when board verify response status is 204', async () => {
server.use(rest.post(MOCK_BOARD_URL_FOR_JIRA, (req, res, ctx) => res(ctx.status(HttpStatusCode.NoContent))));
mockVerifySuccess(300);
setup();
fillBoardFieldsInformation();

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

await waitFor(() => {
expect(screen.getByText(NO_CARD_ERROR_MESSAGE)).toBeInTheDocument();
expect(screen.getByTestId('loading')).toBeInTheDocument();
});

fireEvent.click(screen.getByRole('button', { name: 'Ok' }));
expect(screen.getByText(NO_CARD_ERROR_MESSAGE)).not.toBeVisible();
});

it('should check error notification show and disappear when board verify response status is 401', async () => {
server.use(
rest.post(MOCK_BOARD_URL_FOR_JIRA, (req, res, ctx) =>
res(ctx.status(HttpStatusCode.Unauthorized), ctx.json({ hintInfo: VERIFY_ERROR_MESSAGE.UNAUTHORIZED })),
),
);
server.use(rest.post(MOCK_BOARD_URL_FOR_JIRA, (_, res, ctx) => res(ctx.status(HttpStatusCode.Unauthorized))));
setup();
fillBoardFieldsInformation();
await fillBoardFieldsInformation();

fireEvent.click(screen.getByRole('button', { name: VERIFY }));
await userEvent.click(screen.getByRole('button', { name: /verify/i }));

await waitFor(() => {
expect(
screen.getByText(`${BOARD_TYPES.JIRA} ${VERIFY_FAILED}: ${VERIFY_ERROR_MESSAGE.UNAUTHORIZED}`),
).toBeInTheDocument();
expect(screen.getByText(/email is incorrect/i)).toBeInTheDocument();
});
});
});
Loading
Loading