diff options
Diffstat (limited to 'frontends/php/tests/selenium/testFormItemPreprocessing.php')
-rw-r--r-- | frontends/php/tests/selenium/testFormItemPreprocessing.php | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/frontends/php/tests/selenium/testFormItemPreprocessing.php b/frontends/php/tests/selenium/testFormItemPreprocessing.php index a6a7e328baa..ddd5284ee8b 100644 --- a/frontends/php/tests/selenium/testFormItemPreprocessing.php +++ b/frontends/php/tests/selenium/testFormItemPreprocessing.php @@ -129,10 +129,10 @@ class testFormItemPreprocessing extends CLegacyWebTest { [ [ 'expected' => TEST_BAD, - 'name' => 'Item JSON Path', + 'name' => 'Item JSONPath', 'key' => 'item-empty-jsonpath', 'preprocessing' => [ - ['type' => 'JSON Path', 'parameter_1' => ''], + ['type' => 'JSONPath', 'parameter_1' => ''], ], 'error' => 'Incorrect value for field "params": cannot be empty.' ] @@ -532,7 +532,7 @@ class testFormItemPreprocessing extends CLegacyWebTest { ['type' => 'Left trim', 'parameter_1' => '2b!@#$%^&*()-='], ['type' => 'Trim', 'parameter_1' => '3c!@#$%^&*()-='], ['type' => 'XML XPath', 'parameter_1' => '3c!@#$%^&*()-='], - ['type' => 'JSON Path', 'parameter_1' => '3c!@#$%^&*()-='], + ['type' => 'JSONPath', 'parameter_1' => '3c!@#$%^&*()-='], ['type' => 'Custom multiplier', 'parameter_1' => '4e+10'], ['type' => 'Regular expression', 'parameter_1' => '5d!@#$%^&*()-=', 'parameter_2' => '6e!@#$%^&*()-='], ['type' => 'Matches regular expression', 'parameter_1' => '7f!@#$%^&*()-='], @@ -558,8 +558,8 @@ class testFormItemPreprocessing extends CLegacyWebTest { ['type' => 'Trim', 'parameter_1' => '1a2b3c'], ['type' => 'XML XPath', 'parameter_1' => '1a2b3c'], ['type' => 'XML XPath', 'parameter_1' => '1a2b3c'], - ['type' => 'JSON Path', 'parameter_1' => '1a2b3c'], - ['type' => 'JSON Path', 'parameter_1' => '1a2b3c'], + ['type' => 'JSONPath', 'parameter_1' => '1a2b3c'], + ['type' => 'JSONPath', 'parameter_1' => '1a2b3c'], ['type' => 'Custom multiplier', 'parameter_1' => '123'], ['type' => 'Custom multiplier', 'parameter_1' => '123'], ['type' => 'Regular expression', 'parameter_1' => 'expression', 'parameter_2' => 'test output'], @@ -596,7 +596,7 @@ class testFormItemPreprocessing extends CLegacyWebTest { ['type' => 'Right trim', 'parameter_1' => '{$MACRO}'], ['type' => 'Left trim', 'parameter_1' => '{$USER}'], ['type' => 'XML XPath', 'parameter_1' => 'number(/values/Item/value[../key=\'{$DELIM}\'])'], - ['type' => 'JSON Path', 'parameter_1' => '$.data[\'{$KEY}\']'], + ['type' => 'JSONPath', 'parameter_1' => '$.data[\'{$KEY}\']'], ['type' => 'Custom multiplier', 'parameter_1' => '{$VALUE}'], ['type' => 'In range', 'parameter_1' => '{$FROM}', 'parameter_2' => '{$TO}'], ['type' => 'Matches regular expression', 'parameter_1' => '{$EXPRESSION}(.*)'], @@ -650,7 +650,15 @@ class testFormItemPreprocessing extends CLegacyWebTest { // Check results in DB. foreach ($data['preprocessing'] as $key => $options) { - $db_type = get_preprocessing_types($type[$key]); + // The array of allowed types must be synced with CItem::$supported_preprocessing_types. + $db_type = get_preprocessing_types($type[$key], false, [ZBX_PREPROC_REGSUB, ZBX_PREPROC_TRIM, + ZBX_PREPROC_RTRIM, ZBX_PREPROC_LTRIM, ZBX_PREPROC_XPATH, ZBX_PREPROC_JSONPATH, + ZBX_PREPROC_MULTIPLIER, ZBX_PREPROC_DELTA_VALUE, ZBX_PREPROC_DELTA_SPEED, ZBX_PREPROC_BOOL2DEC, + ZBX_PREPROC_OCT2DEC, ZBX_PREPROC_HEX2DEC, ZBX_PREPROC_VALIDATE_RANGE, + ZBX_PREPROC_VALIDATE_REGEX, ZBX_PREPROC_VALIDATE_NOT_REGEX, ZBX_PREPROC_ERROR_FIELD_JSON, + ZBX_PREPROC_ERROR_FIELD_XML, ZBX_PREPROC_ERROR_FIELD_REGEX, ZBX_PREPROC_THROTTLE_VALUE, + ZBX_PREPROC_THROTTLE_TIMED_VALUE + ]); $this->assertEquals($options['type'], $db_type); switch ($options['type']) { @@ -659,7 +667,7 @@ class testFormItemPreprocessing extends CLegacyWebTest { case 'Left trim': case 'Trim': case 'XML XPath': - case 'JSON Path': + case 'JSONPath': case 'Matches regular expression': case 'Does not match regular expression': case 'Check for error in JSON': @@ -724,7 +732,13 @@ class testFormItemPreprocessing extends CLegacyWebTest { // Check preprocessing parameters for each type in form. $db_items_preproc = CDBHelper::getAll('SELECT * FROM item_preproc WHERE itemid='.$preprocessing_itemid); foreach ($db_items_preproc as $item_preproc) { - $preprocessing_type = get_preprocessing_types($item_preproc['type']); + $preprocessing_type = get_preprocessing_types($item_preproc['type'], false, [ZBX_PREPROC_REGSUB, + ZBX_PREPROC_TRIM, ZBX_PREPROC_RTRIM, ZBX_PREPROC_LTRIM, ZBX_PREPROC_XPATH, ZBX_PREPROC_JSONPATH, + ZBX_PREPROC_MULTIPLIER, ZBX_PREPROC_DELTA_VALUE, ZBX_PREPROC_DELTA_SPEED, ZBX_PREPROC_BOOL2DEC, + ZBX_PREPROC_OCT2DEC, ZBX_PREPROC_HEX2DEC, ZBX_PREPROC_VALIDATE_RANGE, ZBX_PREPROC_VALIDATE_REGEX, + ZBX_PREPROC_VALIDATE_NOT_REGEX, ZBX_PREPROC_ERROR_FIELD_JSON, ZBX_PREPROC_ERROR_FIELD_XML, + ZBX_PREPROC_ERROR_FIELD_REGEX, ZBX_PREPROC_THROTTLE_VALUE, ZBX_PREPROC_THROTTLE_TIMED_VALUE + ]); $this->zbxTestAssertElementNotPresentXpath('//input[@id="preprocessing_'.($item_preproc['step'] - 1).'_type"][@readonly]'); $this->zbxTestDropdownAssertSelected('preprocessing['.($item_preproc['step'] - 1).'][type]', $preprocessing_type); switch ($item_preproc['type']) { @@ -767,7 +781,7 @@ class testFormItemPreprocessing extends CLegacyWebTest { ['type' => 'Right trim', 'parameter_1' => 'right_trim'], ['type' => 'Left trim', 'parameter_1' => 'left_trim'], ['type' => 'XML XPath', 'parameter_1' => '/xml/path'], - ['type' => 'JSON Path', 'parameter_1' => '/json/path'], + ['type' => 'JSONPath', 'parameter_1' => '/json/path'], ['type' => 'Custom multiplier', 'parameter_1' => '5'], ['type' => 'Simple change'], ['type' => 'Boolean to decimal'], @@ -845,7 +859,7 @@ class testFormItemPreprocessing extends CLegacyWebTest { switch ($options['type']) { case 'Regular expression': case 'XML XPath': - case 'JSON Path': + case 'JSONPath': case 'Custom multiplier': case 'Simple change': case 'Change per second': @@ -902,7 +916,7 @@ class testFormItemPreprocessing extends CLegacyWebTest { switch ($options['type']) { case 'Regular expression': case 'XML XPath': - case 'JSON Path': + case 'JSONPath': case 'Custom multiplier': case 'Simple change': case 'Change per second': @@ -1045,7 +1059,7 @@ class testFormItemPreprocessing extends CLegacyWebTest { $preprocessing = [ ['type' => 'Regular expression', 'parameter_1' => 'expression', 'parameter_2' => 'test output'], ['type' => 'XML XPath', 'parameter_1' => '/xml/path'], - ['type' => 'JSON Path', 'parameter_1' => '/json/path'], + ['type' => 'JSONPath', 'parameter_1' => '/json/path'], ['type' => 'Custom multiplier', 'parameter_1' => '5'], ['type' => 'Simple change'], ['type' => 'Boolean to decimal'], |