diff --git a/src/legacy/ui/public/field_editor/field_editor.js b/src/legacy/ui/public/field_editor/field_editor.js index aa9b0d61dba83..ab4f9e85d339c 100644 --- a/src/legacy/ui/public/field_editor/field_editor.js +++ b/src/legacy/ui/public/field_editor/field_editor.js @@ -662,7 +662,7 @@ export class FieldEditorComponent extends PureComponent { } if (!fieldFormatId) { - indexPattern.fieldFormatMap[field.name] = {}; + indexPattern.fieldFormatMap[field.name] = undefined; } else { indexPattern.fieldFormatMap[field.name] = field.format; } diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index a3077e965dd4c..3e901388ed383 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -73,6 +73,33 @@ export default function ({ getService, getPageObjects }) { }); }); + + describe('testing regression for issue #33251', function describeIndexTests() { + const scriptedPainlessFieldName = 'ram_Pain_reg'; + + it('should create and edit scripted field', async function () { + await PageObjects.settings.navigateTo(); + await PageObjects.settings.clickKibanaIndexPatterns(); + await PageObjects.settings.clickIndexPatternLogstash(); + const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount()); + await PageObjects.settings.clickScriptedFieldsTab(); + await log.debug('add scripted field'); + const script = `1`; + await PageObjects.settings.addScriptedField(scriptedPainlessFieldName, 'painless', 'number', null, '1', script); + await retry.try(async function () { + expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount())).to.be(startingCount + 1); + }); + + for (let i = 0; i < 3; i++) { + await PageObjects.settings.editScriptedField(scriptedPainlessFieldName); + const fieldSaveButton = await testSubjects.exists('fieldSaveButton'); + expect(fieldSaveButton).to.be(true); + await PageObjects.settings.clickSaveScriptedField(); + } + }); + }); + + describe('creating and using Painless numeric scripted fields', function describeIndexTests() { const scriptedPainlessFieldName = 'ram_Pain1'; diff --git a/test/functional/page_objects/settings_page.js b/test/functional/page_objects/settings_page.js index 2e728db3b388d..2b42906717f36 100644 --- a/test/functional/page_objects/settings_page.js +++ b/test/functional/page_objects/settings_page.js @@ -380,6 +380,11 @@ export function SettingsPageProvider({ getService, getPageObjects }) { await testSubjects.click('tab-sourceFilters'); } + async editScriptedField(name) { + await this.filterField(name); + await find.clickByCssSelector('.euiTableRowCell--hasActions button:first-child'); + } + async addScriptedField(name, language, type, format, popularity, script) { await this.clickAddScriptedField(); await this.setScriptedFieldName(name);