-
Notifications
You must be signed in to change notification settings - Fork 132
MQE-2242: Add static check to flag use of <pause> #783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace tests\util; | ||
|
||
use Magento\FunctionalTestingFramework\Util\Filesystem\DirSetupUtil; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
|
||
class MftfStaticTestCase extends TestCase | ||
{ | ||
const STATIC_RESULTS_DIR = TESTS_MODULE_PATH . | ||
DIRECTORY_SEPARATOR . | ||
'_output' . | ||
DIRECTORY_SEPARATOR . | ||
'static-results'; | ||
|
||
const RESOURCES_PATH = TESTS_MODULE_PATH . | ||
DIRECTORY_SEPARATOR . | ||
"Resources" . | ||
DIRECTORY_SEPARATOR . | ||
'StaticChecks'; | ||
|
||
/** | ||
* Sets input interface | ||
* @param $path | ||
* @return \PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
public function mockInputInterface($path = null) | ||
{ | ||
$input = $this->getMockBuilder(InputInterface::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
if ($path) { | ||
$input->method('getOption') | ||
->with('path') | ||
->willReturn($path); | ||
} | ||
return $input; | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
DirSetupUtil::rmdirRecursive(self::STATIC_RESULTS_DIR); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ts/verification/PauseCheckModule/ActionGroup/ActionGroupWithMultiplePausesActionGroup.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> | ||
<actionGroup name="ActionGroupWithMultiplePausesActionGroup"> | ||
<fillField selector="#foo" userInput="foo" stepKey="fillField1"/> | ||
<pause stepKey="pauseAfterFillField1"/> | ||
<fillField selector="#bar" userInput="bar" stepKey="fillField2"/> | ||
<pause stepKey="pauseAfterFillField2"/> | ||
<fillField selector="#baz" userInput="baz" stepKey="fillField3"/> | ||
<pause stepKey="pauseAfterFillField3"/> | ||
</actionGroup> | ||
</actionGroups> |
15 changes: 15 additions & 0 deletions
15
dev/tests/verification/PauseCheckModule/ActionGroup/ActionGroupWithNoPauseActionGroup.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> | ||
<actionGroup name="ActionGroupWithNoPauseActionGroup"> | ||
<fillField selector="#foo" userInput="foo" stepKey="fillField1"/> | ||
<fillField selector="#bar" userInput="bar" stepKey="fillField2"/> | ||
<fillField selector="#baz" userInput="baz" stepKey="fillField3"/> | ||
</actionGroup> | ||
</actionGroups> |
15 changes: 15 additions & 0 deletions
15
dev/tests/verification/PauseCheckModule/ActionGroup/ActionGroupWithPauseActionGroup.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> | ||
<actionGroup name="ActionGroupWithPauseActionGroup"> | ||
<fillField selector="#foo" userInput="myData1" stepKey="fillField1"/> | ||
<fillField selector="#bar" userInput="myData2" stepKey="fillField2"/> | ||
<pause stepKey="pauseAfterFillField2"/> | ||
</actionGroup> | ||
</actionGroups> |
28 changes: 28 additions & 0 deletions
28
dev/tests/verification/PauseCheckModule/Suite/suiteWithMultiplePauseActionsSuite.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
|
||
<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Suite/etc/suiteSchema.xsd"> | ||
<suite name="suiteWithMultiplePauseActionsSuite"> | ||
<include> | ||
<group name="include" /> | ||
</include> | ||
<before> | ||
<amOnPage url="some.url" stepKey="before"/> | ||
<createData entity="SecretData" stepKey="create1"> | ||
<field key="someKey">dataHere</field> | ||
</createData> | ||
<pause stepKey="pauseCreate1"/> | ||
</before> | ||
<after> | ||
<deleteData createDataKey="create1" stepKey="delete1"/> | ||
<deleteData url="deleteThis" stepKey="deleteThis"/> | ||
<fillField selector="#fill" userInput="{{SecretData.key2}}" stepKey="fillAfter"/> | ||
<pause stepKey="pauseFillAfter"/> | ||
</after> | ||
</suite> | ||
</suites> |
27 changes: 27 additions & 0 deletions
27
dev/tests/verification/PauseCheckModule/Suite/suiteWithPauseActionSuite.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
|
||
<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Suite/etc/suiteSchema.xsd"> | ||
<suite name="suiteWithPauseActionSuite"> | ||
<include> | ||
<group name="include" /> | ||
</include> | ||
<before> | ||
<amOnPage url="some.url" stepKey="before"/> | ||
<createData entity="createThis" stepKey="create"> | ||
<field key="someKey">dataHere</field> | ||
</createData> | ||
<pause stepKey="pauseSuite"/> | ||
<click stepKey="clickWithData" userInput="$create.data$"/> | ||
<fillField selector="#foo" userInput="myData1" stepKey="fillField1"/> | ||
</before> | ||
<after> | ||
<comment userInput="afterBlock" stepKey="afterBlock"/> | ||
</after> | ||
</suite> | ||
</suites> |
30 changes: 30 additions & 0 deletions
30
dev/tests/verification/PauseCheckModule/Test/TestWithMultiplePauseActionsTest.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
|
||
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> | ||
<test name="TestWithMultiplePauseActionsTest"> | ||
<annotations> | ||
<severity value="CRITICAL"/> | ||
<group value="functional"/> | ||
<features value="Pause check"/> | ||
<stories value="MQE-433"/> | ||
</annotations> | ||
<before> | ||
<amOnPage url="/beforeUrl" stepKey="beforeAmOnPageKey"/> | ||
<pause stepKey="pauseBeforeAmOnPageKey"/> | ||
</before> | ||
<fillField stepKey="step1" selector="#username" userInput="step1"/> | ||
<fillField stepKey="step2" selector="#password" userInput="step2"/> | ||
<pause stepKey="pauseAfterStep2"/> | ||
<after> | ||
<amOnPage url="/afterUrl" stepKey="afterAmOnPageKey"/> | ||
<pause stepKey="pauseAfterAmOnPageKey"/> | ||
</after> | ||
</test> | ||
</tests> |
23 changes: 23 additions & 0 deletions
23
dev/tests/verification/PauseCheckModule/Test/TestWithPauseActionTest.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
|
||
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> | ||
<test name="TestWithPauseActionTest"> | ||
<annotations> | ||
<severity value="CRITICAL"/> | ||
<group value="functional"/> | ||
<features value="Pause check"/> | ||
<stories value="MQE-433"/> | ||
</annotations> | ||
<amOnPage stepKey="step1" url="/step1"/> | ||
<fillField stepKey="step2" selector="#username" userInput="step2"/> | ||
<fillField stepKey="step3" selector="#password" userInput="step3"/> | ||
<pause stepKey="pauseAfterStep3"/> | ||
</test> | ||
</tests> |
30 changes: 30 additions & 0 deletions
30
dev/tests/verification/Resources/StaticChecks/mftf-pause-action-usage-checks.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
File "/verification/PauseCheckModule/ActionGroup/ActionGroupWithMultiplePausesActionGroup.xml" | ||
contains pause action(s): | ||
|
||
ActionGroupWithMultiplePausesActionGroup has pause action at stepKey(s): pauseAfterFillField1, pauseAfterFillField2, pauseAfterFillField3 | ||
|
||
File "/verification/PauseCheckModule/ActionGroup/ActionGroupWithPauseActionGroup.xml" | ||
contains pause action(s): | ||
|
||
ActionGroupWithPauseActionGroup has pause action at stepKey(s): pauseAfterFillField2 | ||
|
||
File "/verification/PauseCheckModule/Test/TestWithMultiplePauseActionsTest.xml" | ||
contains pause action(s): | ||
|
||
TestWithMultiplePauseActionsTest has pause action at stepKey(s): pauseBeforeAmOnPageKey, pauseAfterStep2, pauseAfterAmOnPageKey | ||
|
||
File "/verification/PauseCheckModule/Test/TestWithPauseActionTest.xml" | ||
contains pause action(s): | ||
|
||
TestWithPauseActionTest has pause action at stepKey(s): pauseAfterStep3 | ||
|
||
File "/verification/PauseCheckModule/Suite/suiteWithMultiplePauseActionsSuite.xml" | ||
contains pause action(s): | ||
|
||
suiteWithMultiplePauseActionsSuite has pause action at stepKey(s): pauseCreate1, pauseFillAfter | ||
|
||
File "/verification/PauseCheckModule/Suite/suiteWithPauseActionSuite.xml" | ||
contains pause action(s): | ||
|
||
suiteWithPauseActionSuite has pause action at stepKey(s): pauseSuite |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
dev/tests/verification/Tests/StaticCheck/PauseActionStaticCheckTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace tests\verification\Tests; | ||
|
||
use AspectMock\Test as AspectMock; | ||
use Magento\FunctionalTestingFramework\StaticCheck\PauseActionUsageCheck; | ||
use Magento\FunctionalTestingFramework\StaticCheck\StaticChecksList; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
|
||
use tests\util\MftfStaticTestCase; | ||
|
||
class PauseActionStaticCheckTest extends MftfStaticTestCase | ||
{ | ||
const LOG_FILE = self::STATIC_RESULTS_DIR . | ||
DIRECTORY_SEPARATOR . | ||
PauseActionUsageCheck::ERROR_LOG_FILENAME . | ||
'.txt'; | ||
|
||
const TEST_MODULE_PATH = TESTS_MODULE_PATH . | ||
DIRECTORY_SEPARATOR . | ||
'PauseCheckModule'. | ||
DIRECTORY_SEPARATOR; | ||
|
||
/** | ||
* test static-check PauseActionUsageCheck. | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function testPauseActionUsageCheck() | ||
{ | ||
$staticCheck = new PauseActionUsageCheck(); | ||
|
||
$input = $this->mockInputInterface(self::TEST_MODULE_PATH); | ||
AspectMock::double(StaticChecksList::class, ['getErrorFilesPath' => self::STATIC_RESULTS_DIR]); | ||
|
||
/** @var InputInterface $input */ | ||
$staticCheck->execute($input); | ||
|
||
$this->assertTrue(file_exists(self::LOG_FILE)); | ||
$this->assertFileEquals( | ||
self::RESOURCES_PATH. | ||
DIRECTORY_SEPARATOR . | ||
PauseActionUsageCheck::ERROR_LOG_FILENAME . | ||
".txt", | ||
self::LOG_FILE | ||
); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.