Skip to content

Commit

Permalink
[Workplace Search] Add top-level tests for Groups (#81215) (#81425)
Browse files Browse the repository at this point in the history
* Update id of second sources mock to be unique

Both were originally set to ‘123’

* Remove unused types from interface

These were never used and were only uncovered while testing. These both exist on `group` but not at the top level.

* Add group mock

* Fix typo in reducer name

* Add tests for group_logic

* Remove redundant messages check

This is not needed with global flash messages, as the component will not render with no messages.

* Add tests for group_router

* Add group mock

* Add tests for groups_logic

* Convert groups_router to use children

This allow for testing the component visiblity and aligns with other usage of React Router

* Add tests for groups_router

* Refactor pagination logic

This commit removes the useDidUpdateEffect custom hook and moves the logic to fetch the search results to a listener inside of Kea.

* dd tests for main groups container

* Lint fixes

* Fix broken test and remove comment

The issue was that the delay needed to be in the catch block to properly execute.

* Add comments and make test explicit

In other places in the tests, we explicitly test for an error string in the catch block. Changing this to match.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
scottybollinger and kibanamachine authored Oct 22, 2020
1 parent eb05a56 commit 837f464
Show file tree
Hide file tree
Showing 17 changed files with 1,324 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jest.mock('react-router-dom', () => ({
...(jest.requireActual('react-router-dom') as object),
useHistory: jest.fn(() => mockHistory),
useLocation: jest.fn(() => mockLocation),
useParams: jest.fn(() => ({})),
}));

/**
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const contentSources = [
boost: 1,
},
{
id: '123',
id: '124',
serviceType: 'jira',
searchable: true,
supportedByLicense: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { IGroupValues } from '../group_logic';

import { IGroupDetails, ISourcePriority } from '../../../types';

export const mockGroupValues = {
group: {} as IGroupDetails,
dataLoading: true,
manageUsersModalVisible: false,
managerModalFormErrors: [],
sharedSourcesModalVisible: false,
confirmDeleteModalVisible: false,
groupNameInputValue: '',
selectedGroupSources: [],
selectedGroupUsers: [],
groupPrioritiesUnchanged: true,
activeSourcePriorities: {} as ISourcePriority,
cachedSourcePriorities: {} as ISourcePriority,
} as IGroupValues;
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { IGroupsValues } from '../groups_logic';

import { IContentSource, IUser, IGroup } from '../../../types';

import { DEFAULT_META } from '../../../../shared/constants';

export const mockGroupsValues = {
groups: [] as IGroup[],
contentSources: [] as IContentSource[],
users: [] as IUser[],
groupsDataLoading: true,
groupListLoading: true,
newGroupModalOpen: false,
newGroupName: '',
hasFiltersSet: false,
newGroup: null,
newGroupNameErrors: [],
filterSourcesDropdownOpen: false,
filteredSources: [],
filterUsersDropdownOpen: false,
filteredUsers: [],
allGroupUsersLoading: false,
allGroupUsers: [],
filterValue: '',
groupsMeta: DEFAULT_META,
} as IGroupsValues;
Loading

0 comments on commit 837f464

Please sign in to comment.