Add missing tests for curation panel refresh buttons (#130912)

This commit is contained in:
Efe Gürkan YALAMAN 2022-04-25 19:33:22 +02:00 committed by GitHub
parent 6d9a7ce4c8
commit 2ba68e7edc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 1 deletions

View file

@ -9,8 +9,14 @@ import React from 'react';
import { shallow } from 'enzyme';
import { EuiButtonEmpty } from '@elastic/eui';
import { nextTick } from '@kbn/test-jest-helpers';
import { EntSearchLogStream } from '../../../../shared/log_stream';
import { DataPanel } from '../../data_panel';
import { AutomatedCurationHistory } from './automated_curation_history';
describe('AutomatedCurationHistory', () => {
@ -20,4 +26,17 @@ describe('AutomatedCurationHistory', () => {
'appsearch.adaptive_relevance.query: some text and event.kind: event and event.dataset: search-relevance-suggestions and appsearch.adaptive_relevance.engine: foo and event.action: curation_suggestion and appsearch.adaptive_relevance.suggestion.new_status: automated'
);
});
it('sets new endTimestamp when refresh is pressed', async () => {
const wrapper = shallow(<AutomatedCurationHistory engineName="foo" query="some text" />);
const initialTimestamp = wrapper.find(EntSearchLogStream).prop('endTimestamp');
await nextTick();
// Find the refresh button and click
shallow(wrapper.find(DataPanel).prop('title')).find(EuiButtonEmpty).simulate('click');
wrapper.update();
expect(wrapper.find(EntSearchLogStream).prop('endTimestamp')).not.toEqual(initialTimestamp);
});
});

View file

@ -13,6 +13,10 @@ import React from 'react';
import { shallow } from 'enzyme';
import { EuiButtonEmpty } from '@elastic/eui';
import { nextTick } from '@kbn/test-jest-helpers';
import { EntSearchLogStream } from '../../../../../../shared/log_stream';
import { DataPanel } from '../../../../data_panel';
@ -32,4 +36,17 @@ describe('AutomatedCurationsHistoryPanel', () => {
'event.kind: event and event.dataset: search-relevance-suggestions and appsearch.adaptive_relevance.engine: some-engine and event.action: curation_suggestion and appsearch.adaptive_relevance.suggestion.new_status: automated'
);
});
it('sets new endTimestamp when refresh is pressed', async () => {
const wrapper = shallow(<AutomatedCurationsHistoryPanel />);
const initialTimestamp = wrapper.find(EntSearchLogStream).prop('endTimestamp');
await nextTick();
// Find the refresh button and click
shallow(wrapper.find(DataPanel).prop('title')).find(EuiButtonEmpty).simulate('click');
wrapper.update();
expect(wrapper.find(EntSearchLogStream).prop('endTimestamp')).not.toEqual(initialTimestamp);
});
});

View file

@ -15,7 +15,9 @@ import React from 'react';
import { shallow } from 'enzyme';
import { EuiBasicTable } from '@elastic/eui';
import { EuiBasicTable, EuiButtonEmpty } from '@elastic/eui';
import { DataPanel } from '../../../../../data_panel';
import { IgnoredQueriesPanel } from './ignored_queries_panel';
@ -91,4 +93,13 @@ describe('IgnoredQueriesPanel', () => {
expect(mockActions.onPaginate).toHaveBeenCalledWith(1);
});
it('fetches data on refresh button press', () => {
const wrapper = shallow(<IgnoredQueriesPanel />);
expect(mockActions.loadIgnoredQueries).toHaveBeenCalledTimes(1);
shallow(wrapper.find(DataPanel).prop('title')).find(EuiButtonEmpty).simulate('click');
expect(mockActions.loadIgnoredQueries).toHaveBeenCalledTimes(2);
});
});