Skip to content

Commit

Permalink
[Behavioral Analytics] Fix CI errors
Browse files Browse the repository at this point in the history
  • Loading branch information
yansavitski committed Apr 24, 2023
1 parent e77ba1b commit 188c94e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('FetchAnalyticsCollectionsApiLogic', () => {
it('calls the analytics collections list api', async () => {
const promise = Promise.resolve([{ name: 'result' }]);
http.get.mockReturnValue(promise);
const result = fetchAnalyticsCollections();
const result = fetchAnalyticsCollections({});
await nextTick();
expect(http.get).toHaveBeenCalledWith('/internal/enterprise_search/analytics/collections');
await expect(result).resolves.toEqual([{ name: 'result' }]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { HttpLogic } from '../../../shared/http';
export type FetchAnalyticsCollectionsApiLogicResponse = AnalyticsCollection[];

interface FetchAnalyticsCollectionsApiLogicArgs {
query: string;
query?: string;
}

export const fetchAnalyticsCollections = async ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { EuiButtonGroup, EuiSuperDatePicker } from '@elastic/eui';
import { AnalyticsCollection } from '../../../../../common/types/analytics';

import { AnalyticsCollectionCardWithLens } from './analytics_collection_card/analytics_collection_card';
import { AnalyticsCollectionNotFound } from './analytics_collection_not_found';

import { AnalyticsCollectionTable } from './analytics_collection_table';

Expand All @@ -30,36 +31,43 @@ describe('AnalyticsCollectionTable', () => {
name: 'example2',
},
];
const props = {
collections: analyticsCollections,
isSearching: false,
onSearch: jest.fn(),
};

beforeEach(() => {
jest.clearAllMocks();
});

it('renders cards', () => {
const wrapper = shallow(<AnalyticsCollectionTable collections={analyticsCollections} />);
const wrapper = shallow(<AnalyticsCollectionTable {...props} />);
const collectionCards = wrapper.find(AnalyticsCollectionCardWithLens);

expect(collectionCards).toHaveLength(analyticsCollections.length);
expect(collectionCards.at(1).prop('collection')).toMatchObject(analyticsCollections[1]);
});

it('renders filters', () => {
const buttonGroup = shallow(
<AnalyticsCollectionTable collections={analyticsCollections} />
).find(EuiButtonGroup);
const buttonGroup = shallow(<AnalyticsCollectionTable {...props} />).find(EuiButtonGroup);

expect(buttonGroup).toHaveLength(1);
expect(buttonGroup.prop('options')).toHaveLength(4);
expect(buttonGroup.prop('idSelected')).toEqual('Searches');
});

it('renders datePick', () => {
const datePicker = shallow(
<AnalyticsCollectionTable collections={analyticsCollections} />
).find(EuiSuperDatePicker);
const datePicker = shallow(<AnalyticsCollectionTable {...props} />).find(EuiSuperDatePicker);

expect(datePicker).toHaveLength(1);
expect(datePicker.prop('start')).toEqual('now-7d');
expect(datePicker.prop('end')).toEqual('now');
});

it('renders not found page', () => {
const wrapper = shallow(<AnalyticsCollectionTable {...props} collections={[]} />);

expect(wrapper.find(AnalyticsCollectionNotFound)).toHaveLength(1);
});
});

0 comments on commit 188c94e

Please sign in to comment.