Skip to content

Commit 19effcc

Browse files
ClendeninKevinBKozan
authored andcommitted
MQE-1088: If stepKey is in a selector, incorrect generation occurs
- Added list of actions that return data, actionGroupObject now only returns stepKeys if the actions are of the right list.
1 parent 7610008 commit 19effcc

File tree

4 files changed

+125
-1
lines changed

4 files changed

+125
-1
lines changed

dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php

+56
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,62 @@ public function testExceptionOnMissingArguments()
261261
$actionGroupUnderTest->getSteps(null, self::ACTION_GROUP_MERGE_KEY);
262262
}
263263

264+
/**
265+
* Tests the stepKey replacement with "stepKey + invocationKey" process filter
266+
* Specific to actions that make it past a "require stepKey replacement" filter
267+
*/
268+
public function testStepKeyReplacementFilteredIn()
269+
{
270+
$createStepKey = "createDataStepKey";
271+
$updateStepKey = "updateDataStepKey";
272+
273+
$actionGroupUnderTest = (new ActionGroupObjectBuilder())
274+
->withActionObjects([
275+
new ActionObject(
276+
$updateStepKey,
277+
ActionGroupObject::STEPKEY_REPLACEMENT_ENABLED_TYPES[6],
278+
['selector' => 'value']
279+
),
280+
new ActionObject(
281+
$createStepKey,
282+
ActionGroupObject::STEPKEY_REPLACEMENT_ENABLED_TYPES[7],
283+
['selector' => 'value']
284+
)
285+
])
286+
->build();
287+
288+
$result = $actionGroupUnderTest->extractStepKeys();
289+
290+
$this->assertContains($updateStepKey, $result);
291+
$this->assertContains($createStepKey, $result);
292+
$this->assertCount(2, $result);
293+
}
294+
295+
/**
296+
* Tests the stepKey replacement with "stepKey + invocationKey" process filter
297+
* Specific to actions that make are removed by a "require stepKey replacement" filter
298+
*/
299+
public function testStepKeyReplacementFilteredOut()
300+
{
301+
$clickStepKey = "clickStepKey";
302+
$fillFieldStepKey = "fillFieldStepKey";
303+
$clickAction = "click";
304+
$fillFieldAction ="fillField";
305+
306+
$actionGroupUnderTest = (new ActionGroupObjectBuilder())
307+
->withActionObjects([
308+
new ActionObject($clickStepKey, $clickAction, ['selector' => 'value']),
309+
new ActionObject($fillFieldStepKey, $fillFieldAction, ['selector' => 'value'])
310+
])
311+
->build();
312+
313+
$result = $actionGroupUnderTest->extractStepKeys();
314+
315+
$this->assertNotContains($clickStepKey, $result);
316+
$this->assertNotContains($fillFieldStepKey, $result);
317+
$this->assertCount(0, $result);
318+
}
319+
264320
/**
265321
* This function takes a desired return for the EntityObjectHandler mock and performs set up of the mock for the
266322
* duration of a single test case.

dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt

+28
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,33 @@ class ActionGroupWithStepKeyReferencesCest
3535
$createSimpleDataActionGroup->createEntity();
3636
$grabTextDataActionGroup = $I->grabTextFrom(".class");
3737
$I->fillField(".{$grabTextDataActionGroup}", $createSimpleDataActionGroup->getCreatedDataByName('field'));
38+
$I->click($action0);
39+
$I->fillField($action1);
40+
$action3ActionGroup = $I->executeJS($action3ActionGroup);
41+
$action4ActionGroup = $I->magentoCLI($action4ActionGroup, "\"stuffHere\"");
42+
$I->comment($action4ActionGroup);
43+
$date = new \DateTime();
44+
$date->setTimestamp(strtotime("{$action5}"));
45+
$date->setTimezone(new \DateTimeZone("America/Los_Angeles"));
46+
$action5ActionGroup = $date->format("H:i:s");
47+
$action6ActionGroup = $I->formatMoney($action6ActionGroup);
48+
$I->amGoingTo("delete entity that has the createDataKey: {$action7}");
49+
${$action7}->deleteEntity();
50+
$I->amGoingTo("get entity that has the stepKey: action8ActionGroup");
51+
${$action8} = DataObjectHandler::getInstance()->getObject("{$action8}");
52+
$action8ActionGroup = new DataPersistenceHandler(${$action8});
53+
$action8ActionGroup->getEntity(null);
54+
$I->amGoingTo("update entity that has the createdDataKey: 1");
55+
$1->updateEntity("{$action9}");
56+
$I->amGoingTo("create entity that has the stepKey: action10ActionGroup");
57+
${$action10} = DataObjectHandler::getInstance()->getObject("{$action10}");
58+
$action10ActionGroup = new DataPersistenceHandler(${$action10}, []);
59+
$action10ActionGroup->createEntity();
60+
$action11ActionGroup = $I->grabAttributeFrom($action11ActionGroup, "someInput");
61+
$action12ActionGroup = $I->grabCookie($action12ActionGroup, ['domain' => 'www.google.com']);
62+
$action13ActionGroup = $I->grabFromCurrentUrl($action13ActionGroup);
63+
$action14ActionGroup = $I->grabMultiple($action14ActionGroup);
64+
$action15ActionGroup = $I->grabTextFrom($action15ActionGroup);
65+
$action16ActionGroup = $I->grabValueFrom($action16ActionGroup);
3866
}
3967
}

dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml

+18
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,24 @@
4949
<createData entity="simpleData" stepKey="createSimpleData"/>
5050
<grabTextFrom selector=".class" stepKey="grabTextData"/>
5151
<fillField stepKey="fill1" selector=".{$grabTextData}" userInput="$createSimpleData.field$"/>
52+
<!--Invocation stepKey will not be appended in non stepKey instances-->
53+
<click selector="{$action0}" stepKey="action0"/>
54+
<fillField selector="{$action1}" stepKey="action1"/>
55+
<!--Invocation stepKey will be appended to every instance of $stepKey in action-->
56+
<executeJS function="{$action3}" stepKey="action3"/>
57+
<magentoCLI command="{$action4}" arguments="&quot;stuffHere&quot;" stepKey="action4"/>
58+
<generateDate date="{$action5}" format="H:i:s" stepKey="action5"/>
59+
<formatMoney userInput="{$action6}" stepKey="action6"/>
60+
<deleteData createDataKey="{$action7}" stepKey="action7"/>
61+
<getData entity="{$action8}" stepKey="action8"/>
62+
<updateData entity="{$action9}" stepKey="action9" createDataKey="1"/>
63+
<createData entity="{$action10}" stepKey="action10"/>
64+
<grabAttributeFrom selector="{$action11}" userInput="someInput" stepKey="action11"/>
65+
<grabCookie userInput="{$action12}" parameterArray="['domain' => 'www.google.com']" stepKey="action12"/>
66+
<grabFromCurrentUrl regex="{$action13}" stepKey="action13"/>
67+
<grabMultiple selector="{$action14}" stepKey="action14"/>
68+
<grabTextFrom selector="{$action15}" stepKey="action15"/>
69+
<grabValueFrom selector="{$action16}" stepKey="action16"/>
5270
</actionGroup>
5371
<actionGroup name="FunctionalActionGroupForMassMergeBefore">
5472
<fillField selector="#foo" userInput="foo" stepKey="fillField1"/>

src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php

+23-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ class ActionGroupObject
1919
{
2020
const ACTION_GROUP_ORIGIN_NAME = "actionGroupName";
2121
const ACTION_GROUP_ORIGIN_TEST_REF = "testInvocationRef";
22+
const STEPKEY_REPLACEMENT_ENABLED_TYPES = [
23+
"executeJS",
24+
"magentoCLI",
25+
"generateDate",
26+
"formatMoney",
27+
"deleteData",
28+
"getData",
29+
"updateData",
30+
"createData",
31+
"grabAttributeFrom",
32+
"grabCookie",
33+
"grabFromCurrentUrl",
34+
"grabMultiple",
35+
"grabPageSource",
36+
"grabTextFrom",
37+
"grabValueFrom"
38+
];
2239

2340
/**
2441
* Array of variable-enabled attributes.
@@ -372,7 +389,12 @@ public function extractStepKeys()
372389
{
373390
$originalKeys = [];
374391
foreach ($this->parsedActions as $action) {
375-
$originalKeys[] = $action->getStepKey();
392+
//limit actions returned to list that are relevant
393+
foreach (self::STEPKEY_REPLACEMENT_ENABLED_TYPES as $actionValue) {
394+
if ($actionValue === $action->getType()) {
395+
$originalKeys[] = $action->getStepKey();
396+
}
397+
}
376398
}
377399
return $originalKeys;
378400
}

0 commit comments

Comments
 (0)