Skip to content

Commit 54d4c53

Browse files
authored
Change painless scripted field (#21026) (#21046)
* Change painless scripted field * Remove wrong char * Remove invalid escape chars
1 parent 1267432 commit 54d4c53

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
@@ -149,7 +149,11 @@ export default function ({ getService, getPageObjects }) {
149149
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount());
150150
await PageObjects.settings.clickScriptedFieldsTab();
151151
await log.debug('add scripted field');
152-
const script = 'doc[\'machine.ram\'].value / (1024 * 1024 * 1024)';
152+
const script = `if (doc['machine.ram'].size() == 0) {
153+
return -1;
154+
} else {
155+
return doc['machine.ram'].value / (1024 * 1024 * 1024);
156+
}`;
153157
await PageObjects.settings.addScriptedField(scriptedPainlessFieldName, 'painless', 'number', null, '1', script);
154158
await retry.try(async function () {
155159
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount())).to.be(startingCount + 1);

0 commit comments

Comments
 (0)