mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[data view] Data view management - persist count / popularity number (#188285)
## Summary Fixes updating of data view field popularity value. Previously, the data view field would be changed but it wouldn't save. Closes https://github.com/elastic/kibana/issues/188202
This commit is contained in:
parent
1cae23769a
commit
39017342ed
7 changed files with 38 additions and 3 deletions
|
@ -126,6 +126,7 @@ export const buildDataViewMock = ({
|
|||
return dataViewFields.find((field) => field.name === timeFieldName);
|
||||
},
|
||||
getRuntimeField: () => null,
|
||||
setFieldCount: jest.fn(),
|
||||
} as unknown as DataView;
|
||||
|
||||
dataView.isTimeBased = () => !!timeFieldName;
|
||||
|
|
|
@ -320,6 +320,7 @@ Array [
|
|||
"_score",
|
||||
],
|
||||
"name": "index-pattern-with-timefield",
|
||||
"setFieldCount": [MockFunction],
|
||||
"timeFieldName": "timestamp",
|
||||
"title": "index-pattern-with-timefield-title",
|
||||
"toMinimalSpec": [Function],
|
||||
|
@ -564,6 +565,7 @@ Array [
|
|||
"_score",
|
||||
],
|
||||
"name": "index-pattern-with-timefield",
|
||||
"setFieldCount": [MockFunction],
|
||||
"timeFieldName": "timestamp",
|
||||
"title": "index-pattern-with-timefield-title",
|
||||
"toMinimalSpec": [Function],
|
||||
|
@ -820,6 +822,7 @@ Array [
|
|||
"_score",
|
||||
],
|
||||
"name": "index-pattern-with-timefield",
|
||||
"setFieldCount": [MockFunction],
|
||||
"timeFieldName": "timestamp",
|
||||
"title": "index-pattern-with-timefield-title",
|
||||
"toMinimalSpec": [Function],
|
||||
|
@ -1063,6 +1066,7 @@ Array [
|
|||
"_score",
|
||||
],
|
||||
"name": "index-pattern-with-timefield",
|
||||
"setFieldCount": [MockFunction],
|
||||
"timeFieldName": "timestamp",
|
||||
"title": "index-pattern-with-timefield-title",
|
||||
"toMinimalSpec": [Function],
|
||||
|
@ -1351,6 +1355,7 @@ Array [
|
|||
"_score",
|
||||
],
|
||||
"name": "index-pattern-with-timefield",
|
||||
"setFieldCount": [MockFunction],
|
||||
"timeFieldName": "timestamp",
|
||||
"title": "index-pattern-with-timefield-title",
|
||||
"toMinimalSpec": [Function],
|
||||
|
@ -1632,6 +1637,7 @@ Array [
|
|||
"_score",
|
||||
],
|
||||
"name": "index-pattern-with-timefield",
|
||||
"setFieldCount": [MockFunction],
|
||||
"timeFieldName": "timestamp",
|
||||
"title": "index-pattern-with-timefield-title",
|
||||
"toMinimalSpec": [Function],
|
||||
|
@ -1795,6 +1801,7 @@ Array [
|
|||
"_score",
|
||||
],
|
||||
"name": "index-pattern-with-timefield",
|
||||
"setFieldCount": [MockFunction],
|
||||
"timeFieldName": "timestamp",
|
||||
"title": "index-pattern-with-timefield-title",
|
||||
"toMinimalSpec": [Function],
|
||||
|
@ -1950,6 +1957,7 @@ Array [
|
|||
"_score",
|
||||
],
|
||||
"name": "index-pattern-with-timefield",
|
||||
"setFieldCount": [MockFunction],
|
||||
"timeFieldName": "timestamp",
|
||||
"title": "index-pattern-with-timefield-title",
|
||||
"toMinimalSpec": [Function],
|
||||
|
@ -2152,6 +2160,7 @@ Array [
|
|||
"_score",
|
||||
],
|
||||
"name": "index-pattern-with-timefield",
|
||||
"setFieldCount": [MockFunction],
|
||||
"timeFieldName": "timestamp",
|
||||
"title": "index-pattern-with-timefield-title",
|
||||
"toMinimalSpec": [Function],
|
||||
|
@ -2366,6 +2375,7 @@ Array [
|
|||
"_score",
|
||||
],
|
||||
"name": "index-pattern-with-timefield",
|
||||
"setFieldCount": [MockFunction],
|
||||
"timeFieldName": "timestamp",
|
||||
"title": "index-pattern-with-timefield-title",
|
||||
"toMinimalSpec": [Function],
|
||||
|
@ -2566,6 +2576,7 @@ Array [
|
|||
"_score",
|
||||
],
|
||||
"name": "index-pattern-with-timefield",
|
||||
"setFieldCount": [MockFunction],
|
||||
"timeFieldName": "timestamp",
|
||||
"title": "index-pattern-with-timefield-title",
|
||||
"toMinimalSpec": [Function],
|
||||
|
@ -2768,6 +2779,7 @@ Array [
|
|||
"_score",
|
||||
],
|
||||
"name": "index-pattern-with-timefield",
|
||||
"setFieldCount": [MockFunction],
|
||||
"timeFieldName": "timestamp",
|
||||
"title": "index-pattern-with-timefield-title",
|
||||
"toMinimalSpec": [Function],
|
||||
|
@ -3007,6 +3019,7 @@ Array [
|
|||
"_score",
|
||||
],
|
||||
"name": "index-pattern-with-timefield",
|
||||
"setFieldCount": [MockFunction],
|
||||
"timeFieldName": "timestamp",
|
||||
"title": "index-pattern-with-timefield-title",
|
||||
"toMinimalSpec": [Function],
|
||||
|
@ -3224,6 +3237,7 @@ Array [
|
|||
"_score",
|
||||
],
|
||||
"name": "index-pattern-with-timefield",
|
||||
"setFieldCount": [MockFunction],
|
||||
"timeFieldName": "timestamp",
|
||||
"title": "index-pattern-with-timefield-title",
|
||||
"toMinimalSpec": [Function],
|
||||
|
|
|
@ -38,11 +38,13 @@ describe('Popularize field', () => {
|
|||
});
|
||||
|
||||
test('do not updates saved object if data view is not persisted', async () => {
|
||||
const field = { count: 0 };
|
||||
const dataView = {
|
||||
id: 'id',
|
||||
fields: {
|
||||
getByName: () => ({ count: 0 }),
|
||||
getByName: () => field,
|
||||
},
|
||||
setFieldCount: jest.fn(),
|
||||
isPersisted: () => false,
|
||||
} as unknown as DataView;
|
||||
const updateSavedObjectMock = jest.fn();
|
||||
|
@ -62,6 +64,9 @@ describe('Popularize field', () => {
|
|||
fields: {
|
||||
getByName: () => field,
|
||||
},
|
||||
setFieldCount: jest.fn().mockImplementation((fieldName, count) => {
|
||||
field.count = count;
|
||||
}),
|
||||
isPersisted: () => true,
|
||||
} as unknown as DataView;
|
||||
const fieldName = '@timestamp';
|
||||
|
@ -84,6 +89,9 @@ describe('Popularize field', () => {
|
|||
fields: {
|
||||
getByName: () => field,
|
||||
},
|
||||
setFieldCount: jest.fn().mockImplementation((fieldName, count) => {
|
||||
field.count = count;
|
||||
}),
|
||||
isPersisted: () => true,
|
||||
} as unknown as DataView;
|
||||
const fieldName = '@timestamp';
|
||||
|
|
|
@ -22,7 +22,7 @@ async function popularizeField(
|
|||
return;
|
||||
}
|
||||
|
||||
field.count++;
|
||||
dataView.setFieldCount(fieldName, field.count + 1);
|
||||
|
||||
if (!dataView.isPersisted()) {
|
||||
return;
|
||||
|
|
|
@ -187,7 +187,10 @@ export class PreviewController {
|
|||
this.dataView.setFieldCustomLabel(updatedField.name, updatedField.customLabel);
|
||||
this.dataView.setFieldCustomDescription(updatedField.name, updatedField.customDescription);
|
||||
|
||||
editedField.count = updatedField.popularity || 0;
|
||||
if (updatedField.popularity !== undefined) {
|
||||
this.dataView.setFieldCount(updatedField.name, updatedField.popularity || 0);
|
||||
}
|
||||
|
||||
if (updatedField.format) {
|
||||
this.dataView.setFieldFormat(updatedField.name, updatedField.format!);
|
||||
} else {
|
||||
|
|
|
@ -442,6 +442,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be(
|
||||
'3 selected fields. 3 popular fields. 48 available fields. 5 empty fields. 4 meta fields.'
|
||||
);
|
||||
|
||||
// verify popular fields were persisted
|
||||
await browser.refresh();
|
||||
await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded();
|
||||
expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be(
|
||||
'3 selected fields. 3 popular fields. 48 available fields. 5 empty fields. 4 meta fields.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should show selected and available fields in ES|QL mode', async function () {
|
||||
|
|
|
@ -12,6 +12,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
|
|||
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const testSubjects = getService('testSubjects');
|
||||
const browser = getService('browser');
|
||||
const log = getService('log');
|
||||
const PageObjects = getPageObjects(['settings', 'common']);
|
||||
|
||||
|
@ -58,6 +59,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
it('can be saved', async function () {
|
||||
// Saving the popularity change
|
||||
await PageObjects.settings.controlChangeSave();
|
||||
await browser.refresh();
|
||||
await PageObjects.settings.openControlsByName(fieldName);
|
||||
const popularity = await PageObjects.settings.getPopularity();
|
||||
log.debug('popularity = ' + popularity);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue