Skip to content

Commit

Permalink
Editing a scripted field causes errors elastic#33251 (elastic#34679) (e…
Browse files Browse the repository at this point in the history
…lastic#34912)

* Changed the default fieldFormatMap to undefined - bugfix

* Test for bug elastic#33251

* Remove only
  • Loading branch information
lizozom authored Apr 11, 2019
1 parent 679fa71 commit 7836db5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/legacy/ui/public/field_editor/field_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
27 changes: 27 additions & 0 deletions test/functional/apps/management/_scripted_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
5 changes: 5 additions & 0 deletions test/functional/page_objects/settings_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7836db5

Please sign in to comment.