Skip to content

Commit 740fbd0

Browse files
committed
ENGCOM-3558: MTF test fix.
1 parent 747f33d commit 740fbd0

File tree

4 files changed

+103
-14
lines changed

4 files changed

+103
-14
lines changed

app/code/Magento/Rule/Model/Condition/AbstractCondition.php

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ abstract class AbstractCondition extends \Magento\Framework\DataObject implement
6262
protected $_layout;
6363

6464
/**
65-
* Base name for hidden elements
65+
* Base name for hidden elements.
66+
*
6667
* @var string
6768
*/
6869
protected $elementName = 'rule';
@@ -116,8 +117,9 @@ public function getDefaultOperatorInputByType()
116117
}
117118

118119
/**
119-
* Default operator options getter
120-
* Provides all possible operator options
120+
* Default operator options getter.
121+
*
122+
* Provides all possible operator options.
121123
*
122124
* @return array
123125
*/
@@ -141,6 +143,8 @@ public function getDefaultOperatorOptions()
141143
}
142144

143145
/**
146+
* Get rule form.
147+
*
144148
* @return Form
145149
*/
146150
public function getForm()
@@ -149,6 +153,8 @@ public function getForm()
149153
}
150154

151155
/**
156+
* Get condition as array.
157+
*
152158
* @param array $arrAttributes
153159
* @return array
154160
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
@@ -195,6 +201,8 @@ public function getMappedSqlField()
195201
}
196202

197203
/**
204+
* Get condition as xml.
205+
*
198206
* @return string
199207
*/
200208
public function asXml()
@@ -214,6 +222,8 @@ public function asXml()
214222
}
215223

216224
/**
225+
* Load condition from array.
226+
*
217227
* @param array $arr
218228
* @return $this
219229
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -229,6 +239,8 @@ public function loadArray($arr)
229239
}
230240

231241
/**
242+
* Load condition from xml.
243+
*
232244
* @param string|array $xml
233245
* @return $this
234246
*/
@@ -242,6 +254,8 @@ public function loadXml($xml)
242254
}
243255

244256
/**
257+
* Load attribute options.
258+
*
245259
* @return $this
246260
*/
247261
public function loadAttributeOptions()
@@ -250,6 +264,8 @@ public function loadAttributeOptions()
250264
}
251265

252266
/**
267+
* Get attribute options.
268+
*
253269
* @return array
254270
*/
255271
public function getAttributeOptions()
@@ -258,6 +274,8 @@ public function getAttributeOptions()
258274
}
259275

260276
/**
277+
* Get attribute select options.
278+
*
261279
* @return array
262280
*/
263281
public function getAttributeSelectOptions()
@@ -270,6 +288,8 @@ public function getAttributeSelectOptions()
270288
}
271289

272290
/**
291+
* Get attribute name.
292+
*
273293
* @return string
274294
*/
275295
public function getAttributeName()
@@ -278,6 +298,8 @@ public function getAttributeName()
278298
}
279299

280300
/**
301+
* Load operator options.
302+
*
281303
* @return $this
282304
*/
283305
public function loadOperatorOptions()
@@ -300,6 +322,8 @@ public function getInputType()
300322
}
301323

302324
/**
325+
* Get operator select options.
326+
*
303327
* @return array
304328
*/
305329
public function getOperatorSelectOptions()
@@ -316,6 +340,8 @@ public function getOperatorSelectOptions()
316340
}
317341

318342
/**
343+
* Get operator name.
344+
*
319345
* @return array
320346
*/
321347
public function getOperatorName()
@@ -324,6 +350,8 @@ public function getOperatorName()
324350
}
325351

326352
/**
353+
* Load value options.
354+
*
327355
* @return $this
328356
*/
329357
public function loadValueOptions()
@@ -333,6 +361,8 @@ public function loadValueOptions()
333361
}
334362

335363
/**
364+
* Get value select options.
365+
*
336366
* @return array
337367
*/
338368
public function getValueSelectOptions()
@@ -380,6 +410,8 @@ public function isArrayOperatorType()
380410
}
381411

382412
/**
413+
* Get value.
414+
*
383415
* @return mixed
384416
*/
385417
public function getValue()
@@ -395,6 +427,8 @@ public function getValue()
395427
}
396428

397429
/**
430+
* Get value name.
431+
*
398432
* @return array|string
399433
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
400434
*/
@@ -446,6 +480,8 @@ public function getNewChildSelectOptions()
446480
}
447481

448482
/**
483+
* Get new child name.
484+
*
449485
* @return string
450486
*/
451487
public function getNewChildName()
@@ -454,6 +490,8 @@ public function getNewChildName()
454490
}
455491

456492
/**
493+
* Get this condition as html.
494+
*
457495
* @return string
458496
*/
459497
public function asHtml()
@@ -467,6 +505,8 @@ public function asHtml()
467505
}
468506

469507
/**
508+
* Get this condition with subconditions as html.
509+
*
470510
* @return string
471511
*/
472512
public function asHtmlRecursive()
@@ -475,6 +515,8 @@ public function asHtmlRecursive()
475515
}
476516

477517
/**
518+
* Get type element.
519+
*
478520
* @return AbstractElement
479521
*/
480522
public function getTypeElement()
@@ -493,6 +535,8 @@ public function getTypeElement()
493535
}
494536

495537
/**
538+
* Get type element html.
539+
*
496540
* @return string
497541
*/
498542
public function getTypeElementHtml()
@@ -501,6 +545,8 @@ public function getTypeElementHtml()
501545
}
502546

503547
/**
548+
* Get attribute element.
549+
*
504550
* @return $this
505551
*/
506552
public function getAttributeElement()
@@ -528,6 +574,8 @@ public function getAttributeElement()
528574
}
529575

530576
/**
577+
* Get attribute element html.
578+
*
531579
* @return string
532580
*/
533581
public function getAttributeElementHtml()
@@ -536,8 +584,9 @@ public function getAttributeElementHtml()
536584
}
537585

538586
/**
539-
* Retrieve Condition Operator element Instance
540-
* If the operator value is empty - define first available operator value as default
587+
* Retrieve Condition Operator element Instance.
588+
*
589+
* If the operator value is empty - define first available operator value as default.
541590
*
542591
* @return \Magento\Framework\Data\Form\Element\Select
543592
*/
@@ -568,6 +617,8 @@ public function getOperatorElement()
568617
}
569618

570619
/**
620+
* Get operator element html.
621+
*
571622
* @return string
572623
*/
573624
public function getOperatorElementHtml()
@@ -587,6 +638,8 @@ public function getValueElementType()
587638
}
588639

589640
/**
641+
* Get value element renderer.
642+
*
590643
* @return \Magento\Rule\Block\Editable
591644
*/
592645
public function getValueElementRenderer()
@@ -598,6 +651,8 @@ public function getValueElementRenderer()
598651
}
599652

600653
/**
654+
* Get value element.
655+
*
601656
* @return $this
602657
*/
603658
public function getValueElement()
@@ -629,6 +684,8 @@ public function getValueElement()
629684
}
630685

631686
/**
687+
* Get value element html.
688+
*
632689
* @return string
633690
*/
634691
public function getValueElementHtml()
@@ -637,6 +694,8 @@ public function getValueElementHtml()
637694
}
638695

639696
/**
697+
* Get add link html.
698+
*
640699
* @return string
641700
*/
642701
public function getAddLinkHtml()
@@ -646,6 +705,8 @@ public function getAddLinkHtml()
646705
}
647706

648707
/**
708+
* Get remove link html.
709+
*
649710
* @return string
650711
*/
651712
public function getRemoveLinkHtml()
@@ -658,6 +719,8 @@ public function getRemoveLinkHtml()
658719
}
659720

660721
/**
722+
* Get chooser container html.
723+
*
661724
* @return string
662725
*/
663726
public function getChooserContainerHtml()
@@ -667,6 +730,8 @@ public function getChooserContainerHtml()
667730
}
668731

669732
/**
733+
* Get this condition as string.
734+
*
670735
* @param string $format
671736
* @return string
672737
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
@@ -677,6 +742,8 @@ public function asString($format = '')
677742
}
678743

679744
/**
745+
* Get this condition with subconditions as string.
746+
*
680747
* @param int $level
681748
* @return string
682749
*/
@@ -819,6 +886,8 @@ protected function _compareValues($validatedValue, $value, $strict = true)
819886
}
820887

821888
/**
889+
* Validate model.
890+
*
822891
* @param \Magento\Framework\Model\AbstractModel $model
823892
* @return bool
824893
*/

dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
namespace Magento\Mtf\Client\Element;
88

9-
use Magento\Mtf\ObjectManager;
10-
use Magento\Mtf\Client\Locator;
119
use Magento\Mtf\Client\ElementInterface;
10+
use Magento\Mtf\Client\Locator;
11+
use Magento\Mtf\ObjectManager;
1212

1313
/**
1414
* Typified element class for conditions.
@@ -135,6 +135,13 @@ class ConditionsElement extends SimpleElement
135135
*/
136136
protected $chooserGridLocator = 'div[id*=chooser]';
137137

138+
/**
139+
* Datepicker xpath.
140+
*
141+
* @var string
142+
*/
143+
private $datepicker = './/*[contains(@class,"ui-datepicker-trigger")]';
144+
138145
/**
139146
* Key of last find param.
140147
*
@@ -189,10 +196,7 @@ class ConditionsElement extends SimpleElement
189196
protected $exception;
190197

191198
/**
192-
* Set value to conditions.
193-
*
194-
* @param string $value
195-
* @return void
199+
* @inheritdoc
196200
*/
197201
public function setValue($value)
198202
{
@@ -411,7 +415,16 @@ protected function fillText($rule, ElementInterface $param)
411415
{
412416
$value = $param->find('input', Locator::SELECTOR_TAG_NAME);
413417
if ($value->isVisible()) {
414-
$value->setValue($rule);
418+
if (!$value->getAttribute('readonly')) {
419+
$value->setValue($rule);
420+
} else {
421+
$datepicker = $param->find(
422+
$this->datepicker,
423+
Locator::SELECTOR_XPATH,
424+
DatepickerElement::class
425+
);
426+
$datepicker->setValue($rule);
427+
}
415428

416429
$apply = $param->find('.//*[@class="rule-param-apply"]', Locator::SELECTOR_XPATH);
417430
if ($apply->isVisible()) {

0 commit comments

Comments
 (0)