Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Heenawter committed Jul 19, 2024
1 parent 229d241 commit 0ece8d7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@ import { SHOW_FIELD_STATISTICS } from '@kbn/discover-utils';
import { buildDataViewMock, deepMockedFields } from '@kbn/discover-utils/src/__mocks__';
import { BuildReactEmbeddableApiRegistration } from '@kbn/embeddable-plugin/public/react_embeddable_system/types';
import { PresentationContainer } from '@kbn/presentation-containers';
import {
PhaseEvent,
PublishesFilters,
PublishesUnifiedSearch,
StateComparators,
} from '@kbn/presentation-publishing';
import { PhaseEvent, PublishesUnifiedSearch, StateComparators } from '@kbn/presentation-publishing';
import { VIEW_MODE } from '@kbn/saved-search-plugin/common';
import { act, render } from '@testing-library/react';

import { AggregateQuery, Filter, Query, TimeRange } from '@kbn/es-query';
import { createDataViewDataSource } from '../../common/data_sources';
import { discoverServiceMock } from '../__mocks__/services';
import { getSearchEmbeddableFactory } from './get_search_embeddable_factory';
Expand All @@ -32,7 +28,6 @@ import {
SearchEmbeddableRuntimeState,
SearchEmbeddableSerializedState,
} from './types';
import { AggregateQuery, Filter, Query, TimeRange } from '@kbn/es-query';

describe('saved search embeddable', () => {
const mockServices = {
Expand Down
13 changes: 7 additions & 6 deletions src/plugins/discover/public/embeddable/initialize_fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,16 @@ export function initializeFetch({
const searchSessionId = fetchContext.searchSessionId;
const searchSourceQuery = savedSearch.searchSource.getField('query');

// Log request to inspector
requestAdapter.reset();

try {
api.dataLoading.next(true);

// Log request to inspector
requestAdapter.reset();
// Get new abort controller
const currentAbortController = new AbortController();
abortController = currentAbortController;

await discoverServices.profilesManager.resolveDataSourceProfile({
dataSource: isOfAggregateQueryType(searchSourceQuery)
? createEsqlDataSource()
Expand All @@ -141,10 +146,6 @@ export function initializeFetch({
query: searchSourceQuery,
});

// Get new abort controller
const currentAbortController = new AbortController();
abortController = currentAbortController;

const esqlMode = isEsqlMode(savedSearch);
if (
esqlMode &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ describe('Serialization utils', () => {
test('by reference', async () => {
discoverServiceMock.savedSearch.get = jest.fn().mockReturnValue({
savedObjectId: 'savedSearch',
...discoverServiceMock.savedSearch.byValueToSavedSearch(
...(await discoverServiceMock.savedSearch.byValueToSavedSearch(
{
attributes: mockedSavedSearchAttributes,
} as unknown as SavedSearchUnwrapResult,
true
),
)),
});

const serializedState: SerializedPanelState<SearchEmbeddableSerializedState> = {
Expand All @@ -93,7 +93,6 @@ describe('Serialization utils', () => {
serializedState,
discoverServices: discoverServiceMock,
});

expect(Object.keys(deserializedState)).toContain('serializedSearchSource');
expect(Object.keys(deserializedState)).toContain('savedObjectId');
expect(deserializedState.title).toEqual('test panel title');
Expand Down

0 comments on commit 0ece8d7

Please sign in to comment.