Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Yulong Ruan <[email protected]>
  • Loading branch information
ruanyl committed Jul 17, 2024
1 parent 841f18b commit 3113c02
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/plugins/data/common/search/opensearch_search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import { SearchResponse } from 'elasticsearch';
import { Search } from '@opensearch-project/opensearch/api/requestParams';
import { IOpenSearchDashboardsSearchRequest, IOpenSearchDashboardsSearchResponse } from '../types';
import { OpenSearchDashboardsRequest } from '../../../../../../src/core/server';

export const OPENSEARCH_SEARCH_STRATEGY = 'opensearch';
export const OPENSEARCH_SEARCH_WITH_LONG_NUMERALS_STRATEGY = 'opensearch-with-long-numerals';
Expand Down Expand Up @@ -60,7 +59,6 @@ export interface IOpenSearchSearchRequest
indexType?: string;
language?: string;
dataSourceId?: string;
rawRequest?: OpenSearchDashboardsRequest;
}

export type IOpenSearchSearchResponse<Source = any> = IOpenSearchDashboardsSearchResponse<
Expand Down
10 changes: 8 additions & 2 deletions src/plugins/data/server/search/routes/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ describe('Search service', () => {
await handler((mockContext as unknown) as RequestHandlerContext, mockRequest, mockResponse);

expect(mockDataStart.search.search).toBeCalled();
expect(mockDataStart.search.search.mock.calls[0][1]).toStrictEqual(mockBody);
expect(mockDataStart.search.search.mock.calls[0][1]).toStrictEqual({
...mockBody,
rawRequest: mockRequest,
});
expect(mockResponse.ok).toBeCalled();
expect(mockResponse.ok.mock.calls[0][0]).toEqual({
body: response,
Expand Down Expand Up @@ -125,7 +128,10 @@ describe('Search service', () => {
await handler((mockContext as unknown) as RequestHandlerContext, mockRequest, mockResponse);

expect(mockDataStart.search.search).toBeCalled();
expect(mockDataStart.search.search.mock.calls[0][1]).toStrictEqual(mockBody);
expect(mockDataStart.search.search.mock.calls[0][1]).toStrictEqual({
...mockBody,
rawRequest: mockRequest,
});
expect(mockResponse.customError).toBeCalled();
const error: any = mockResponse.customError.mock.calls[0][0];
expect(error.body.message).toBe('oh no');
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/data/server/search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export interface ISearchSetup {
}

export interface ISearchStart<
SearchStrategyRequest extends IOpenSearchDashboardsSearchRequest = IOpenSearchSearchRequest,
SearchStrategyRequest extends IOpenSearchDashboardsSearchRequest = IOpenSearchSearchRequest & {
rawRequest?: OpenSearchDashboardsRequest;
},
SearchStrategyResponse extends IOpenSearchDashboardsSearchResponse = IOpenSearchSearchResponse
> {
aggs: AggsStart;
Expand Down

0 comments on commit 3113c02

Please sign in to comment.