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

[Cases] Filter user activities pagination #152702

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
2f90fd5
add user actions list component
js-jankisalvi Feb 27, 2023
4add110
use infinite query to fetch top user action data
js-jankisalvi Mar 1, 2023
229e75b
finalise user action list component, added useInfiniteQuery hook for …
js-jankisalvi Mar 2, 2023
85b59d2
added create case activity, fixed affected unit tests
js-jankisalvi Mar 6, 2023
5712a91
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Mar 6, 2023
1ce3fea
add user actions list component
js-jankisalvi Feb 27, 2023
20ad650
use infinite query to fetch top user action data
js-jankisalvi Mar 1, 2023
0e0072b
finalise user action list component, added useInfiniteQuery hook for …
js-jankisalvi Mar 2, 2023
8a78566
added create case activity, fixed affected unit tests
js-jankisalvi Mar 6, 2023
de9e839
Merge branch 'filter-activities-pagination' of https://github.com/js-…
js-jankisalvi Mar 6, 2023
b82a656
unit tests refactored
js-jankisalvi Mar 6, 2023
e1a0526
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Mar 6, 2023
db96b3a
fixed unit tests
js-jankisalvi Mar 7, 2023
286e6f4
e2e tests fixed
js-jankisalvi Mar 9, 2023
3f77daa
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Mar 9, 2023
81378e9
clean up
js-jankisalvi Mar 9, 2023
e0c26ea
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Mar 9, 2023
b147bcd
added css to handle connection of 2 comment list, moved user action f…
js-jankisalvi Mar 10, 2023
72dead5
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Mar 10, 2023
1a727bd
last page to be positive check
js-jankisalvi Mar 10, 2023
f8b3b87
Merge branch 'filter-activities-pagination' of https://github.com/js-…
js-jankisalvi Mar 10, 2023
4f9fd66
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Mar 23, 2023
28d99ba
call use update pagination hook only once
js-jankisalvi Mar 24, 2023
dd45bca
lint fix
js-jankisalvi Mar 24, 2023
a5fbbda
separate component for show more button, fix functional test
js-jankisalvi Mar 24, 2023
a69209d
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Mar 24, 2023
1fcd045
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Mar 24, 2023
15bd9f6
handled scenarios to prevent unnecessary rerenders of pagination and …
js-jankisalvi Mar 27, 2023
b2dda6a
removed console log
js-jankisalvi Mar 27, 2023
f67c79d
removed unnecessary check
js-jankisalvi Mar 27, 2023
dbc3d8d
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Mar 27, 2023
4221797
added e2e test to verify show load more button behaviour
js-jankisalvi Mar 27, 2023
16062a0
Merge branch 'filter-activities-pagination' of https://github.com/js-…
js-jankisalvi Mar 27, 2023
f7fb5f2
update unit test
js-jankisalvi Mar 27, 2023
2b3253d
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Mar 27, 2023
d425b62
removed css as it breaks normal add comment view
js-jankisalvi Mar 27, 2023
4edefb8
add conditional comment for comment
js-jankisalvi Mar 27, 2023
0c26735
show load more bug fix
js-jankisalvi Mar 28, 2023
60e6e6b
loading action bug fixed
js-jankisalvi Mar 28, 2023
9ce2de8
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Mar 28, 2023
4b8b3bf
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Mar 28, 2023
2b9f4e0
removed useRef variables
js-jankisalvi Mar 28, 2023
e9114b6
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Mar 28, 2023
f043862
created separate functionality to generate user actions
js-jankisalvi Mar 29, 2023
d4f0d77
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Mar 29, 2023
7291471
review comments addressed part 1
js-jankisalvi Mar 29, 2023
02b5c86
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Mar 29, 2023
4ea9bd2
review comment addressed part 2
js-jankisalvi Mar 30, 2023
387e6fc
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Mar 30, 2023
17dacd3
e2e test updated using updateCase API
js-jankisalvi Mar 30, 2023
037075a
Merge branch 'filter-activities-pagination' of https://github.com/js-…
js-jankisalvi Mar 30, 2023
02d091e
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Mar 30, 2023
abc0c00
fixed 21 user actions unit test
js-jankisalvi Mar 30, 2023
37cd8ba
functional tests update
js-jankisalvi Mar 30, 2023
f9f7ddc
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Mar 30, 2023
4ce66d3
fetch next page param unit test fixed
js-jankisalvi Mar 31, 2023
eab2761
Merge branch 'filter-activities-pagination' of https://github.com/js-…
js-jankisalvi Mar 31, 2023
fea8c9e
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Mar 31, 2023
e1ce393
review comments addressed
js-jankisalvi Mar 31, 2023
27f7aca
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Mar 31, 2023
42ba5c4
unit test updated
js-jankisalvi Apr 3, 2023
820a182
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Apr 3, 2023
5c20ba7
removed condition from loading
js-jankisalvi Apr 3, 2023
5c48cbb
Merge branch 'filter-activities-pagination' of https://github.com/js-…
js-jankisalvi Apr 3, 2023
bf46758
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Apr 3, 2023
c964977
adding isFetchingNextPage for show more button
js-jankisalvi Apr 3, 2023
fa142a3
Merge branch 'filter-activities-pagination' of https://github.com/js-…
js-jankisalvi Apr 3, 2023
7594ad4
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Apr 3, 2023
174d2ad
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Apr 3, 2023
024ff50
fix margin issue for page before last page
js-jankisalvi Apr 3, 2023
9ee979e
Merge branch 'filter-activities-pagination' of https://github.com/js-…
js-jankisalvi Apr 3, 2023
267eb84
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Apr 3, 2023
656cff0
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Apr 3, 2023
877c6a6
Merge branch 'main' into filter-activities-pagination
js-jankisalvi Apr 3, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
caseViewProps,
defaultGetCase,
defaultGetCaseMetrics,
defaultInfiniteUseFindCaseUserActions,
defaultUpdateCaseState,
defaultUseFindCaseUserActions,
} from './mocks';
Expand All @@ -39,13 +40,17 @@ import { userProfiles } from '../../containers/user_profiles/api.mock';
import { licensingMock } from '@kbn/licensing-plugin/public/mocks';
import { CASE_VIEW_PAGE_TABS } from '../../../common/types';
import { getCaseConnectorsMockResponse } from '../../common/mock/connectors';
import { useInfiniteFindCaseUserActions } from '../../containers/use_infinite_find_case_user_actions';
import { useGetCaseUserActionsStats } from '../../containers/use_get_case_user_actions_stats';

const mockSetTitle = jest.fn();

jest.mock('../../containers/use_get_action_license');
jest.mock('../../containers/use_update_case');
jest.mock('../../containers/use_get_case_metrics');
jest.mock('../../containers/use_find_case_user_actions');
jest.mock('../../containers/use_infinite_find_case_user_actions');
jest.mock('../../containers/use_get_case_user_actions_stats');
jest.mock('../../containers/use_get_tags');
jest.mock('../../containers/use_get_case');
jest.mock('../../containers/configure/use_get_supported_action_connectors');
Expand Down Expand Up @@ -80,6 +85,8 @@ const useUrlParamsMock = useUrlParams as jest.Mock;
const useCaseViewNavigationMock = useCaseViewNavigation as jest.Mock;
const useUpdateCaseMock = useUpdateCase as jest.Mock;
const useFindCaseUserActionsMock = useFindCaseUserActions as jest.Mock;
const useInfiniteFindCaseUserActionsMock = useInfiniteFindCaseUserActions as jest.Mock;
const useGetCaseUserActionsStatsMock = useGetCaseUserActionsStats as jest.Mock;
const useGetConnectorsMock = useGetSupportedActionConnectors as jest.Mock;
const usePostPushToServiceMock = usePostPushToService as jest.Mock;
const useGetCaseConnectorsMock = useGetCaseConnectors as jest.Mock;
Expand Down Expand Up @@ -111,21 +118,28 @@ export const caseClosedProps: CaseViewPageProps = {
caseData: basicCaseClosed,
};

const userActionsStats = {
total: 21,
totalComments: 9,
totalOtherActions: 11,
};

describe('CaseViewPage', () => {
const updateCaseProperty = defaultUpdateCaseState.updateCaseProperty;
const pushCaseToExternalService = jest.fn();
const data = caseProps.caseData;
let appMockRenderer: AppMockRenderer;
const caseConnectors = getCaseConnectorsMockResponse();
const caseUsers = getCaseUsersMockResponse();
const refetchFindCaseUserActions = jest.fn();

beforeEach(() => {
mockGetCase();
jest.clearAllMocks();
mockGetCase();
useUpdateCaseMock.mockReturnValue(defaultUpdateCaseState);
useGetCaseMetricsMock.mockReturnValue(defaultGetCaseMetrics);
useFindCaseUserActionsMock.mockReturnValue(defaultUseFindCaseUserActions);
useInfiniteFindCaseUserActionsMock.mockReturnValue(defaultInfiniteUseFindCaseUserActions);
useGetCaseUserActionsStatsMock.mockReturnValue({ data: userActionsStats, isLoading: false });
usePostPushToServiceMock.mockReturnValue({ isLoading: false, pushCaseToExternalService });
useGetCaseConnectorsMock.mockReturnValue({
isLoading: false,
Expand Down Expand Up @@ -349,22 +363,16 @@ describe('CaseViewPage', () => {
});
});

it('should show loading content when loading user actions', async () => {
it('should show loading content when loading user actions stats', async () => {
const useFetchAlertData = jest.fn().mockReturnValue([true]);
useFindCaseUserActionsMock.mockReturnValue({
data: undefined,
isError: false,
isLoading: true,
isFetching: true,
refetch: refetchFindCaseUserActions,
});
useGetCaseUserActionsStatsMock.mockReturnValue({ isLoading: true });

const result = appMockRenderer.render(
<CaseViewPage {...caseProps} useFetchAlertData={useFetchAlertData} />
);
await waitFor(() => {
expect(result.getByTestId('case-view-loading-content')).toBeInTheDocument();
expect(result.queryByTestId('user-actions')).not.toBeInTheDocument();
expect(result.queryByTestId('user-actions-list')).not.toBeInTheDocument();
});
});

Expand All @@ -374,7 +382,7 @@ describe('CaseViewPage', () => {
<CaseViewPage {...caseProps} showAlertDetails={showAlertDetails} />
);

userEvent.click(result.getByTestId('comment-action-show-alert-alert-action-id'));
userEvent.click(result.getAllByTestId('comment-action-show-alert-alert-action-id')[1]);

await waitFor(() => {
expect(showAlertDetails).toHaveBeenCalledWith('alert-id-1', 'alert-index-1');
Expand All @@ -387,7 +395,7 @@ describe('CaseViewPage', () => {
await waitFor(() => {
expect(
result
.getByTestId('user-action-alert-comment-create-action-alert-action-id')
.getAllByTestId('user-action-alert-comment-create-action-alert-action-id')[1]
.querySelector('.euiCommentEvent__headerEvent')
).toHaveTextContent('added an alert from Awesome rule');
});
Expand Down
Loading