From 54d4c5332c9954e5e44a0949b4613d941247403c Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Fri, 20 Jul 2018 14:41:52 -0600 Subject: [PATCH] Change painless scripted field (#21026) (#21046) * Change painless scripted field * Remove wrong char * Remove invalid escape chars --- test/functional/apps/management/_scripted_fields.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index 746ea4cfc4029..386a33c6eaf1b 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -149,7 +149,11 @@ export default function ({ getService, getPageObjects }) { const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount()); await PageObjects.settings.clickScriptedFieldsTab(); await log.debug('add scripted field'); - const script = 'doc[\'machine.ram\'].value / (1024 * 1024 * 1024)'; + const script = `if (doc['machine.ram'].size() == 0) { + return -1; + } else { + return doc['machine.ram'].value / (1024 * 1024 * 1024); + }`; 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);