-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[data views editor] Disable loading rollups when rollups are disabled (…
…#184765) ## Summary Previously we were checking the `/api/rollup/indices` endpoint when the data view editor was loaded. If rollups were disabled, it would harmlessly handle a 404 error. Still, people justifiably wonder whether something is wrong. This PR skips checking the endpoint as one would expect. A unit test has been added. I also manually verified the behavior is as expected. Follow up to #162674 --------- Co-authored-by: Lukas Olson <[email protected]>
- Loading branch information
1 parent
9560481
commit 1772203
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/plugins/data_view_editor/public/data_view_editor_service.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { DataViewEditorService } from './data_view_editor_service'; | ||
import { HttpSetup } from '@kbn/core/public'; | ||
import { DataViewsServicePublic } from '@kbn/data-views-plugin/public'; | ||
|
||
describe('DataViewEditorService', () => { | ||
it('should check for rollup indices when rolls are enabled', () => { | ||
const get = jest.fn(); | ||
const http = { get } as unknown as HttpSetup; | ||
new DataViewEditorService({ | ||
services: { | ||
http, | ||
dataViews: { | ||
getIdsWithTitle: jest.fn().mockResolvedValue([]), | ||
getRollupsEnabled: jest.fn().mockReturnValue(true), | ||
} as unknown as DataViewsServicePublic, | ||
}, | ||
initialValues: {}, | ||
}); | ||
|
||
expect(get).toHaveBeenCalledTimes(1); | ||
expect(get.mock.calls[0][0]).toEqual('/api/rollup/indices'); | ||
}); | ||
it('should skip check for rollup indices when rollups are disabled', () => { | ||
const http = { get: jest.fn() } as unknown as HttpSetup; | ||
new DataViewEditorService({ | ||
services: { | ||
http, | ||
dataViews: { | ||
getIdsWithTitle: jest.fn().mockResolvedValue([]), | ||
getRollupsEnabled: jest.fn().mockReturnValue(false), | ||
} as unknown as DataViewsServicePublic, | ||
}, | ||
initialValues: {}, | ||
}); | ||
|
||
expect(http.get).toHaveBeenCalledTimes(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters