[App Search] Remove analytics tracking from the entire dashboard (#103534)
This commit is contained in:
parent
b6fb390ea9
commit
068aef82bc
|
@ -387,15 +387,12 @@ describe('RelevanceTuningLogic', () => {
|
|||
await nextTick();
|
||||
|
||||
expect(RelevanceTuningLogic.actions.setResultsLoading).toHaveBeenCalledWith(true);
|
||||
expect(http.post).toHaveBeenCalledWith(
|
||||
'/api/app_search/engines/test-engine/search_settings_search',
|
||||
{
|
||||
body: JSON.stringify(searchSettingsWithoutNewBoostProp),
|
||||
query: {
|
||||
query: 'foo',
|
||||
},
|
||||
}
|
||||
);
|
||||
expect(http.post).toHaveBeenCalledWith('/api/app_search/engines/test-engine/search', {
|
||||
body: JSON.stringify(searchSettingsWithoutNewBoostProp),
|
||||
query: {
|
||||
query: 'foo',
|
||||
},
|
||||
});
|
||||
expect(RelevanceTuningLogic.actions.setSearchResults).toHaveBeenCalledWith(searchResults);
|
||||
expect(clearFlashMessages).toHaveBeenCalled();
|
||||
});
|
||||
|
@ -420,15 +417,12 @@ describe('RelevanceTuningLogic', () => {
|
|||
jest.runAllTimers();
|
||||
await nextTick();
|
||||
|
||||
expect(http.post).toHaveBeenCalledWith(
|
||||
'/api/app_search/engines/test-engine/search_settings_search',
|
||||
{
|
||||
body: '{}',
|
||||
query: {
|
||||
query: 'foo',
|
||||
},
|
||||
}
|
||||
);
|
||||
expect(http.post).toHaveBeenCalledWith('/api/app_search/engines/test-engine/search', {
|
||||
body: '{}',
|
||||
query: {
|
||||
query: 'foo',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('will call clearSearchResults if there is no query', async () => {
|
||||
|
|
|
@ -268,7 +268,7 @@ export const RelevanceTuningLogic = kea<
|
|||
const { engineName } = EngineLogic.values;
|
||||
const { http } = HttpLogic.values;
|
||||
const { search_fields: searchFields, boosts } = removeBoostStateProps(values.searchSettings);
|
||||
const url = `/api/app_search/engines/${engineName}/search_settings_search`;
|
||||
const url = `/api/app_search/engines/${engineName}/search`;
|
||||
|
||||
actions.setResultsLoading(true);
|
||||
|
||||
|
|
|
@ -68,12 +68,16 @@ export const SampleResponseLogic = kea<MakeLogicType<SampleResponseValues, Sampl
|
|||
const { http } = HttpLogic.values;
|
||||
const { engineName } = EngineLogic.values;
|
||||
|
||||
const url = `/api/app_search/engines/${engineName}/sample_response_search`;
|
||||
const url = `/api/app_search/engines/${engineName}/search`;
|
||||
|
||||
try {
|
||||
const response = await http.post(url, {
|
||||
query: { query },
|
||||
body: JSON.stringify({
|
||||
query,
|
||||
page: {
|
||||
size: 1,
|
||||
current: 1,
|
||||
},
|
||||
result_fields: resultFields,
|
||||
}),
|
||||
});
|
||||
|
|
|
@ -82,7 +82,7 @@ describe('SearchLogic', () => {
|
|||
afterAll(() => jest.useRealTimers());
|
||||
|
||||
it('should make a GET API call with a search query', async () => {
|
||||
http.get.mockReturnValueOnce(Promise.resolve(MOCK_SEARCH_RESPONSE));
|
||||
http.post.mockReturnValueOnce(Promise.resolve(MOCK_SEARCH_RESPONSE));
|
||||
const logic = mountLogic();
|
||||
jest.spyOn(logic.actions, 'onSearch');
|
||||
|
||||
|
@ -90,14 +90,14 @@ describe('SearchLogic', () => {
|
|||
jest.runAllTimers();
|
||||
await nextTick();
|
||||
|
||||
expect(http.get).toHaveBeenCalledWith('/api/app_search/engines/some-engine/search', {
|
||||
expect(http.post).toHaveBeenCalledWith('/api/app_search/engines/some-engine/search', {
|
||||
query: { query: 'hello world' },
|
||||
});
|
||||
expect(logic.actions.onSearch).toHaveBeenCalledWith(MOCK_SEARCH_RESPONSE);
|
||||
});
|
||||
|
||||
it('handles errors', async () => {
|
||||
http.get.mockReturnValueOnce(Promise.reject('error'));
|
||||
http.post.mockReturnValueOnce(Promise.reject('error'));
|
||||
const logic = mountLogic();
|
||||
|
||||
logic.actions.search('test');
|
||||
|
|
|
@ -61,7 +61,7 @@ export const SearchLogic = kea<MakeLogicType<SearchValues, SearchActions>>({
|
|||
const { engineName } = EngineLogic.values;
|
||||
|
||||
try {
|
||||
const response = await http.get(`/api/app_search/engines/${engineName}/search`, {
|
||||
const response = await http.post(`/api/app_search/engines/${engineName}/search`, {
|
||||
query: { query },
|
||||
});
|
||||
actions.onSearch(response);
|
||||
|
|
|
@ -115,21 +115,4 @@ export function registerCurationsRoutes({
|
|||
path: '/as/engines/:engineName/curations/find_or_create',
|
||||
})
|
||||
);
|
||||
|
||||
router.get(
|
||||
{
|
||||
path: '/api/app_search/engines/{engineName}/curation_search',
|
||||
validate: {
|
||||
params: schema.object({
|
||||
engineName: schema.string(),
|
||||
}),
|
||||
query: schema.object({
|
||||
query: schema.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
enterpriseSearchRequestHandler.createRequest({
|
||||
path: '/api/as/v1/engines/:engineName/search.json',
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
@ -72,32 +72,4 @@ describe('result settings routes', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /api/app_search/engines/{name}/sample_response_search', () => {
|
||||
const mockRouter = new MockRouter({
|
||||
method: 'post',
|
||||
path: '/api/app_search/engines/{engineName}/sample_response_search',
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
registerResultSettingsRoutes({
|
||||
...mockDependencies,
|
||||
router: mockRouter.router,
|
||||
});
|
||||
});
|
||||
|
||||
it('creates a request to enterprise search', () => {
|
||||
mockRouter.callRoute({
|
||||
params: { engineName: 'some-engine' },
|
||||
body: {
|
||||
query: 'test',
|
||||
result_fields: resultFields,
|
||||
},
|
||||
});
|
||||
|
||||
expect(mockRequestHandler.createRequest).toHaveBeenCalledWith({
|
||||
path: '/as/engines/:engineName/sample_response_search',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -42,18 +42,4 @@ export function registerResultSettingsRoutes({
|
|||
path: '/as/engines/:engineName/result_settings',
|
||||
})
|
||||
);
|
||||
|
||||
router.post(
|
||||
skipBodyValidation({
|
||||
path: '/api/app_search/engines/{engineName}/sample_response_search',
|
||||
validate: {
|
||||
params: schema.object({
|
||||
engineName: schema.string(),
|
||||
}),
|
||||
},
|
||||
}),
|
||||
enterpriseSearchRequestHandler.createRequest({
|
||||
path: '/as/engines/:engineName/sample_response_search',
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ describe('search routes', () => {
|
|||
|
||||
it('creates a request handler', () => {
|
||||
expect(mockRequestHandler.createRequest).toHaveBeenCalledWith({
|
||||
path: '/api/as/v1/engines/:engineName/search.json',
|
||||
path: '/as/engines/:engineName/dashboard_search',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -22,8 +22,8 @@ export function registerSearchRoutes({
|
|||
router,
|
||||
enterpriseSearchRequestHandler,
|
||||
}: RouteDependencies) {
|
||||
router.get(
|
||||
{
|
||||
router.post(
|
||||
skipBodyValidation({
|
||||
path: '/api/app_search/engines/{engineName}/search',
|
||||
validate: {
|
||||
params: schema.object({
|
||||
|
@ -33,19 +33,15 @@ export function registerSearchRoutes({
|
|||
query: schema.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
}),
|
||||
enterpriseSearchRequestHandler.createRequest({
|
||||
path: '/api/as/v1/engines/:engineName/search.json',
|
||||
path: '/as/engines/:engineName/dashboard_search',
|
||||
})
|
||||
);
|
||||
|
||||
// For the Search UI routes below, Search UI always uses the full API path, like:
|
||||
// "/api/as/v1/engines/{engineName}/search.json". We only have control over the base path
|
||||
// in Search UI, so we created a common basepath of "/api/app_search/search-ui" here that
|
||||
// Search UI can use.
|
||||
//
|
||||
// Search UI *also* uses the click tracking and query suggestion endpoints, however, since the
|
||||
// App Search plugin doesn't use that portion of Search UI, we only set up a proxy for the search endpoint below.
|
||||
// Search UI always posts it's requests to {some_configured_base_url}/api/as/v1/engines/{engineName}/search.json
|
||||
// For that reason, we have to create a proxy url with that same suffix below, so that we can proxy Search UI
|
||||
// requests through Kibana's server.
|
||||
router.post(
|
||||
skipBodyValidation({
|
||||
path: '/api/app_search/search-ui/api/as/v1/engines/{engineName}/search.json',
|
||||
|
@ -56,7 +52,7 @@ export function registerSearchRoutes({
|
|||
},
|
||||
}),
|
||||
enterpriseSearchRequestHandler.createRequest({
|
||||
path: '/api/as/v1/engines/:engineName/search.json',
|
||||
path: '/as/engines/:engineName/dashboard_search',
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
@ -132,45 +132,4 @@ describe('search settings routes', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /api/app_search/engines/{name}/search_settings_search', () => {
|
||||
const mockRouter = new MockRouter({
|
||||
method: 'post',
|
||||
path: '/api/app_search/engines/{engineName}/search_settings_search',
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
registerSearchSettingsRoutes({
|
||||
...mockDependencies,
|
||||
router: mockRouter.router,
|
||||
});
|
||||
});
|
||||
|
||||
it('creates a request to enterprise search', () => {
|
||||
mockRouter.callRoute({
|
||||
params: { engineName: 'some-engine' },
|
||||
body: searchSettings,
|
||||
});
|
||||
|
||||
expect(mockRequestHandler.createRequest).toHaveBeenCalledWith({
|
||||
path: '/as/engines/:engineName/search_settings_search',
|
||||
});
|
||||
});
|
||||
|
||||
describe('validates query', () => {
|
||||
it('correctly', () => {
|
||||
const request = {
|
||||
query: {
|
||||
query: 'foo',
|
||||
},
|
||||
};
|
||||
mockRouter.shouldValidate(request);
|
||||
});
|
||||
|
||||
it('missing required fields', () => {
|
||||
const request = { query: {} };
|
||||
mockRouter.shouldThrow(request);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -56,21 +56,4 @@ export function registerSearchSettingsRoutes({
|
|||
path: '/as/engines/:engineName/search_settings',
|
||||
})
|
||||
);
|
||||
|
||||
router.post(
|
||||
skipBodyValidation({
|
||||
path: '/api/app_search/engines/{engineName}/search_settings_search',
|
||||
validate: {
|
||||
params: schema.object({
|
||||
engineName: schema.string(),
|
||||
}),
|
||||
query: schema.object({
|
||||
query: schema.string(),
|
||||
}),
|
||||
},
|
||||
}),
|
||||
enterpriseSearchRequestHandler.createRequest({
|
||||
path: '/as/engines/:engineName/search_settings_search',
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue