Skip to content

Commit 826ff96

Browse files
committed
MQE-1157: Add readiness bypass to test actions
- Removed print statements, created action steps instead
1 parent ce6543d commit 826ff96

File tree

2 files changed

+42
-16
lines changed

2 files changed

+42
-16
lines changed

src/Magento/FunctionalTestingFramework/Test/Util/ActionMergeUtil.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class ActionMergeUtil
2323
const WAIT_ATTR = 'timeout';
2424
const WAIT_ACTION_NAME = 'waitForPageLoad';
2525
const WAIT_ACTION_SUFFIX = 'WaitForPageLoad';
26+
const SKIP_READINESS_ACTION_NAME = 'skipReadinessCheck';
27+
const SKIP_READINESS_OFF_SUFFIX = 'SkipReadinessOff';
28+
const SKIP_READINESS_ON_SUFFIX = 'SkipReadinessOn';
29+
const DEFAULT_SKIP_ON_ORDER = 'before';
30+
const DEFAULT_SKIP_OFF_ORDER = 'after';
2631
const DEFAULT_WAIT_ORDER = 'after';
2732

2833
/**
@@ -78,6 +83,7 @@ public function resolveActionSteps($parsedSteps, $skipActionGroupResolution = fa
7883
{
7984
$this->mergeActions($parsedSteps);
8085
$this->insertWaits();
86+
$this->insertReadinessSkips();
8187

8288
if ($skipActionGroupResolution) {
8389
return $this->orderedSteps;
@@ -217,6 +223,39 @@ private function insertWaits()
217223
}
218224
}
219225

226+
/**
227+
* Runs through the prepared orderedSteps and calls insertWait if a step requires a wait after it.
228+
*
229+
* @return void
230+
*/
231+
private function insertReadinessSkips()
232+
{
233+
foreach ($this->orderedSteps as $step) {
234+
if (array_key_exists("skipReadiness", $step->getCustomActionAttributes())) {
235+
if ($step->getCustomActionAttributes()['skipReadiness']) {
236+
$skipReadinessOn = new ActionObject(
237+
$step->getStepKey() . self::SKIP_READINESS_ON_SUFFIX,
238+
self::SKIP_READINESS_ACTION_NAME,
239+
['state' => "true"],
240+
$step->getStepKey(),
241+
self::DEFAULT_SKIP_ON_ORDER
242+
);
243+
244+
$skipReadinessOff = new ActionObject(
245+
$step->getStepKey() . self::SKIP_READINESS_OFF_SUFFIX,
246+
self::SKIP_READINESS_ACTION_NAME,
247+
['state' => "false"],
248+
$step->getStepKey(),
249+
self::DEFAULT_SKIP_OFF_ORDER
250+
);
251+
252+
$this->insertStep($skipReadinessOn);
253+
$this->insertStep($skipReadinessOff);
254+
}
255+
}
256+
}
257+
}
258+
220259
/**
221260
* This method takes the steps from the parser and splits steps which need merge from steps that are ordered.
222261
*

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -513,14 +513,6 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = "
513513
if (isset($customActionAttributes['arguments'])) {
514514
$arguments = $this->addUniquenessFunctionCall($customActionAttributes['arguments']);
515515
}
516-
if (isset($customActionAttributes['skipReadiness'])) {
517-
if ($customActionAttributes['skipReadiness'] == "true") {
518-
$testSteps .= sprintf(
519-
"\t\t$%s->skipReadinessCheck(true);\n",
520-
$actor
521-
);
522-
}
523-
}
524516

525517
if (isset($customActionAttributes['attribute'])) {
526518
$attribute = $customActionAttributes['attribute'];
@@ -1280,17 +1272,12 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = "
12801272

12811273
$testSteps .= $dateGenerateCode;
12821274
break;
1275+
case "skipReadinessCheck":
1276+
$testSteps .= $this->wrapFunctionCall($actor, $actionObject, $customActionAttributes['state']);
1277+
break;
12831278
default:
12841279
$testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $input, $parameter);
12851280
}
1286-
if (isset($customActionAttributes['skipReadiness'])) {
1287-
if ($customActionAttributes['skipReadiness'] == "true") {
1288-
$testSteps .= sprintf(
1289-
"\t\t$%s->skipReadinessCheck(false);\n",
1290-
$actor
1291-
);
1292-
}
1293-
}
12941281
}
12951282

12961283
return $testSteps;

0 commit comments

Comments
 (0)