Skip to content

Commit 0dbaf65

Browse files
timroesnreese
authored andcommitted
Change painless scripted field (#21026)
* Change painless scripted field * Remove wrong char * Remove invalid escape chars
1 parent 97593b4 commit 0dbaf65

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/functional/apps/management/_scripted_fields.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ export default function ({ getService, getPageObjects }) {
8080
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount());
8181
await PageObjects.settings.clickScriptedFieldsTab();
8282
await log.debug('add scripted field');
83-
const script = 'doc[\'machine.ram\'].value / (1024 * 1024 * 1024)';
83+
const script = `if (doc['machine.ram'].size() == 0) {
84+
return -1;
85+
} else {
86+
return doc['machine.ram'].value / (1024 * 1024 * 1024);
87+
}`;
8488
await PageObjects.settings.addScriptedField(scriptedPainlessFieldName, 'painless', 'number', null, '1', script);
8589
await retry.try(async function () {
8690
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount())).to.be(startingCount + 1);

0 commit comments

Comments
 (0)